/* ===================================
   Mobile-First Responsive Styles
   =================================== */

/* Base Mobile Styles */
:root {
    --sidebar-width-md: 25%; /* col-md-3 width */
    --sidebar-width-lg: 16.666667%; /* col-lg-2 width */
    --navbar-height: 56px;
    --primary-color: #0d6efd;
    --sidebar-bg: #f8f9fa;
}

* {
    box-sizing: border-box;
}

body {
    font-size: 14px;
    line-height: 1.5;
}

/* ===================================
   Mobile Styles (< 768px)
   =================================== */

/* Navbar - Mobile */
.navbar {
    padding: 0.5rem 1rem;
    position: relative;
}

.navbar-brand {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.navbar-brand i {
    font-size: 1.2rem;
}

.navbar-text {
    display: none; /* Hide username on mobile */
}

.navbar .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

/* Sidebar - Mobile (Offcanvas) */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: -280px;
    width: 280px !important;
    height: calc(100vh - var(--navbar-height));
    background-color: var(--sidebar-bg);
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding: 1rem;
    max-width: 280px;
}

.sidebar.show {
    left: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--navbar-height));
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* Main Content - Mobile */
main {
    padding: 1rem 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    margin-left: 0 !important;
    position: relative;
    z-index: 1;
}

/* Cards - Mobile */
.card {
    margin-bottom: 1rem;
    border-radius: 0.5rem;
}

.card-header {
    padding: 0.75rem;
    font-size: 0.95rem;
}

.card-body {
    padding: 1rem;
}

/* Tables - Mobile (Card-based layout) */
.table-responsive {
    border-radius: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    font-size: 0.85rem;
}

table th,
table td {
    padding: 0.5rem 0.4rem;
    white-space: nowrap;
}

