/* Responsive Design */
/* Large screens (1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
    
    .overview-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Medium screens (768px to 1199px) */
@media (max-width: 1199px) and (min-width: 768px) {
    .container {
        max-width: 100%;
        padding: 0 30px;
    }
    
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Small screens (481px to 767px) */
@media (max-width: 767px) and (min-width: 481px) {
    .container {
        padding: 0 20px;
    }
    
    .dashboard-header {
        padding: 0 20px;
        height: 60px;
    }
    
    .header-left h1 {
        font-size: 1.3rem;
    }
    
    .header-left h1 i {
        font-size: 1.6rem;
    }
    
    .user-info {
        display: none;
    }
    
    .dashboard-nav {
        padding: 0 20px;
    }
    
    .nav-btn {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .dashboard-content {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 16px;
    }
    
    .overview-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .overview-card {
        padding: 20px;
    }
    
    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .card-content p {
        font-size: 1.5rem;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .settings-card {
        padding: 20px;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .setting-item input[type="number"] {
        width: 100%;
    }
    
    .app-card {
        padding: 20px;
    }
    
    .app-header {
        gap: 12px;
    }
    
    .app-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .app-info h3 {
        font-size: 1.1rem;
    }
    
    .app-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .app-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Extra small screens (480px and below) */
@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .dashboard-header {
        padding: 0 15px;
        height: 55px;
    }
    
    .header-left h1 {
        font-size: 1.1rem;
    }
    
    .header-left h1 i {
        font-size: 1.4rem;
    }
    
    .logout-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .logout-btn span {
        display: none;
    }
    
    .dashboard-nav {
        padding: 0 15px;
    }
    
    .nav-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .nav-btn span {
        display: none;
    }
    
    .nav-btn i {
        font-size: 18px;
    }
    
    .dashboard-content {
        padding: 15px 0px;
    }
    
    .section-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
    }
    
    .section-header h2 {
        font-size: 1.3rem;
    }
    
    .apps-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .app-card {
        padding: 16px;
    }
    
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .app-icon {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .app-info h3 {
        font-size: 1rem;
    }
    
    .app-description {
        font-size: 0.9rem;
        margin-bottom: 16px;
    }
    
    .app-meta {
        padding-top: 12px;
    }
    
    .app-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .app-btn {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .overview-grid {
        gap: 12px;
    }
    
    .overview-card {
        padding: 16px;
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    
    .card-icon {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    .card-content h3 {
        font-size: 1rem;
    }
    
    .card-content p {
        font-size: 1.3rem;
    }
    
    .settings-card {
        padding: 16px;
    }
    
    .settings-card h3 {
        font-size: 1.1rem;
        margin-bottom: 16px;
    }
    
    .setting-item {
        padding: 12px 0;
    }
    
    .setting-item label {
        font-size: 0.9rem;
    }
    
    .add-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }
    
    .search-container {
        max-width: 100%;
    }
    
    .search-container input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .auth-container {
        max-width: 500px;
        padding: 30px;
    }
    
    .dashboard-header {
        height: 50px;
    }
    
    .dashboard-nav {
        padding: 0 15px;
    }
    
    .nav-btn {
        padding: 8px 12px;
    }
    
    .dashboard-content {
        padding: 15px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .app-icon,
    .card-icon {
        border-radius: 8px;
    }
    
    .nav-btn {
        border-bottom-width: 2px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
    }
    
    .status-dot {
        animation: none;
    }
}

/* Dark mode support (if user prefers dark mode) */
@media (prefers-color-scheme: dark) {
    /* The app is already dark, so no changes needed */
}

/* Print styles */
@media print {
    .dashboard-header,
    .dashboard-nav,
    .logout-btn,
    .add-btn,
    .app-actions,
    .modal-overlay {
        display: none !important;
    }
    
    .dashboard {
        background: white !important;
        color: black !important;
    }
    
    .dashboard-content {
        padding: 0 !important;
    }
    
    .app-card,
    .overview-card,
    .settings-card {
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
}

/* Focus styles for keyboard navigation */
@media (any-hover: none) {
    /* Touch devices */
    .app-card:hover,
    .overview-card:hover,
    .nav-btn:hover,
    .btn:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    
    .app-card:active,
    .overview-card:active,
    .nav-btn:active,
    .btn:active {
        transform: scale(0.98);
    }
}

/* Very small screens (320px and below) */
@media (max-width: 320px) {
    .auth-container {
        padding: 20px 15px;
        margin: 10px;
    }
    
    .auth-header h1 {
        font-size: 1.8rem;
    }
    
    .auth-header p {
        font-size: 0.9rem;
    }
    
    .dashboard-header {
        padding: 0 10px;
    }
    
    .header-left h1 {
        font-size: 1rem;
    }
    
    .dashboard-content {
        padding: 10px;
    }
    
    .section-header h2 {
        font-size: 1.2rem;
    }
    
    .app-card,
    .overview-card,
    .settings-card {
        padding: 12px;
    }
    
    .app-icon,
    .card-icon {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    .app-info h3 {
        font-size: 0.9rem;
    }
    
    .card-content h3 {
        font-size: 0.9rem;
    }
    
    .card-content p {
        font-size: 1.1rem;
    }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Prevent zoom on input focus for iOS */
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }
    
    /* Improve touch targets */
    .btn,
    .nav-btn,
    .tab-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for mobile */
    .app-card {
        margin-bottom: 15px;
    }
    
    /* Improve modal usability on mobile */
    .modal-content {
        border-radius: 8px;
        margin: 10px;
    }
    
    /* Better form layout on mobile */
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Improve button spacing */
    .form-actions {
        gap: 10px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Mobile bottom navigation improvements */
    .mobile-bottom-nav {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: #000000;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    /* Ensure content doesn't overlap with bottom nav */
    .dashboard-content {
        padding-bottom: 90px;
    }
    
    /* Improve mobile nav touch targets */
    .mobile-nav-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Adjust spacing for different screen sizes */
    @media (max-width: 480px) {
        .mobile-bottom-nav {
            padding: 10px 15px;
        }
    }
}

/* Extra small mobile devices */
@media (max-width: 375px) {
    .mobile-nav-btn {
        font-size: 18px;
        padding: 10px 6px;
    }
    
    .mobile-bottom-nav {
        padding: 6px 0;
    }
    
    .dashboard-content {
        padding-bottom: 85px;
    }
}
