/* ============================================
   MOBILE-RESPONSIVE ADDON CSS
   Add this to existing label-designer.css
   Preserves all desktop functionality
   ============================================ */

/* Mobile Icon Navigation */
.mobile-icon-nav {
    display: none; /* Hidden by default */
}

@media (max-width: 767.98px) {
    /* Hide branding bar on very small screens */
    .zinlab-brand-bar {
        display: none;
    }
    
    /* Ensure toolbar buttons stay left-aligned */
    .top-toolbar {
        justify-content: flex-start;
    }
    
    .mobile-icon-nav {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        top: 60px;
        bottom: 0;
        width: 60px;
        background: var(--surface);
        border-right: 2px solid var(--border);
        padding: 8px 4px;
        gap: 6px;
        z-index: 100;
        overflow-y: auto;
    }
    
    .mobile-nav-btn {
        width: 52px;
        height: 52px;
        border: 1px solid var(--border);
        background: var(--surface);
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        color: var(--text-dark);
        font-size: 18px;
        padding: 6px;
        flex-shrink: 0;
    }
    
    .mobile-nav-btn i {
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    .mobile-nav-btn span {
        font-size: 8px;
        text-align: center;
        line-height: 1;
    }
    
    .mobile-nav-btn:hover,
    .mobile-nav-btn.active {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
    }
    
    .mobile-nav-btn.danger {
        background: #dc3545;
        color: white;
        border-color: #dc3545;
    }
    
    .mobile-context-divider {
        height: 1px;
        background: var(--border);
        margin: 8px 0;
    }
    
    /* Hide desktop sidebars on mobile */
    .template-sidebar,
    .controls-sidebar {
        display: none !important;
    }
    
    /* Hide selected controls section on mobile - use modal instead */
    .selected-object-controls {
        display: none !important;
    }
    
    /* Full width layout */
    .designer-layout {
        grid-template-columns: 1fr;
        padding: 0 !important;
        margin: 0 !important;
        gap: 0;
        margin-left: 25px !important; /* Only offset by icon nav width */
        width: calc(100vw - 25px) !important; /* Full width minus nav */
    }
    
    .canvas-area {
        padding: 8px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
    }
    
    /* Canvas fills available space */
    .canvas-wrapper {
        max-width: 100%;
        overflow: visible;
        margin: 0 auto;
        padding: 0;
        background: none;
    }
    
    #labelCanvas {
        max-width: 100%;
        height: auto !important;
        display: block;
        margin: 0 auto;
    }
}

/* Tool Modal System */
.mobile-tool-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 10000; /* Higher than everything */
    backdrop-filter: blur(4px);
}

.mobile-tool-modal.active {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.mobile-modal-content {
    background: var(--surface);
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUpModal 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUpModal {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid var(--border);
    background: var(--bg-secondary);
    position: relative;
}

.mobile-modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
}

.mobile-modal-header h5 {
    margin: 0;
    color: var(--primary);
    font-size: 16px;
    font-weight: 700;
}

.mobile-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    color: var(--text-dark); /* Light text for dark theme */
}

.mobile-modal-section {
    margin-bottom: 20px;
}

.mobile-modal-section:last-child {
    margin-bottom: 0;
}

.mobile-modal-section label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark); /* Light text */
    margin-bottom: 8px;
    display: block;
}

.mobile-modal-section p,
.mobile-modal-section small {
    color: var(--text-muted); /* Lighter muted text */
}

/* Tablet responsive (768-1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .mobile-icon-nav {
        display: flex;
        width: 64px;
    }
    
    .designer-layout {
        grid-template-columns: 200px 1fr;
        padding-left: 72px;
    }
    
    .template-sidebar {
        display: block !important;
    }
    
    .controls-sidebar {
        display: none !important;
    }
    
    .mobile-tool-modal.active {
        align-items: center;
        justify-content: flex-end;
    }
    
    .mobile-modal-content {
        width: 400px;
        max-height: 100vh;
        border-radius: 16px 0 0 16px;
        animation: slideLeftModal 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes slideLeftModal {
        from {
            transform: translateX(100%);
        }
        to {
            transform: translateX(0);
        }
    }
}

/* Touch-friendly form controls */
@media (max-width: 1024px) {
    .mobile-modal-body input[type="range"] {
        height: 36px;
        -webkit-appearance: none;
        appearance: none;
        background: transparent;
    }
    
    .mobile-modal-body input[type="range"]::-webkit-slider-track {
        height: 8px;
        background: var(--border);
        border-radius: 4px;
    }
    
    .mobile-modal-body input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 24px;
        height: 24px;
        background: var(--primary);
        border-radius: 50%;
        cursor: pointer;
        margin-top: -8px;
    }
    
    .mobile-modal-body input[type="range"]::-moz-range-track {
        height: 8px;
        background: var(--border);
        border-radius: 4px;
    }
    
    .mobile-modal-body input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
        background: var(--primary);
        border-radius: 50%;
        border: none;
        cursor: pointer;
    }
    
    .mobile-modal-body select,
    .mobile-modal-body input[type="text"],
    .mobile-modal-body input[type="number"],
    .mobile-modal-body textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .mobile-modal-body button {
        min-height: 44px;
    }
}

/* Desktop - hide all mobile elements */
@media (min-width: 1025px) {
    .mobile-icon-nav,
    .mobile-tool-modal {
        display: none !important;
    }
}

/* Utility classes for mobile modals */
.mobile-btn-group {
    display: flex;
    gap: 8px;
}

.mobile-btn {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.mobile-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.mobile-btn.danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.mobile-btn.outline {
    background: transparent;
}

.mobile-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.mobile-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Color swatches in modals */
.mobile-color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.mobile-color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.mobile-color-swatch:hover,
.mobile-color-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    transform: scale(1.05);
}

/* Range input with display */
.mobile-range-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-range-value {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    color: var(--primary);
}

.mobile-range-control input[type="range"] {
    flex: 1;
}

/* Prevent body scroll when modal open */
body.mobile-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

@media (max-width: 767.98px) {
    body.mobile-modal-open {
        position: fixed;
        width: 100%;
    }
}