/* Hide less important columns on mobile */
@media (max-width: 575px) {
    .table-mobile-hide {
        display: none;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    table th,
    table td {
        padding: 0.4rem 0.3rem;
    }
}

/* Dashboard Cards - Mobile */
.dashboard-stats .col-md-3 {
    margin-bottom: 1rem;
}

.dashboard-stats .card-body {
    padding: 1rem 0.75rem;
}

.dashboard-stats h2 {
    font-size: 1.75rem;
}

.dashboard-stats .align-self-center i {
    font-size: 2rem !important;
}

.dashboard-stats .btn {
    font-size: 0.8rem;
    height: 25px;
    padding: 0 0.75rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.dashboard-stats .btn i {
    font-size: 0.8rem !important;
}

/* Forms - Mobile */
.form-label {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.form-control,
.form-select {
    font-size: 0.9rem;
    padding: 0.5rem;
}

.btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
}

/* Page Headers - Mobile */
.page-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.page-header .btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* Request Details - Mobile */
.request-details table th {
    width: 35%;
    font-size: 0.85rem;
    padding: 0.5rem 0.5rem 0.5rem 0;
    vertical-align: top;
}

.request-details table td {
    font-size: 0.85rem;
    padding: 0.5rem 0;
    word-break: break-word;
}

.request-details code {
    font-size: 0.75rem;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

/* Action Cards - Mobile */
.action-cards .col-md-4 {
    margin-bottom: 1rem;
}

.action-cards .card {
    margin-bottom: 1rem;
}

/* Login Page - Mobile */
.login-card {
    padding: 1rem;
    width: 100%;
    max-width: 100%;
}

.login-card .card {
    border-radius: 0.75rem;
}

.login-card .card-body {
    padding: 1.5rem 1rem;
}

.login-card i {
    font-size: 2.5rem !important;
}

.login-card h3 {
    font-size: 1.5rem;
}

/* Badges - Mobile */
.badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* Pagination - Mobile */
.pagination {
    font-size: 0.85rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination .page-link {
    padding: 0.375rem 0.5rem;
}

/* List Groups - Mobile */
.list-group-item {
    padding: 0.75rem;
    font-size: 0.9rem;
}

/* Hamburger Menu Button */
.mobile-menu-btn {
    display: inline-block;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

/* ===================================
   Tablet Styles (768px - 991px)
   =================================== */
@media (min-width: 768px) {
    body {
        font-size: 15px;
    }
    
    .navbar-brand {
        font-size: 1rem;
        max-width: none;
    }
    
    .navbar-text {
        display: inline-block;
        font-size: 0.9rem;
    }
    
    main {
        padding: 1.5rem 1rem !important;
    }
    
    .page-header {
        margin-bottom: 1.5rem;
    }
    
    .page-header h1 {
        font-size: 1.75rem;
    }
    
    .page-header .btn {
        width: auto;
        margin-top: 0;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    .request-details table th {
        width: 200px;
    }
    
    .login-card {
        max-width: 450px;
    }
}

/* ===================================
   Desktop Styles (≥ 992px)
   =================================== */
@media (min-width: 992px) {
    body {
        font-size: 16px;
    }
    
    /* Sidebar - Desktop (offcanvas drawer, hidden until opened) */
    .sidebar {
        position: fixed !important;
        top: var(--navbar-height) !important;
        left: -280px !important;
        width: 280px !important;
        max-width: 280px !important;
        height: calc(100vh - var(--navbar-height)) !important;
        min-height: calc(100vh - var(--navbar-height)) !important;
        padding: 1.5rem 1rem !important;
        margin: 0 !important;
        z-index: 1020 !important;
        background-color: var(--sidebar-bg) !important;
        transition: left 0.3s ease !important;
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
        box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    }

    .sidebar.show {
        left: 0 !important;
    }

    .sidebar-overlay {
        z-index: 1010;
    }
    
    /* Ensure sidebar nav is vertical */
    .sidebar .nav {
        flex-direction: column !important;
    }
    
    /* Container adjustments for fixed navbar */
    .container-fluid {
        margin-top: 0 !important;
        padding-top: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .container-fluid > .row {
        margin-top: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-top: 0 !important;
    }
    
    /* Main Content - Desktop (full width; sidebar overlays when open) */
    main {
        position: fixed !important;
        top: var(--navbar-height) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: calc(100vh - var(--navbar-height)) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        z-index: 1 !important;
        padding: 2rem 1.5rem !important;
        background-color: #fff;
    }
    
    /* Navbar - Desktop (Fixed/Sticky) */
    .navbar {
        padding: 0.75rem 1rem;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 1030 !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Add top padding to body on desktop to account for fixed navbar */
    body {
        padding-top: var(--navbar-height) !important;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-text {
        font-size: 1rem;
        margin-right: 1rem;
    }
    
    /* Cards - Desktop */
    .card-header {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    /* Tables - Desktop */
    table {
        font-size: 0.95rem;
    }
    
    table th,
    table td {
        padding: 0.75rem;
    }
    
    /* Dashboard Stats - Desktop */
    .dashboard-stats h2 {
        font-size: 2.5rem;
    }
    
    .dashboard-stats .align-self-center i {
        font-size: 2.5rem !important;
    }
    
    /* Page Headers - Desktop */
    .page-header {
        margin-bottom: 2rem;
        padding-bottom: 1rem;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    /* Forms - Desktop */
    .form-label {
        font-size: 1rem;
    }
    
    .form-control,
    .form-select {
        font-size: 1rem;
        padding: 0.6rem;
    }
    
    .btn {
        font-size: 1rem;
        padding: 0.6rem 1.2rem;
    }
    
    /* Request Details - Desktop */
    .request-details table th {
        width: 200px;
        font-size: 0.95rem;
        padding: 0.75rem 1rem 0.75rem 0;
    }
    
    .request-details table td {
        font-size: 0.95rem;
        padding: 0.75rem 0;
    }
    
    .request-details code {
        font-size: 0.9rem;
    }
    
    /* Login Page - Desktop */
    .login-card {
        max-width: 450px;
    }
    
    .login-card .card-body {
        padding: 2rem 2.5rem;
    }
    
    .login-card i {
        font-size: 3rem !important;
    }
    
    .login-card h3 {
        font-size: 1.75rem;
    }
    
    /* Badges - Desktop */
    .badge {
        font-size: 0.875rem;
        padding: 0.4em 0.75em;
    }
    
    /* Pagination - Desktop */
    .pagination {
        font-size: 1rem;
    }
    
    /* List Groups - Desktop */
    .list-group-item {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Hover Effects - Desktop Only */
    .nav-link:hover {
        background-color: #e7f1ff;
        border-radius: 0.375rem;
    }
    
    .card {
        transition: box-shadow 0.2s ease;
    }
    
    .card:hover {
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075), 
                    0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }
}

/* ===================================
   Large Desktop Styles (≥ 1200px)
   =================================== */
@media (min-width: 1200px) {
    main {
        padding: 2rem 2rem !important;
    }
    
    .card-body {
        padding: 2rem;
    }
    
    .dashboard-stats h2 {
        font-size: 3rem;
    }
    
    .page-header h1 {
        font-size: 2.25rem;
    }
}

/* ===================================
   Utility Classes
   =================================== */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
    
    .desktop-only {
        display: block;
    }
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

/* Code Blocks */
code {
    background-color: #f8f9fa;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

/* Company+branch grouped table rows */
.group-toggle .bi-chevron-right {
    display: inline-block;
    transition: transform 0.15s ease;
}

.group-toggle[aria-expanded="true"] .bi-chevron-right {
    transform: rotate(90deg);
}

.group-children-cell {
    background-color: #f8f9fa;
    padding: 0.75rem 1rem 1rem 2.5rem !important;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus States for Accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

