/* ============================================
   OCTONOS MOBILE OPTIMIZATION
   Comprehensive mobile-first responsive design
   ============================================ */

/* ============================================
   GLOBAL MOBILE LAYOUT (Tablets & Below)
   ============================================ */
@media (max-width: 1024px) {
    /* Remove sidebar margin from main content */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Adjust padding for smaller screens */
    .content-body {
        padding: 16px !important;
    }
    
    .content-header {
        padding: 20px 16px !important;
    }
    
    /* Make grids single column */
    .dashboard-charts-grid,
    .dashboard-bottom-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Sidebar overlay behavior */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Show hamburger menu */
    .hamburger-btn {
        display: flex !important;
    }
}

/* ============================================
   MOBILE PHONE LAYOUT (768px and below)
   ============================================ */
@media (max-width: 768px) {
    
    /* ===== TYPOGRAPHY ===== */
    .content-title,
    h1 {
        font-size: 22px !important;
        line-height: 1.3 !important;
    }
    
    .content-subtitle,
    h2 {
        font-size: 18px !important;
    }
    
    h3 {
        font-size: 16px !important;
    }
    
    p, .body-text {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
    
    /* ===== CONTAINERS ===== */
    .ideas-container,
    .ideas-page,
    .waitlist-container,
    .waitlist-page,
    .interviews-container,
    .mockups-container,
    .partners-container,
    .settings-container {
        padding: 16px !important;
    }
    
    /* ===== CARDS ===== */
    .card,
    .idea-card,
    .interview-card,
    .mockup-card,
    .partner-card {
        padding: 16px !important;
        margin-bottom: 12px !important;
    }
    
    /* ===== BUTTONS ===== */
    .btn,
    button {
        padding: 12px 20px !important;
        font-size: 14px !important;
        min-height: 44px; /* Touch-friendly */
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .btn-small,
    .btn-sm {
        padding: 8px 14px !important;
        font-size: 13px !important;
        min-height: 36px;
    }
    
    /* ===== FORMS ===== */
    input,
    select,
    textarea {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 44px; /* Touch-friendly */
        box-sizing: border-box !important;
    }
    
    textarea {
        min-height: 120px !important;
    }
    
    .form-group {
        margin-bottom: 16px !important;
    }
    
    label {
        font-size: 13px !important;
        margin-bottom: 6px !important;
        display: block;
    }
    
    /* ===== MODALS ===== */
    .modal-content,
    .modal-dialog {
        margin: 20px !important;
        max-width: calc(100% - 40px) !important;
        max-height: calc(100vh - 40px) !important;
        overflow-y: auto !important;
    }
    
    .modal-header {
        padding: 16px !important;
    }
    
    .modal-body {
        padding: 20px 16px !important;
    }
    
    .modal-footer {
        padding: 12px 16px !important;
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .modal-footer button {
        width: 100% !important;
    }
    
    /* ===== TABLES ===== */
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 13px !important;
        min-width: 100% !important;
    }
    
    th, td {
        padding: 10px 8px !important;
        white-space: nowrap;
    }
    
    /* Convert tables to cards on very small screens */
    .table-responsive {
        display: block !important;
    }
    
    /* ===== DASHBOARD KPIs ===== */
    .dashboard-kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .dashboard-kpi-card {
        flex-direction: row !important;
        text-align: left !important;
        padding: 16px !important;
        align-items: center !important;
        gap: 12px !important;
    }
    
    .dashboard-kpi-card .kpi-value {
        font-size: 24px !important;
        margin: 0 !important;
    }
    
    .dashboard-kpi-card .kpi-label {
        font-size: 12px !important;
        margin: 0 !important;
    }
    
    .icon-dashboard {
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0;
    }
    
    /* ===== CHARTS ===== */
    .dashboard-chart-card,
    .chart-card {
        padding: 16px !important;
        overflow: hidden !important;
    }
    
    .chart-container {
        height: 240px !important;
        position: relative !important;
        width: 100% !important;
    }
    
    .chart-container-sm {
        height: 200px !important;
        position: relative !important;
        width: 100% !important;
    }
    
    .chart-container canvas,
    .chart-container-sm canvas {
        max-width: 100% !important;
        height: auto !important;
        width: 100% !important;
    }
    
    .chart-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        margin-bottom: 16px !important;
    }
    
    .chart-title {
        font-size: 15px !important;
        font-weight: 600;
    }
    
    .chart-subtitle {
        font-size: 12px !important;
        color: #64748B;
    }
    
    .chart-controls {
        width: 100%;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .btn-chart-range {
        font-size: 11px !important;
        padding: 6px 12px !important;
        flex: 1;
        min-width: 80px;
    }
    
    /* ===== IDEAS SECTION ===== */
    .ideas-filters,
    .ideas-controls {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }
    
    .btn-add-idea,
    .add-idea-btn {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 15px !important;
        order: -1; /* Always on top */
    }
    
    /* Status filters (All, Active, Completed) */
    .ideas-status-filters,
    .status-filter-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    .btn-status-filter,
    .ideas-status-btn {
        flex: 1 !important;
        min-width: 0 !important;
        padding: 12px 8px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
        text-align: center;
    }
    
    /* Sort filters (Oldest/Newest First) */
    .ideas-sort-filters,
    .sort-filter-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    .btn-sort-filter,
    .ideas-sort-btn {
        flex: 1 !important;
        min-width: 0 !important;
        padding: 12px 12px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
    }
    
    /* Search inputs */
    .filter-search,
    .ideas-search,
    .search-input,
    input[type="search"] {
        width: 100% !important;
        margin-bottom: 12px !important;
    }
    
    /* ===== WAITLIST SECTION ===== */
    .waitlist-filters,
    .waitlist-controls {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }
    
    .waitlist-primary-actions,
    .waitlist-secondary-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .btn-waitlist-action,
    .btn-waitlist-export {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 15px !important;
        justify-content: center !important;
    }
    
    .waitlist-filter-controls select,
    #waitlist-idea-filter {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
    }
    
    /* ===== INTERVIEWS SECTION ===== */
    .interview-header,
    .interview-actions {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .interview-card {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .interview-meta {
        font-size: 12px !important;
        flex-wrap: wrap;
    }
    
    /* ===== MOCKUPS SECTION ===== */
    .mockup-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .mockup-card {
        padding: 16px !important;
    }
    
    .mockup-preview {
        height: 200px !important;
        overflow: hidden;
    }
    
    .mockup-actions {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .mockup-actions button {
        width: 100% !important;
    }
    
    /* ===== PARTNERSHIPS SECTION ===== */
    .partner-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .partner-card {
        padding: 16px !important;
    }
    
    .partner-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .partner-actions {
        width: 100%;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .partner-actions button {
        width: 100% !important;
    }
    
    /* ===== SETTINGS SECTION ===== */
    .settings-grid {
        grid-template-columns: 1fr !important;
    }
    
    .settings-card {
        padding: 16px !important;
    }
    
    .plan-cards-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .plan-card {
        padding: 20px !important;
    }
    
    .team-member-row {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: flex-start !important;
    }
    
    .team-member-row button {
        width: 100% !important;
    }
    
    /* ===== NAVIGATION & TABS ===== */
    .tab-navigation {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .tab-navigation::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }
    
    .tab-button {
        flex: 0 0 auto !important;
        min-width: 120px;
        font-size: 13px !important;
        padding: 10px 16px !important;
    }
    
    /* ===== DROPDOWNS & MENUS ===== */
    .dropdown-menu {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
    }
    
    /* ===== NOTIFICATIONS & TOASTS ===== */
    .notification,
    .toast {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        font-size: 14px !important;
        padding: 12px 16px !important;
    }
    
    /* ===== BADGES & PILLS ===== */
    .badge,
    .pill,
    .tag {
        font-size: 11px !important;
        padding: 4px 10px !important;
    }
    
    /* ===== PROGRESS BARS ===== */
    .progress-bar {
        height: 8px !important;
    }
    
    .progress-label {
        font-size: 12px !important;
    }
    
    /* ===== STATS & METRICS ===== */
    .stat-item {
        padding: 12px !important;
        flex-direction: column !important;
        text-align: center;
    }
    
    .stat-value {
        font-size: 20px !important;
    }
    
    .stat-label {
        font-size: 11px !important;
    }
}

/* ============================================
   SMALL MOBILE PHONES (480px and below)
   ============================================ */
@media (max-width: 480px) {
    
    /* Smaller typography */
    .content-title,
    h1 {
        font-size: 20px !important;
    }
    
    .content-subtitle,
    h2 {
        font-size: 16px !important;
    }
    
    /* Tighter padding */
    .content-body,
    .ideas-container,
    .waitlist-container {
        padding: 12px !important;
    }
    
    /* Smaller cards */
    .card,
    .idea-card {
        padding: 12px !important;
    }
    
    /* Smaller KPI values */
    .dashboard-kpi-card .kpi-value {
        font-size: 20px !important;
    }
    
    .dashboard-kpi-card .kpi-label {
        font-size: 11px !important;
    }
    
    /* Smaller charts */
    .chart-container {
        height: 200px !important;
    }
    
    .chart-container-sm {
        height: 180px !important;
    }
    
    /* Smaller buttons */
    .btn,
    button {
        font-size: 13px !important;
        padding: 10px 16px !important;
    }
    
    /* Modal adjustments */
    .modal-content {
        margin: 10px !important;
        max-width: calc(100% - 20px) !important;
    }
    
    .modal-header h3 {
        font-size: 16px !important;
    }
}

/* ============================================
   VERY SMALL PHONES (390px and below - iPhone 12 Pro)
   ============================================ */
@media (max-width: 390px) {
    
    /* Ultra-compact typography */
    .content-title {
        font-size: 18px !important;
    }
    
    /* Compact status filters */
    .btn-status-filter,
    .ideas-status-btn {
        font-size: 13px !important;
        padding: 10px 6px !important;
    }
    
    /* Compact sort filters */
    .btn-sort-filter,
    .ideas-sort-btn {
        font-size: 13px !important;
        padding: 10px 8px !important;
    }
    
    /* Compact waitlist buttons */
    .btn-waitlist-action,
    .btn-waitlist-export {
        font-size: 14px !important;
        padding: 12px 18px !important;
    }
    
    /* Compact select dropdowns */
    #waitlist-idea-filter,
    select {
        font-size: 13px !important;
        padding: 10px 14px !important;
    }
    
    /* Compact form inputs */
    input,
    textarea {
        font-size: 13px !important;
        padding: 10px 12px !important;
    }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    
    /* Reduce vertical padding */
    .content-header {
        padding: 12px 16px !important;
    }
    
    .content-body {
        padding: 12px !important;
    }
    
    /* Smaller modals */
    .modal-content {
        max-height: 90vh !important;
    }
    
    /* Compact charts */
    .chart-container,
    .chart-container-sm {
        height: 150px !important;
    }
    
    /* Hide non-essential elements */
    .content-subtitle {
        display: none !important;
    }
}

/* ============================================
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ============================================ */
@media (max-width: 768px) {
    
    /* Larger touch targets */
    a,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Prevent text selection on double tap */
    .no-select {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Smooth scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Focus states for accessibility */
    button:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid #14B8A6 !important;
        outline-offset: 2px;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    
    /* Disable animations on low-power devices */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
    
    /* GPU acceleration for smooth scrolling */
    .sidebar,
    .modal,
    .dropdown-menu {
        will-change: transform;
        transform: translateZ(0);
    }
}
