/* Responsive Design Utilities */

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container-xl {
        max-width: 1400px;
    }
    
    .col-xl-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-xl-2 { flex: 0 0 16.667%; max-width: 16.667%; }
    .col-xl-3 { flex: 0 0 25%; max-width: 25%; }
    .col-xl-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-xl-5 { flex: 0 0 41.667%; max-width: 41.667%; }
    .col-xl-6 { flex: 0 0 50%; max-width: 50%; }
    .col-xl-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-xl-8 { flex: 0 0 66.667%; max-width: 66.667%; }
    .col-xl-9 { flex: 0 0 75%; max-width: 75%; }
    .col-xl-10 { flex: 0 0 83.333%; max-width: 83.333%; }
    .col-xl-11 { flex: 0 0 91.667%; max-width: 91.667%; }
    .col-xl-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Large devices (desktops, 992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .col-lg-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-lg-2 { flex: 0 0 16.667%; max-width: 16.667%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-lg-5 { flex: 0 0 41.667%; max-width: 41.667%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-lg-8 { flex: 0 0 66.667%; max-width: 66.667%; }
    .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
    .col-lg-10 { flex: 0 0 83.333%; max-width: 83.333%; }
    .col-lg-11 { flex: 0 0 91.667%; max-width: 91.667%; }
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
    
    .nav-menu {
        gap: var(--space-sm);
    }
    
    .welcome-title {
        font-size: 2.25rem;
    }
}

/* Medium devices (tablets, 768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .col-md-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-md-2 { flex: 0 0 16.667%; max-width: 16.667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-md-5 { flex: 0 0 41.667%; max-width: 41.667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-md-8 { flex: 0 0 66.667%; max-width: 66.667%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333%; max-width: 83.333%; }
    .col-md-11 { flex: 0 0 91.667%; max-width: 91.667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    
    .navbar {
        padding: 0.5rem 0;
    }
    
    .nav-container {
        flex-wrap: wrap;
        padding: 0 var(--space-md);
    }
    
    .nav-logo {
        order: 1;
    }
    
    .search-container {
        order: 3;
        width: 100%;
        margin-top: var(--space-sm);
    }
    
    .search-input {
        width: 100%;
    }
    
    .user-profile {
        order: 2;
    }
    
    .nav-menu {
        display: none;
        order: 4;
        width: 100%;
        margin-top: var(--space-sm);
        background: var(--dark-card);
        border: 1px solid var(--dark-border);
        border-radius: var(--radius-md);
        padding: var(--space-sm);
    }
    
    .nav-menu.show {
        display: flex;
        flex-direction: column;
    }
    
    .menu-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--text-secondary);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
    }
    
    .main-container {
        padding: var(--space-md);
    }
    
    .welcome-banner {
        padding: var(--space-lg);
    }
    
    .welcome-title {
        font-size: 2rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .calendar-grid {
        font-size: 0.875rem;
    }
    
    .calendar-day {
        padding: 0.5rem;
    }
}

/* Small devices (landscape phones, 576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .col-sm-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-sm-2 { flex: 0 0 16.667%; max-width: 16.667%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-sm-5 { flex: 0 0 41.667%; max-width: 41.667%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-sm-8 { flex: 0 0 66.667%; max-width: 66.667%; }
    .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
    .col-sm-10 { flex: 0 0 83.333%; max-width: 83.333%; }
    .col-sm-11 { flex: 0 0 91.667%; max-width: 91.667%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .welcome-title {
        font-size: 1.75rem;
    }
    
    .welcome-subtitle {
        font-size: 1rem;
    }
    
    .section-title {
        font-size: 1.25rem;
    }
    
    .stat-card {
        padding: var(--space-md);
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    .modal-content {
        margin: 0 var(--space-sm);
    }
    
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-lg);
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575px) {
    .col-xs-1 { flex: 0 0 8.333%; max-width: 8.333%; }
    .col-xs-2 { flex: 0 0 16.667%; max-width: 16.667%; }
    .col-xs-3 { flex: 0 0 25%; max-width: 25%; }
    .col-xs-4 { flex: 0 0 33.333%; max-width: 33.333%; }
    .col-xs-5 { flex: 0 0 41.667%; max-width: 41.667%; }
    .col-xs-6 { flex: 0 0 50%; max-width: 50%; }
    .col-xs-7 { flex: 0 0 58.333%; max-width: 58.333%; }
    .col-xs-8 { flex: 0 0 66.667%; max-width: 66.667%; }
    .col-xs-9 { flex: 0 0 75%; max-width: 75%; }
    .col-xs-10 { flex: 0 0 83.333%; max-width: 83.333%; }
    .col-xs-11 { flex: 0 0 91.667%; max-width: 91.667%; }
    .col-xs-12 { flex: 0 0 100%; max-width: 100%; }
    
    html {
        font-size: 13px;
    }
    
    .navbar {
        padding: 0.5rem 0;
    }
    
    .nav-container {
        padding: 0 var(--space-sm);
        gap: var(--space-sm);
    }
    
    .nav-logo span {
        display: none;
    }
    
    .user-info {
        display: none;
    }
    
    .search-container {
        flex: 1;
        margin: 0;
    }
    
    .search-input {
        width: 100%;
    }
    
    .main-container {
        padding: var(--space-sm);
    }
    
    .welcome-banner {
        padding: var(--space-md);
        margin-bottom: var(--space-lg);
    }
    
    .welcome-title {
        font-size: 1.5rem;
    }
    
    .welcome-subtitle {
        font-size: 0.875rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
        margin-bottom: var(--space-lg);
    }
    
    .stat-card {
        padding: var(--space-md);
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .dashboard-section {
        margin-bottom: var(--space-lg);
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .quick-action-card {
        padding: var(--space-md);
    }
    
    .quick-action-icon {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
    }
    
    .calendar-grid {
        font-size: 0.75rem;
    }
    
    .calendar-day {
        padding: 0.375rem;
    }
    
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .modal-content {
        margin: 0 var(--space-xs);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-md);
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .footer-section {
        text-align: center;
    }
}

/* Print styles */
@media print {
    .navbar,
    .search-container,
    .user-profile,
    .btn,
    .footer,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt !important;
    }
    
    .main-container {
        padding: 0 !important;
        max-width: none !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
    }
    
    a {
        color: black !important;
        text-decoration: underline !important;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    thead {
        display: table-header-group;
    }
    
    tr {
        page-break-inside: avoid;
    }
    
    .page-break {
        page-break-before: always;
    }
    
    @page {
        margin: 2cm;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --dark-bg: #000000;
        --dark-card: #000000;
        --dark-text: #FFFFFF;
        --dark-text-secondary: #FFFFFF;
        --accent-gold: #FFFF00;
        --accent-brown: #FFA500;
        --border-light: #FFFFFF;
    }
    
    body {
        background: var(--dark-bg);
        color: var(--dark-text);
        border: 1px solid var(--border-light);
    }
    
    .card,
    .stat-card,
    .recent-activity,
    .calendar-widget {
        border: 2px solid var(--border-light);
    }
    
    .btn {
        border: 2px solid var(--border-light);
    }
}

/* Reduced motion */
@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;
    }
    
    .btn:hover,
    .card:hover,
    .stat-card:hover,
    .quick-action-card:hover,
    .activity-item:hover,
    .calendar-day:hover {
        transform: none !important;
    }
    
    .spinner,
    .progress-bar::after,
    .loading-shimmer {
        animation: none !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .tab-link,
    .dropdown-toggle,
    .accordion-header,
    .quick-action-card,
    .calendar-day {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control,
    select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"] {
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 44px;
    }
    
    .dropdown-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        transform: translateY(100%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .dropdown.show .dropdown-menu {
        transform: translateY(0);
    }
    
    .modal-content {
        max-height: 80vh;
        margin-bottom: env(safe-area-inset-bottom);
    }
}

/* Dark mode toggle animation */
.dark-mode-toggle {
    transition: all 0.3s ease;
}

.dark-mode-toggle:hover {
    transform: rotate(30deg);
}

/* Loading skeleton animations */
.skeleton {
    background: linear-gradient(90deg, 
        var(--dark-border) 25%, 
        var(--dark-card) 50%, 
        var(--dark-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Smooth scrolling for the whole page */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
:focus-visible {
    outline: 3px solid var(--accent-gold);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Skip to main content link for screen readers */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-gold);
    color: var(--text-on-gold);
    padding: 8px 16px;
    text-decoration: none;
    border-radius: var(--radius-sm);
    z-index: 9999;
    font-weight: 600;
}

.skip-to-content:focus {
    top: 10px;
}
