/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden; /* Prevent double scrollbars */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    padding-top: 56px; /* Height of fixed navbar */
}

/* Main container - full height and flex */
.main-container {
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

.row {
    height: 100%;
    margin: 0;
    flex: 1;
}

/* Fixed header styles */
.navbar.fixed-top {
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 1050;
    height: 56px;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.2rem;
}

.navbar-dark .navbar-nav .nav-link {
    color: rgba(255,255,255,0.9);
    padding: 0.5rem 1rem;
    transition: all 0.3s;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* Sidebar styles - Fixed and scrollable */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 250px;
    background-color: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Sidebar sticky container */
.sidebar-sticky {
    position: relative;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    flex: 1;
}

/* Custom scrollbar for sidebar */
.sidebar-sticky::-webkit-scrollbar {
    width: 5px;
}

.sidebar-sticky::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar-sticky::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.sidebar-sticky::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* For Firefox */
.sidebar-sticky {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

.sidebar .nav {
    padding: 0;
    margin: 0;
}

.sidebar .nav-link {
    padding: 10px 20px;
    color: #333;
    border-left: 3px solid transparent;
    transition: all 0.3s;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .nav-link:hover {
    background-color: #e9ecef;
    border-left-color: #007bff;
}

.sidebar .nav-link.active {
    background-color: #e9ecef;
    border-left-color: #007bff;
    color: #007bff;
    font-weight: 600;
}

.sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar .nav-link.text-danger:hover {
    background-color: #fce4e4;
    border-left-color: #dc3545;
}

.sidebar hr {
    margin: 10px 20px;
    border-top: 1px solid #dee2e6;
}

/* Main content area - adjusted for fixed sidebar */
main {
    margin-left: 250px;
    padding: 20px;
    background-color: #f8f9fa;
    min-height: calc(100vh - 56px);
    overflow-y: auto;
    height: calc(100vh - 56px);
}

/* Custom scrollbar for main content */
main::-webkit-scrollbar {
    width: 8px;
}

main::-webkit-scrollbar-track {
    background: #f1f1f1;
}

main::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

main::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* For Firefox */
main {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Card styles */
.card {
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border: none;
    background: #fff;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
    padding: 15px 20px;
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

.card-header h4, .card-header h5 {
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* Badge styles */
.badge {
    padding: 6px 12px;
    font-weight: 500;
    border-radius: 20px;
}

/* Table styles */
.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

.table td {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

.btn-sm {
    margin: 2px;
    padding: 4px 10px;
}

/* Modal styles */
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0 !important;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* Alert styles */
.alert {
    border-radius: 8px;
    border: none;
}

/* Form styles */
.form-control {
    border-radius: 6px;
    border: 1px solid #ced4da;
    transition: all 0.3s;
}

.form-control:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.3rem;
}

/* Button styles */
.btn {
    border-radius: 6px;
    padding: 0.4rem 1rem;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    border: none;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    border: none;
    color: #000;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.4);
}

/* Dashboard cards */
.card.bg-primary, .card.bg-success, .card.bg-warning, .card.bg-info {
    transition: transform 0.3s, box-shadow 0.3s;
    border: none;
}

.card.bg-primary:hover, .card.bg-success:hover, 
.card.bg-warning:hover, .card.bg-info:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

/* Status color coding */
.status-pending { background-color: #ffc107; color: #000; }
.status-branch_approved { background-color: #17a2b8; color: #fff; }
.status-ho_maker_approved { background-color: #0d6efd; color: #fff; }
.status-ho_checker_approved { background-color: #198754; color: #fff; }
.status-active { background-color: #198754; color: #fff; }
.status-rejected { background-color: #dc3545; color: #fff; }
.status-returned { background-color: #fd7e14; color: #fff; }

/* Responsive styles */
@media (max-width: 768px) {
    body {
        padding-top: 56px;
    }
    
    .sidebar {
        position: fixed;
        top: 56px;
        left: -100%;
        width: 280px;
        transition: left 0.3s ease;
        box-shadow: 2px 0 15px rgba(0,0,0,0.2);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    /* Overlay for mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    main {
        margin-left: 0 !important;
        padding: 15px;
        height: auto;
        min-height: calc(100vh - 56px);
        overflow-y: visible;
    }
    
    .table-responsive {
        font-size: 12px;
    }
    
    .table-responsive .btn-sm {
        padding: 2px 5px;
        font-size: 10px;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .card-header h4, .card-header h5 {
        font-size: 1rem;
    }
    
    /* Mobile toggle button */
    .navbar-toggler {
        display: block !important;
    }
}

@media (max-width: 576px) {
    .btn-group {
        display: flex;
        flex-wrap: wrap;
    }
    
    .btn-group .btn {
        flex: 1 1 auto;
        margin: 2px;
    }
    
    .sidebar {
        width: 100%;
        max-width: 300px;
    }
}

/* Print styles */
@media print {
    .sidebar, .navbar, .btn, .no-print {
        display: none !important;
    }
    
    body {
        padding-top: 0 !important;
    }
    
    main {
        margin-left: 0 !important;
        padding: 10px !important;
        height: auto !important;
        overflow-y: visible !important;
    }
    
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
    
    .table {
        font-size: 12px !important;
    }
    
    .badge {
        border: 1px solid #ddd !important;
    }
}

/* Custom animations */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Returned row highlight */
.returned-row {
    background-color: #fff3cd !important;
    border-left: 4px solid #fd7e14;
}

.returned-row:hover {
    background-color: #ffe69c !important;
}

/* User type badges */
.user-type-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* Download status */
.download-status-pending {
    color: #ffc107;
    font-weight: bold;
}

.download-status-downloaded {
    color: #28a745;
    font-weight: bold;
}

/* Filter section */
.filter-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Approval buttons */
.btn-approve {
    background-color: #28a745;
    color: white;
}

.btn-reject {
    background-color: #dc3545;
    color: white;
}

.btn-return {
    background-color: #ffc107;
    color: black;
}

.btn-approve:hover, .btn-reject:hover, .btn-return:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}