/* Enhanced Mobile Responsiveness for Dhab.work */

/* Mobile-first approach with progressive enhancement */
@media (max-width: 480px) {
    /* Extra small devices (phones) */
    .container, .dashboard-container, .analytics-container, 
    .ideas-container, .task-container, .performance-container,
    .valuation-container, .shift-container {
        padding: 10px 5px;
    }
    
    /* Typography adjustments */
    h1 {
        font-size: 1.8rem !important;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.4rem !important;
    }
    
    h3 {
        font-size: 1.2rem !important;
    }
    
    /* Button adjustments */
    .header-btn, .fetch-btn, .back-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-height: 36px;
    }
    
    /* Form inputs */
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        min-height: 44px; /* Touch-friendly */
    }
    
    /* Tables - horizontal scroll on mobile */
    .data-table, table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        font-size: 0.8rem;
    }
    
    .data-table th, .data-table td,
    table th, table td {
        padding: 6px 8px;
        min-width: 80px;
    }
    
    /* Cards and sections */
    .stat-card, .app-card, .idea-card, .task-card {
        padding: 16px;
        margin-bottom: 12px;
    }
    
    /* Grid adjustments */
    .stats-grid, .apps-grid, .ideas-grid, .tasks-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    /* Notification panel mobile */
    .notification-panel {
        width: 100vw !important;
        right: -100vw !important;
    }
    
    .notification-panel.open {
        right: 0 !important;
    }
    
    .notification-bell {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    /* Modal adjustments */
    .modal {
        margin: 10px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
    
    /* Navigation improvements */
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-buttons {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
}

@media (max-width: 768px) {
    /* Small devices (tablets) */
    .container, .dashboard-container, .analytics-container, 
    .ideas-container, .task-container, .performance-container,
    .valuation-container, .shift-container {
        padding: 20px 10px;
    }
    
    /* Grid adjustments for tablets */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Header adjustments */
    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        text-align: center;
    }
    
    .header-right {
        align-items: center;
        flex-direction: column;
        gap: 15px;
    }
    
    /* Form improvements */
    .input-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .api-inputs {
        grid-template-columns: 1fr;
    }
    
    /* Table improvements */
    .data-table, table {
        font-size: 0.9rem;
    }
    
    .data-table th, .data-table td,
    table th, table td {
        padding: 8px 6px;
    }
}

@media (max-width: 1024px) {
    /* Medium devices (small laptops) */
    .container, .dashboard-container, .analytics-container, 
    .ideas-container, .task-container, .performance-container,
    .valuation-container, .shift-container {
        max-width: 100%;
        padding: 30px 15px;
    }
    
    /* Grid adjustments */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .apps-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .app-card, .stat-card, .idea-card, .task-card,
    .link-item, .notification-item {
        min-height: 44px;
        padding: 16px;
    }
    
    .header-btn, .fetch-btn, .back-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Remove hover effects on touch devices */
    .app-card:hover, .stat-card:hover, .idea-card:hover,
    .task-card:hover, .link-item:hover {
        transform: none;
        box-shadow: inherit;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .container, .dashboard-container, .analytics-container, 
    .ideas-container, .task-container, .performance-container,
    .valuation-container, .shift-container {
        padding: 10px;
    }
    
    .dashboard-header, .analytics-header, .ideas-header,
    .task-header, .performance-header, .valuation-header,
    .shift-header {
        margin-bottom: 20px;
    }
    
    h1 {
        font-size: 2rem !important;
        margin-bottom: 5px;
    }
    
    .stats-grid, .apps-grid {
        gap: 10px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .app-icon, .stat-icon {
        font-size: 2rem;
    }
    
    .notification-bell svg {
        width: 20px;
        height: 20px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Already using dark theme, but ensure consistency */
    body {
        background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .fadeInUp {
        animation: none !important;
    }
}

/* Print styles */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    
    .notification-bell, .notification-panel,
    .header-buttons, .back-btn {
        display: none !important;
    }
    
    .container, .dashboard-container, .analytics-container, 
    .ideas-container, .task-container, .performance-container,
    .valuation-container, .shift-container {
        max-width: none;
        padding: 0;
    }
    
    .stat-card, .app-card, .idea-card, .task-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Accessibility improvements */
@media (prefers-contrast: high) {
    .stat-card, .app-card, .idea-card, .task-card {
        border: 2px solid #ffffff;
    }
    
    .header-btn, .fetch-btn, .back-btn {
        border: 2px solid currentColor;
    }
}

/* Focus improvements for keyboard navigation */
.header-btn:focus, .fetch-btn:focus, .back-btn:focus,
input:focus, select:focus, textarea:focus {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}

/* Loading states */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    font-size: 1.1rem;
    color: #9ca3af;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #8b5cf6;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error states */
.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
}

/* Success states */
.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
}
