/**
 * Designer Module - Responsive Design
 * Mobile and Tablet Optimizations
 * 
 * @package    Designer Module
 * @subpackage CSS
 * @author     Kilo Code AI
 * @version    2.0.0
 */

/* ===== TABLET (< 1024px) ===== */

@media (max-width: 1024px) {
    /* Toolbar */
    .designer-toolbar {
        width: 56px;
    }
    
    .toolbar-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Right Panel */
    .designer-panel {
        width: 280px;
    }
    
    /* Properties Panel */
    .properties-panel {
        right: 280px;
    }
    
    /* Header */
    .header-title {
        font-size: var(--text-base);
        max-width: 300px;
    }
    
    /* Canvas Area */
    .designer-canvas-area {
        padding: var(--space-6);
    }
}

/* ===== MOBILE (< 768px) ===== */

@media (max-width: 768px) {
    /* Header */
    .designer-header {
        height: 56px;
        padding: 0 var(--space-4);
    }
    
    .header-title {
        font-size: var(--text-sm);
        max-width: 200px;
    }
    
    .header-right .btn span {
        display: none;
    }
    
    .header-right .btn {
        padding: var(--space-2) var(--space-3);
    }
    
    /* Main Content */
    .designer-main {
        margin-top: 56px;
        height: calc(100vh - 56px);
        flex-direction: column;
    }
    
    /* Toolbar becomes bottom bar */
    .designer-toolbar {
        width: 100%;
        height: 64px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-light);
        order: 3;
        padding: var(--space-2) var(--space-4);
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .toolbar-divider {
        width: 1px;
        height: 32px;
        margin: 0 var(--space-2);
    }
    
    /* Tooltip position for bottom toolbar */
    .toolbar-btn[data-tooltip]::after {
        bottom: 100%;
        left: 50%;
        top: auto;
        transform: translateX(-50%) translateY(-8px);
    }
    
    /* Canvas area */
    .designer-canvas-area {
        order: 1;
        padding: var(--space-4);
        height: calc(100vh - 56px - 64px);
    }
    
    .zoom-toolbar {
        top: var(--space-4);
        flex-wrap: wrap;
        max-width: calc(100% - var(--space-8));
    }
    
    .canvas-wrapper {
        max-width: 100%;
    }
    
    /* Right panel becomes full-screen modal */
    .designer-panel {
        position: fixed;
        top: 56px;
        right: 0;
        bottom: 64px;
        width: 100%;
        transform: translateX(100%);
        order: 2;
        z-index: var(--z-modal);
        border-left: none;
    }
    
    .designer-panel.open {
        transform: translateX(0);
    }
    
    /* Add overlay for panel */
    .designer-panel::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base);
    }
    
    .designer-panel.open::before {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Properties panel */
    .properties-panel {
        left: 0;
        right: 0;
        bottom: 64px;
    }
    
    .properties-body {
        max-height: 200px;
        overflow-y: auto;
    }
    
    /* Object Info */
    .object-info {
        flex-direction: column;
        gap: var(--space-2);
        padding: var(--space-3);
        max-width: calc(100% - var(--space-8));
    }
    
    .info-item {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }
}

/* ===== SMALL MOBILE (< 480px) ===== */

@media (max-width: 480px) {
    /* Header */
    .header-logo {
        height: 24px;
    }
    
    .header-title {
        display: none;
    }
    
    .header-right {
        gap: var(--space-2);
    }
    
    /* Canvas Area */
    .designer-canvas-area {
        padding: var(--space-2);
    }
    
    .canvas-wrapper {
        max-width: 100%;
        border-radius: var(--radius-lg);
    }
    
    #designer-canvas {
        max-width: 100%;
        height: auto !important;
    }
    
    /* Zoom Toolbar */
    .zoom-toolbar {
        width: calc(100% - var(--space-4));
        justify-content: space-between;
        padding: var(--space-1);
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
    }
    
    .zoom-display {
        min-width: 50px;
        font-size: var(--text-xs);
    }
    
    /* Toolbar */
    .toolbar-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }
    
    /* Panel */
    .panel-section {
        padding: var(--space-4);
    }
    
    .layers-list {
        max-height: 300px;
    }
    
    .layer-item {
        padding: var(--space-2);
    }
    
    .layer-icon {
        width: 28px;
        height: 28px;
        font-size: var(--text-xs);
    }
    
    .layer-name {
        font-size: var(--text-xs);
    }
    
    .layer-btn {
        width: 24px;
        height: 24px;
    }
    
    /* Properties Panel */
    .properties-header {
        padding: var(--space-3) var(--space-4);
    }
    
    .properties-body {
        padding: var(--space-4);
        max-height: 180px;
    }
    
    .property-row {
        grid-template-columns: 1fr;
    }
    
    /* Preview */
    .preview-image {
        min-height: 100px;
    }
    
    .preview-actions {
        flex-direction: column;
    }
    
    .preview-actions .btn {
        width: 100%;
    }
}

/* ===== LANDSCAPE MOBILE ===== */

@media (max-width: 768px) and (orientation: landscape) {
    .designer-canvas-area {
        height: calc(100vh - 56px - 56px);
    }
    
    .designer-toolbar {
        height: 56px;
    }
    
    .properties-panel {
        bottom: 56px;
    }
    
    .designer-panel {
        bottom: 56px;
    }
}

/* ===== TOUCH OPTIMIZATIONS ===== */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn {
        min-height: 44px;
        padding: var(--space-3) var(--space-6);
    }
    
    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }
    
    .toolbar-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .layer-btn {
        min-width: 32px;
        min-height: 32px;
    }
    
    /* Remove hover effects */
    .hover-lift:hover,
    .hover-scale:hover,
    .hover-brightness:hover,
    .hover-opacity:hover {
        transform: none;
        filter: none;
        opacity: 1;
    }
    
    /* Larger input fields */
    .input {
        min-height: 44px;
        font-size: var(--text-base);
    }
    
    /* Larger toggle buttons */
    .toggle-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===== PRINT STYLES ===== */

@media print {
    .designer-header,
    .designer-toolbar,
    .designer-panel,
    .designer-actions,
    .properties-panel,
    .zoom-toolbar,
    .object-info {
        display: none !important;
    }
    
    .designer-main {
        margin-top: 0;
        height: auto;
    }
    
    .designer-canvas-area {
        padding: 0;
        box-shadow: none;
    }
    
    .canvas-wrapper {
        box-shadow: none;
        border-radius: 0;
    }
}

/* ===== HIGH CONTRAST MODE ===== */

@media (prefers-contrast: high) {
    :root {
        --border-light: #000000;
        --border-medium: #000000;
        --border-dark: #000000;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
        --shadow-xl: none;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .input {
        border: 2px solid currentColor;
    }
}

/* ===== DARK MODE SUPPORT (OPTIONAL) ===== */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1A1A1A;
        --bg-secondary: #2D2D2D;
        --bg-tertiary: #3D3D3D;
        --bg-elevated: #2D2D2D;
        
        --text-primary: #F5F5F5;
        --text-secondary: #A0A0A0;
        --text-tertiary: #707070;
        
        --border-light: #3D3D3D;
        --border-medium: #4D4D4D;
        --border-dark: #5D5D5D;
    }
    
    .canvas-wrapper {
        background: #2D2D2D;
    }
    
    .designer-header {
        background: rgba(26, 26, 26, 0.95);
    }
}
