/* Responsive Design - Mobile First Approach */

:root {
    --primary-color: #003366;
    --secondary-color: #f8f9fa;
    --sidebar-width: 260px;
    --sidebar-width-mobile: 0;
    --navbar-height: 60px;
    --transition-speed: 0.3s ease-in-out;
}

* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

/* Sidebar Responsive */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--primary-color);
    color: white;
    padding-top: 20px;
    z-index: 1000;
    transition: transform var(--transition-speed);
    overflow-y: auto;
}

#sidebar .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 12px 20px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    border-left: 3px solid white;
    padding-left: 17px;
}

#content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left var(--transition-speed);
    min-height: 100vh;
}

/* Main Container */
.container-fluid {
    padding-right: 15px;
    padding-left: 15px;
}

/* Cards Responsive */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 8px;
    margin-bottom: 20px;
    transition: all var(--transition-speed);
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

/* Tables Responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    min-width: 100%;
    font-size: 14px;
}

.table thead th {
    font-weight: 600;
    border-top: none;
    vertical-align: middle;
    white-space: nowrap;
}

.table tbody td {
    vertical-align: middle;
    padding: 12px 8px;
}

/* Forms Responsive */
.form-group {
    margin-bottom: 1.5rem;
}

.form-control,
.form-select {
    border-radius: 4px;
    border: 1px solid #ddd;
    padding: 10px 12px;
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 51, 102, 0.25);
}

/* Buttons Responsive */
.btn {
    padding: 10px 16px;
    font-weight: 500;
    border-radius: 4px;
    transition: all var(--transition-speed);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #002547;
    border-color: #002547;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Hamburger Menu Toggle */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 24px;
    cursor: pointer;
    margin-right: 15px;
    z-index: 1001;
}

.sidebar-toggle:focus {
    outline: none;
}

/* Navbar */
.navbar {
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    padding: 10px 20px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-brand {
    font-weight: bold;
    color: var(--primary-color) !important;
    font-size: 18px;
}

/* Row and Column Spacing */
.row {
    margin-right: -7.5px;
    margin-left: -7.5px;
}

.row > [class*='col-'] {
    padding-right: 7.5px;
    padding-left: 7.5px;
}

/* Breadcrumb Responsive */
.breadcrumb {
    font-size: 13px;
    margin-bottom: 15px;
    background-color: transparent;
}

/* Badge Responsive */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Modal Responsive */
.modal-dialog {
    max-width: 90vw;
    margin: auto;
}

.modal-body {
    padding: 20px;
}

/* Toast Notification Responsive */
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 90vw;
    width: 350px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 15px;
    z-index: 9999;
}

/* Tablet Devices (768px and up) */
@media (max-width: 991px) {
    :root {
        --sidebar-width: 260px;
    }

    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.active {
        transform: translateX(0);
    }

    #content {
        margin-left: 0;
        padding: 15px;
    }

    .sidebar-toggle {
        display: block;
    }

    .table {
        font-size: 13px;
    }

    .table tbody td,
    .table thead th {
        padding: 10px 6px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .card {
        margin-bottom: 15px;
    }

    .form-control,
    .form-select {
        padding: 8px 10px;
        font-size: 13px;
    }
}

