/**
 * SOLVUH Console - Responsive Styles
 * ===================================
 * Mobile-first responsive design for all views.
 */

/* =============================================================================
   BREAKPOINT VARIABLES
   ============================================================================= */

:root {
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
}

/* =============================================================================
   MOBILE BASE STYLES
   ============================================================================= */

/* Larger touch targets on touch devices */
@media (pointer: coarse) {
    button,
    .btn,
    [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }

    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .nav-item {
        padding: 14px 16px;
        min-height: 48px;
    }

    /* Larger checkbox/radio */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .nav-item:hover {
        background: transparent;
    }

    button:hover,
    .btn:hover {
        transform: none;
    }
}

/* =============================================================================
   REDUCED MOTION
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* =============================================================================
   MOBILE LAYOUT (< 768px)
   ============================================================================= */

@media (max-width: 767px) {
    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile-only elements */
    .mobile-only {
        display: block !important;
    }

    /* Full-width containers */
    .container,
    .card,
    .panel {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        border-radius: 0;
    }

    /* Stack grid layouts */
    .grid,
    .flex-row {
        flex-direction: column;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    /* Smaller padding */
    .p-6, .p-8 {
        padding: 16px;
    }

    .px-6, .px-8 {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Full-width buttons */
    .btn-group {
        flex-direction: column;
        gap: 8px;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Tables become cards */
    .table-responsive {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modal fullscreen on mobile */
    .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        margin: 0;
    }

    /* Scrollable content areas */
    .scroll-container {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .scroll-container > * {
        scroll-snap-align: start;
    }
}

/* =============================================================================
   TABLET LAYOUT (768px - 1023px)
   ============================================================================= */

@media (min-width: 768px) and (max-width: 1023px) {
    /* 2-column grids */
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Slightly smaller padding than desktop */
    .p-8 {
        padding: 24px;
    }

    /* Modal smaller but not fullscreen */
    .modal-content {
        max-width: 90%;
        max-height: 90%;
    }
}

/* =============================================================================
   DESKTOP LAYOUT (>= 1024px)
   ============================================================================= */

@media (min-width: 1024px) {
    /* Hide mobile-only elements */
    .mobile-only {
        display: none !important;
    }

    /* Show desktop-only elements */
    .desktop-only {
        display: block !important;
    }
}

/* =============================================================================
   VIEW-SPECIFIC RESPONSIVE RULES
   ============================================================================= */

/* Chat View */
@media (max-width: 767px) {
    .chat-container {
        flex-direction: column;
    }

    .chat-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
    }

    .chat-sidebar.open {
        display: flex;
    }

    .chat-input-container {
        padding: 12px;
    }

    .message-bubble {
        max-width: 90%;
    }
}

/* Pipeline View */
@media (max-width: 767px) {
    .pipeline-header {
        flex-direction: column;
        gap: 12px;
    }

    .pipeline-stages {
        flex-direction: column;
    }

    .stage-card {
        width: 100%;
    }
}

/* Workflow Designer */
@media (max-width: 767px) {
    .workflow-container {
        flex-direction: column;
    }

    .workflow-palette {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: 200px;
        overflow-x: auto;
        flex-direction: row;
        z-index: 100;
    }

    .workflow-canvas {
        height: calc(100vh - 200px);
    }

    .workflow-properties {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 50%;
        overflow-y: auto;
    }
}

/* Admin Dashboard */
@media (max-width: 767px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        display: none;
    }

    .admin-sidebar.open {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
    }
}

/* Brainstormer */
@media (max-width: 767px) {
    .brainstorm-model-flow {
        flex-direction: column;
    }

    .brainstorm-results-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .brainstorm-results-content {
        padding: 12px;
    }
}

/* E-commerce Dashboard */
@media (max-width: 767px) {
    .ecom-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ecom-metric-card {
        padding: 12px;
    }

    .ecom-orders-list {
        max-height: 300px;
    }
}

/* DevOps Dashboard */
@media (max-width: 767px) {
    .devops-services-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .devops-resources-panel,
    .devops-deployments-panel {
        width: 100%;
    }

    .devops-alerts-list {
        max-height: 200px;
    }
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Hide on specific breakpoints */
@media (max-width: 639px) {
    .hide-sm { display: none !important; }
}

@media (min-width: 640px) and (max-width: 767px) {
    .hide-sm-up { display: none !important; }
}

@media (max-width: 767px) {
    .hide-md { display: none !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hide-md-only { display: none !important; }
}

@media (max-width: 1023px) {
    .hide-lg { display: none !important; }
}

@media (min-width: 1024px) {
    .hide-lg-up { display: none !important; }
}

/* Flex direction responsive */
@media (max-width: 767px) {
    .flex-col-mobile { flex-direction: column !important; }
    .flex-row-mobile { flex-direction: row !important; }
}

/* Text alignment responsive */
@media (max-width: 767px) {
    .text-center-mobile { text-align: center !important; }
    .text-left-mobile { text-align: left !important; }
}

/* Gap responsive */
@media (max-width: 767px) {
    .gap-sm-mobile { gap: 8px !important; }
    .gap-md-mobile { gap: 12px !important; }
}

/* =============================================================================
   SAFE AREA (Notch) SUPPORT
   ============================================================================= */

@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    #mobile-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    #sidebar {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .modal-content {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* =============================================================================
   DARK MODE OPTIMIZATIONS
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    /* Reduce brightness of images in dark mode */
    img:not([src*=".svg"]) {
        filter: brightness(0.9);
    }

    /* Softer shadows in dark mode */
    .shadow,
    .card,
    .modal-content {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    /* Hide navigation and interactive elements */
    #sidebar,
    #mobile-header,
    #hamburger,
    .btn,
    button,
    .nav-item {
        display: none !important;
    }

    /* Full width content */
    #main,
    #view-container {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Ensure text is black */
    * {
        color: #000 !important;
        background: #fff !important;
    }

    /* Show links as text */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}
