/* ============================================
   Global Styles
   ============================================ */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 260px;
    --top-navbar-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

/* ============================================
   Wrapper & Layout
   ============================================ */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    background-color: #f5f7fa;
}

.content-wrapper {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
    }
    
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        position: fixed;
        z-index: 1050;
        height: 100vh;
        overflow-y: auto;
    }
    
    .sidebar.active {
        margin-left: 0;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
}

/* ============================================
   Sidebar Styles
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: margin-left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    gap: 0.75rem;
}

.logo:hover {
    color: #fff;
    text-decoration: none;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.logo-text {
    white-space: nowrap;
}

.sidebar-menu {
    padding: 1rem 0;
}

.sidebar-menu .nav {
    list-style: none;
    padding: 0;
}

.nav-divider {
    padding: 0.75rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.6);
    margin-top: 0.5rem;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 0.75rem;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--primary-color);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* ============================================
   Collapsible Menu Sections
   ============================================ */
.nav-menu-section {
    margin: 0.25rem 0;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 0.75rem;
    border-left: 3px solid transparent;
    cursor: pointer;
    font-weight: 500;
}

.nav-section-toggle:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--primary-color);
    text-decoration: none;
}

.nav-section-toggle .section-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.875rem;
    width: auto;
}

.nav-menu-section.active > .nav-section-toggle .section-icon {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.2);
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.nav-menu-section:not(.active) > .nav-submenu {
    max-height: 0;
    opacity: 0;
}

.nav-submenu .nav-item {
    margin: 0;
}

.nav-submenu .nav-link {
    padding-left: 3rem;
    font-size: 0.9rem;
}

.nav-submenu .nav-link i {
    width: 16px;
    font-size: 0.9rem;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-profile {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info i {
    font-size: 2rem;
    color: rgba(255,255,255,0.8);
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
}

.user-role {
    font-size: 0.75rem;
}

/* ============================================
   Top Navbar
   ============================================ */
.top-navbar {
    background: #fff;
    height: var(--top-navbar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 999;
}

#sidebarToggle {
    display: none;
    color: #333;
    font-size: 1.25rem;
    padding: 0.5rem;
    border: none;
    background: none;
}

@media (max-width: 768px) {
    #sidebarToggle {
        display: block;
    }
}

.navbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: 1rem;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    border: none;
}

.card-header {
    padding: 1.25rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    border-radius: 8px 8px 0 0 !important;
}

.card-body {
    padding: 1.5rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

/* ============================================
   Tables
   ============================================ */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
    padding: 0.75rem;
}

.table tbody td {
    padding: 1rem 0.75rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

/* ============================================
   Forms
   ============================================ */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

.form-control,
.form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
    border-radius: 4px;
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    border-radius: 6px;
    border: none;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

/* ============================================
   Responsive Utilities
   ============================================ */
@media (max-width: 576px) {
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: 6px !important;
        margin-bottom: 0.25rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    h1, .h1 {
        font-size: 1.5rem;
    }
    
    h3, .h3 {
        font-size: 1.25rem;
    }
}

@media (max-width: 768px) {
    .d-md-none {
        display: block !important;
    }
    
    .d-md-inline-block {
        display: none !important;
    }
}

/* ============================================
   Auth Pages
   ============================================ */
.auth-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 450px;
}

.auth-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.auth-card-header {
    padding: 2rem;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: #fff;
}

.auth-logo {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.auth-card-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.auth-card-header p {
    opacity: 0.9;
    margin: 0;
}

.auth-card-body {
    padding: 2rem;
}

.auth-footer {
    padding: 1.5rem 2rem;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* ============================================
   Loading & Spinner
   ============================================ */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* ============================================
   Custom Scrollbar
   ============================================ */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar,
    .top-navbar,
    .btn,
    .alert {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}