/* Mobile Devices (576px and up) */
@media (max-width: 576px) {
    :root {
        --sidebar-width: 260px;
    }

    body {
        padding-top: 0;
    }

    #sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        top: 60px;
    }

    #sidebar.active {
        transform: translateX(0);
    }

    #content {
        margin-left: 0;
        padding: 10px;
    }

    .sidebar-toggle {
        display: block;
    }

    /* Navbar Responsive */
    .navbar {
        padding: 8px 10px;
        margin-bottom: 10px;
        position: sticky;
        top: 0;
    }

    .navbar-brand {
        font-size: 16px;
    }

    /* Container Responsive */
    .container,
    .container-fluid {
        padding-right: 10px;
        padding-left: 10px;
    }

    /* Row Spacing */
    .row {
        margin-right: -5px;
        margin-left: -5px;
    }

    .row > [class*='col-'] {
        padding-right: 5px;
        padding-left: 5px;
    }

    /* Table Responsive */
    .table {
        font-size: 12px;
        margin-bottom: 0;
    }

    .table thead th {
        font-size: 11px;
        padding: 8px 4px;
    }

    .table tbody td {
        padding: 8px 4px;
    }

    /* Card Responsive */
    .card {
        border-radius: 6px;
        margin-bottom: 12px;
    }

    .card-header {
        padding: 12px;
        font-size: 13px;
    }

    .card-body {
        padding: 12px;
    }

    .card-footer {
        padding: 10px;
    }

    /* Form Responsive */
    .form-group {
        margin-bottom: 12px;
    }

    .form-control,
    .form-select {
        padding: 8px;
        font-size: 14px;
        border-radius: 4px;
    }

    /* Button Responsive */
    .btn {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 4px;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 11px;
    }

    .btn-lg {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Button Group */
    .btn-group {
        flex-wrap: wrap;
    }

    /* Badge Responsive */
    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 11px;
        margin-bottom: 10px;
    }

    /* Modal */
    .modal-dialog {
        max-width: 95vw;
    }

    .modal-header {
        padding: 12px;
    }

    .modal-body {
        padding: 12px;
    }

    .modal-footer {
        padding: 10px;
    }

    /* Toast */
    .toast-notification {
        width: 85vw;
        bottom: 15px;
        right: 7.5vw;
        left: auto;
        max-width: none;
        padding: 12px;
    }

    /* Dropdown */
    .dropdown-menu {
        min-width: 180px;
        font-size: 12px;
    }

    .dropdown-item {
        padding: 8px 12px;
    }

    /* List Group */
    .list-group-item {
        padding: 10px;
        font-size: 13px;
    }

    /* Pagination */
    .pagination {
        font-size: 12px;
    }

    .page-link {
        padding: 6px 10px;
    }

    /* Alert */
    .alert {
        padding: 12px;
        font-size: 13px;
        margin-bottom: 12px;
    }

    /* Text Utilities */
    .text-truncate {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Helper Classes */
    .d-block {
        display: block !important;
    }

    .d-inline {
        display: inline !important;
    }

    .d-inline-block {
        display: inline-block !important;
    }
}

/* Extra Small Devices (below 480px) */
@media (max-width: 480px) {
    :root {
        --sidebar-width: 100%;
    }

    #sidebar {
        width: 100%;
    }

    .navbar {
        padding: 8px;
    }

    .navbar-brand {
        font-size: 14px;
    }

    #sidebar .px-4 {
        padding: 0.5rem !important;
    }

    .card-header {
        padding: 10px;
        font-size: 12px;
    }

    .card-body {
        padding: 10px;
    }

    .table {
        font-size: 11px;
    }

    .table thead th,
    .table tbody td {
        padding: 6px 3px;
    }

    .btn {
        padding: 8px 10px;
        font-size: 11px;
        width: 100%;
        margin-bottom: 5px;
    }

    .btn-group,
    .btn-toolbar {
        flex-wrap: wrap;
    }

    .form-control,
    .form-select {
        padding: 8px;
        font-size: 13px;
        width: 100%;
    }

    /* Full width form elements on mobile */
    .form-group {
        margin-bottom: 10px;
    }

    label {
        font-size: 12px;
        margin-bottom: 5px;
    }

    .toast-notification {
        width: 90vw;
        left: 5vw;
    }
}

/* Dark Mode Responsive */
body.dark-mode #sidebar {
    background-color: #0d1117;
}

body.dark-mode #content {
    background-color: #0b0e11;
}

body.dark-mode .card {
    background-color: #151b22;
    border: 1px solid #30363d;
}

body.dark-mode .navbar {
    background-color: #0d1117;
    border-bottom: 1px solid #30363d;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}

body.dark-mode .table {
    color: #c9d1d9;
}

body.dark-mode .table thead th {
    background-color: #161b22;
    color: #f0f6fc;
    border-color: #30363d;
}

body.dark-mode .table tbody td {
    border-color: #30363d;
}

/* Print Responsive */
@media print {
    #sidebar,
    .navbar,
    .btn,
    .breadcrumb,
    .sidebar-toggle {
        display: none !important;
    }

    #content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }

    body {
        background-color: white !important;
    }

    .table {
        border-collapse: collapse;
    }
}

/* Landscape Mobile */
@media (max-height: 600px) and (orientation: landscape) {
    #sidebar {
        overflow-y: auto;
        max-height: 100vh;
    }

    .card {
        margin-bottom: 10px;
    }

    .form-group {
        margin-bottom: 8px;
    }
}

/* High DPI Devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Accessibility - 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;
    }
}

/* Touch Devices */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .sidebar-toggle {
        min-height: 44px;
        min-width: 44px;
    }

    .nav-link {
        padding: 15px 20px;
    }
}
