/*
 * TOIL Tracker - Enterprise Application Stylesheet (Bootstrap 5)
 * Version 4.1: Compact corporate design for business efficiency
 */

:root {
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 70px;
    --header-height: 56px;
    --primary-color: #1f2937;
    --primary-dark: #111827;
    --primary-light: #374151;
    --secondary-color: #6b7280;
    --accent-color: #3b82f6;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --surface-color: #ffffff;
    --surface-dark: #f9fafb;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --bs-body-font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --bs-body-font-weight: 400;
    --bs-body-line-height: 1.5;
}

[data-bs-theme="dark"] {
    --bs-body-bg: #0f172a;
    --bs-body-color: #e2e8f0;
    --bs-border-color: #374151;
    --bs-tertiary-bg: #1f2937;
    --surface-color: #1f2937;
    --surface-dark: #111827;
    --border-color: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
}

/* --- Typography & Base Styles --- */
body {
    font-family: var(--bs-body-font-family);
    font-weight: var(--bs-body-font-weight);
    line-height: var(--bs-body-line-height);
    background-color: var(--surface-dark);
    color: var(--text-primary);
    font-size: 14px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin-bottom: 0.75rem;
}

.text-primary { color: var(--accent-color) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }

/* --- Main Layout --- */
#app-container {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--primary-color);
    border-right: 1px solid var(--border-color);
    transition: width 0.2s ease;
    z-index: 1001;
    overflow-x: hidden;
    box-shadow: var(--shadow-md);
}

#main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
    min-height: 100vh;
    background-color: var(--surface-dark);
}

/* Collapsed State */
.sidebar-collapsed #sidebar {
    width: var(--sidebar-width-collapsed);
}
.sidebar-collapsed #main-content {
    margin-left: var(--sidebar-width-collapsed);
}
.sidebar-collapsed .logo-text,
.sidebar-collapsed .nav-text,
.sidebar-collapsed .user-name,
.sidebar-collapsed .submenu,
.sidebar-collapsed .notification-badge {
    display: none;
}

/* --- Sidebar Components --- */
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    height: var(--header-height);
    flex-shrink: 0;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--primary-dark);
}

.logo-img { 
    height: 32px; 
    width: 32px;
    border-radius: 4px;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.logo-text { 
    font-size: 1.1rem; 
    font-weight: 600; 
    margin-left: 0.75rem; 
    color: #ffffff;
}

.sidebar-nav { 
    flex-grow: 1; 
    padding: 0.5rem 0; 
    overflow-y: auto;
}

.nav-link {
    color: #d1d5db;
    margin: 0.125rem 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 6px;
    white-space: nowrap;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-link.active {
    background-color: var(--accent-color);
    color: #ffffff;
}

.nav-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.nav-text {
    flex-grow: 1;
}

.submenu {
    background-color: rgba(0, 0, 0, 0.2);
    margin: 0.25rem 0.75rem;
    padding: 0.25rem 0;
    border-radius: 6px;
}

.submenu-link {
    display: block;
    padding: 0.5rem 1rem 0.5rem 3rem;
    color: #d1d5db;
    font-size: 0.8125rem;
    font-weight: 400;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.15s ease;
}

.submenu-link:hover { 
    color: #ffffff; 
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    background-color: var(--primary-dark);
}

.user-info { 
    display: flex; 
    align-items: center; 
    flex-grow: 1;
}

.user-avatar { 
    width: 28px; 
    height: 28px; 
    border-radius: 4px; 
    background-color: var(--accent-color);
    color: white; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: 600; 
    margin-right: 0.625rem; 
    flex-shrink: 0;
    font-size: 0.75rem;
}

.user-name {
    font-weight: 500;
    color: #ffffff;
    font-size: 0.8125rem;
}

.logout-btn { 
    color: #9ca3af;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.logout-btn:hover { 
    color: white; 
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- Notification Badge --- */
.notification-badge {
    background-color: var(--danger-color);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    line-height: 1.2;
    min-width: 1.25rem;
    text-align: center;
    vertical-align: middle;
}

/* --- Top Bar & Main Content --- */
.top-bar {
    height: var(--header-height);
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.content-wrapper { 
    padding: 1.25rem; 
}

/* --- Enhanced Card Styles --- */
.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.card-header {
    background-color: var(--surface-dark);
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* --- Enhanced Table Styles --- */
.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table thead th {
    background-color: var(--surface-dark);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    vertical-align: middle;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-weight: 400;
}

.table tbody tr:hover {
    background-color: var(--surface-dark);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Enhanced Badge Styles --- */
.badge {
    font-weight: 500;
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
    color: white !important;
}

.badge.bg-danger {
    background-color: var(--danger-color) !important;
}

.badge.bg-primary {
    background-color: var(--accent-color) !important;
}

/* --- Interactive Elements --- */
.cursor-pointer {
    cursor: pointer;
}

.toggle-icon {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
    color: var(--text-muted);
}

tr[data-bs-toggle="collapse"][aria-expanded="true"] .toggle-icon {
    transform: rotate(90deg);
    color: var(--accent-color);
}

/* --- Button Enhancements --- */
.btn {
    font-weight: 500;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    border: 1px solid;
}

.btn-primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-outline-primary {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* --- Form Controls --- */
.form-control, .form-select {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.125rem rgba(59, 130, 246, 0.25);
}

/* --- Summary Statistics --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: right;
    position: relative;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--accent-color);
    border-radius: 8px 0 0 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* --- Action Buttons --- */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

/* --- Status Indicators --- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-approved { background-color: var(--success-color); }
.status-pending { background-color: var(--warning-color); }
.status-rejected { background-color: var(--danger-color); }

/* --- Responsive Design --- */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --sidebar-width-collapsed: 0;
    }
    
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
    
    #main-content {
        margin-left: 0;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.5rem 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* --- Utility Classes --- */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.leading-tight { line-height: 1.25; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Focus States --- */
.nav-link:focus,
.btn:focus,
.form-control:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

/* --- Print Styles --- */
@media print {
    #sidebar,
    .top-bar {
        display: none !important;
    }
    
    #main-content {
        margin-left: 0 !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}