/* ========================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM
   ======================================== */

/* CSS Custom Properties for Responsive Design */
:root {
    /* Breakpoints */
    --mobile: 576px;
    --tablet: 768px;
    --desktop: 992px;
    --large-desktop: 1200px;
    --xl-desktop: 1400px;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-xxl: 1.5rem;
    
    /* Layout */
    --sidebar-width: 250px;
    --sidebar-width-collapsed: 70px;
    --topbar-height: 60px;
    --content-padding: 2rem;
}

/* ========================================
   MOBILE FIRST APPROACH
   ======================================== */

/* Base Mobile Styles (up to 575px) */
@media (max-width: 575.98px) {
    /* Layout Adjustments */
    .wrapper {
        flex-direction: column;
    }
    
    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1050;
        transition: left 0.3s ease;
        background: white;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    #sidebar.active {
        left: 0;
    }
    
    #content {
        margin-left: 0;
        width: 100%;
        padding: 1rem;
        padding-top: calc(var(--topbar-height) + 1rem);
    }
    
    .top-nav {
        left: 0;
        padding: 0.5rem 1rem;
        height: var(--topbar-height);
    }
    
    /* Typography */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    h4 { font-size: 1rem; }
    
    /* Cards */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    /* Tables */
    .table-responsive {
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
    
    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
        border-radius: 0.375rem;
    }
    
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        border-radius: 0.375rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        margin-bottom: 0.25rem;
        border-radius: 0.375rem !important;
    }
    
    /* Grid System */
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .col,
    .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
    .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Navigation */
    .navbar-nav {
        flex-direction: column;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    
    /* Modals */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Dropdowns */
    .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0.5rem;
        border-radius: 0.375rem;
    }
    
    /* Alerts */
    .alert {
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        margin-bottom: 1rem;
    }
    
    /* Stats Cards */
    .stat-card {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    /* Page Header */
    .page-header {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0.5rem;
    }
    
    /* Welcome Section */
    .welcome-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Sidebar Toggle */
    .sidebar-toggle {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1060;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 0.375rem;
        padding: 0.5rem;
        font-size: 1.25rem;
    }
    
    /* Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

/* ========================================
   TABLET STYLES (576px - 991px)
   ======================================== */

@media (min-width: 576px) and (max-width: 991.98px) {
    /* Layout */
    #content {
        padding: 1.5rem;
        padding-top: calc(var(--topbar-height) + 1.5rem);
    }
    
    .top-nav {
        padding: 0.75rem 1.5rem;
    }
    
    /* Cards */
    .card-body {
        padding: 1.25rem;
    }
    
    /* Forms */
    .form-row {
        display: flex;
        flex-wrap: wrap;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .form-row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        flex: 1 1 auto;
        min-width: 0;
    }
    
    /* Buttons */
    .btn {
        width: auto;
        margin-bottom: 0;
    }
    
    .btn-group {
        flex-direction: row;
        width: auto;
    }
    
    /* Tables */
    .table th,
    .table td {
        padding: 0.75rem;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 1.75rem auto;
        max-width: 500px;
    }
    
    .modal-footer {
        flex-direction: row;
    }
    
    .modal-footer .btn {
        width: auto;
        margin-bottom: 0;
    }
    
    /* Stats Grid */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
}

/* ========================================
   DESKTOP STYLES (992px and up)
   ======================================== */

@media (min-width: 992px) {
    /* Layout */
    .wrapper {
        flex-direction: row;
    }
    
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: var(--sidebar-width);
        z-index: 1000;
    }
    
    #content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        padding: var(--content-padding);
        padding-top: calc(var(--topbar-height) + var(--content-padding));
    }
    
    .top-nav {
        left: var(--sidebar-width);
        padding: 0.75rem 2rem;
    }
    
    /* Hide mobile sidebar toggle */
    .sidebar-toggle {
        display: none;
    }
    
    /* Enhanced Typography */
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    
    /* Enhanced Cards */
    .card {
        margin-bottom: 2rem;
        border-radius: 0.75rem;
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    }
    
    .card-body {
        padding: 2rem;
    }
    
    .card-header {
        padding: 1.5rem 2rem;
    }
    
    /* Enhanced Tables */
    .table th,
    .table td {
        padding: 1rem 1.5rem;
    }
    
    /* Enhanced Forms */
    .form-control,
    .form-select {
        padding: 0.875rem 1rem;
        border-radius: 0.5rem;
    }
    
    /* Enhanced Buttons */
    .btn {
        padding: 0.875rem 1.5rem;
        border-radius: 0.5rem;
    }
    
    /* Enhanced Modals */
    .modal-dialog {
        margin: 1.75rem auto;
        max-width: 600px;
    }
    
    .modal-content {
        border-radius: 0.75rem;
    }
    
    .modal-header {
        padding: 1.5rem 2rem;
    }
    
    .modal-body {
        padding: 2rem;
    }
    
    .modal-footer {
        padding: 1.5rem 2rem;
    }
    
    /* Stats Grid */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
}

/* ========================================
   LARGE DESKTOP STYLES (1200px and up)
   ======================================== */

@media (min-width: 1200px) {
    /* Enhanced Layout */
    #content {
        padding: 2.5rem;
        padding-top: calc(var(--topbar-height) + 2.5rem);
    }
    
    .top-nav {
        padding: 1rem 2.5rem;
    }
    
    /* Enhanced Cards */
    .card-body {
        padding: 2.5rem;
    }
    
    .card-header {
        padding: 2rem 2.5rem;
    }
    
    /* Enhanced Tables */
    .table th,
    .table td {
        padding: 1.25rem 2rem;
    }
    
    /* Enhanced Forms */
    .form-control,
    .form-select {
        padding: 1rem 1.25rem;
    }
    
    /* Enhanced Buttons */
    .btn {
        padding: 1rem 2rem;
    }
    
    /* Enhanced Modals */
    .modal-dialog {
        max-width: 700px;
    }
    
    .modal-header {
        padding: 2rem 2.5rem;
    }
    
    .modal-body {
        padding: 2.5rem;
    }
    
    .modal-footer {
        padding: 2rem 2.5rem;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 2rem;
    }
}

/* ========================================
   XL DESKTOP STYLES (1400px and up)
   ======================================== */

@media (min-width: 1400px) {
    /* Maximum content width */
    .container-fluid {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    /* Enhanced spacing */
    #content {
        padding: 3rem;
        padding-top: calc(var(--topbar-height) + 3rem);
    }
    
    .top-nav {
        padding: 1.25rem 3rem;
    }
    
    /* Enhanced Cards */
    .card-body {
        padding: 3rem;
    }
    
    .card-header {
        padding: 2.5rem 3rem;
    }
    
    /* Enhanced Tables */
    .table th,
    .table td {
        padding: 1.5rem 2.5rem;
    }
    
    /* Enhanced Modals */
    .modal-dialog {
        max-width: 800px;
    }
    
    .modal-header {
        padding: 2.5rem 3rem;
    }
    
    .modal-body {
        padding: 3rem;
    }
    
    .modal-footer {
        padding: 2.5rem 3rem;
    }
}

/* ========================================
   LANDSCAPE ORIENTATION FIXES
   ======================================== */

@media (orientation: landscape) and (max-height: 600px) {
    /* Reduce vertical spacing for landscape mobile */
    .card-body {
        padding: 0.75rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .page-header {
        padding: 0.75rem;
    }
    
    .welcome-section {
        padding: 0.75rem;
    }
}

/* ========================================
   HIGH DPI DISPLAYS
   ======================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Enhanced borders and shadows for retina displays */
    .card {
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    
    .btn {
        border-width: 1px;
    }
    
    .form-control,
    .form-select {
        border-width: 1px;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus styles for better accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control,
    .form-select {
        border: 2px solid #000;
    }
}

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

@media print {
    #sidebar,
    .top-nav,
    .sidebar-toggle,
    .sidebar-overlay {
        display: none !important;
    }
    
    #content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    
    .table th {
        background: #f0f0f0 !important;
        color: black !important;
    }
    
    .btn {
        display: none !important;
    }
    
    .modal {
        position: static !important;
        display: block !important;
    }
    
    .modal-dialog {
        max-width: none !important;
        margin: 0 !important;
    }
}

/* ========================================
   UTILITY CLASSES FOR RESPONSIVE DESIGN
   ======================================== */

/* Responsive text alignment */
.text-responsive-left { text-align: left; }
.text-responsive-center { text-align: center; }
.text-responsive-right { text-align: right; }

@media (max-width: 575.98px) {
    .text-responsive-left { text-align: center; }
    .text-responsive-right { text-align: center; }
}

/* Responsive visibility */
.d-mobile { display: block; }
.d-tablet { display: none; }
.d-desktop { display: none; }

@media (min-width: 576px) and (max-width: 991.98px) {
    .d-mobile { display: none; }
    .d-tablet { display: block; }
    .d-desktop { display: none; }
}

@media (min-width: 992px) {
    .d-mobile { display: none; }
    .d-tablet { display: none; }
    .d-desktop { display: block; }
}

/* Responsive spacing */
.mobile-mt-0 { margin-top: 0; }
.mobile-mb-0 { margin-bottom: 0; }
.mobile-pt-0 { padding-top: 0; }
.mobile-pb-0 { padding-bottom: 0; }

@media (min-width: 576px) {
    .mobile-mt-0 { margin-top: inherit; }
    .mobile-mb-0 { margin-bottom: inherit; }
    .mobile-pt-0 { padding-top: inherit; }
    .mobile-pb-0 { padding-bottom: inherit; }
}

/* ========================================
   ANIMATIONS AND TRANSITIONS
   ======================================== */

/* Smooth transitions for responsive changes */
.wrapper,
#content,
#sidebar,
.top-nav,
.card,
.btn,
.form-control,
.form-select {
    transition: all 0.3s ease;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
} 