/* ========== GREEN THEME VARIABLES ========== */
:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-darker: #14532d;
    --primary-light: #22c55e;
    --primary-lighter: #86efac;
    --primary-bg: #f0fdf4;
    --primary-bg-soft: #dcfce7;
    --accent: #84cc16;
    --accent-light: #a3e635;
    --sidebar-bg: #14532d;
    --sidebar-hover: #166534;
    --sidebar-active: #15803d;
    --sidebar-width: 270px;
    --topbar-height: 64px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.07);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --shadow-green: 0 4px 20px rgba(22,163,74,0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== BASE ========== */
* { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--primary-bg);
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ========== PAGE LOADER ========== */
.page-loader {
    position: fixed; inset: 0; background: rgba(255,255,255,0.95);
    z-index: 9999; display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
}
.page-loader.show { display: flex; }
.spinner-ring {
    width: 56px; height: 56px;
    border: 4px solid var(--primary-bg-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-text { margin-top: 1rem; color: var(--primary); font-weight: 500; font-size: 0.875rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== FLASH MESSAGES ========== */
.flash-message {
    margin: 1rem 1.5rem 0; padding: 0.875rem 1.25rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; display: flex; align-items: center;
    animation: slideDown 0.4s ease, fadeIn 0.4s ease;
    position: relative;
    font-weight: 500;
}
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.flash-success { background: var(--primary-bg-soft); color: var(--primary-dark); border: 1px solid var(--primary-light); }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.flash-info { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
.flash-close { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: 0.6; }
.flash-close:hover { opacity: 1; }

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh;
    background: var(--sidebar-bg); color: #fff; z-index: 1040;
    transition: var(--transition); display: flex; flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
}
.sidebar-brand {
    padding: 1.25rem; display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-link { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: #fff; }
.brand-icon {
    width: 40px; height: 40px; background: var(--primary-light);
    border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; box-shadow: 0 2px 10px rgba(22,163,74,0.3);
}
.brand-title { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.5px; display: block; line-height: 1.2; }
.brand-subtitle { font-size: 0.7rem; opacity: 0.6; letter-spacing: 1px; display: block; }
.sidebar-close { background: none; border: none; color: #fff; font-size: 1.25rem; cursor: pointer; opacity: 0.7; }
.sidebar-close:hover { opacity: 1; }

.sidebar-nav { flex: 1; padding: 0.75rem 0.75rem; }
.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.8rem 1rem; margin-bottom: 0.25rem;
    color: rgba(255,255,255,0.7); text-decoration: none;
    border-radius: var(--radius-sm); transition: var(--transition);
    font-size: 0.9rem; font-weight: 500; position: relative;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; transform: translateX(4px); }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 2px 12px rgba(22,163,74,0.3); }
.sidebar-link.active::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 4px; height: 24px; background: var(--accent); border-radius: 0 4px 4px 0;
}
.sidebar-icon { width: 24px; text-align: center; font-size: 1.1rem; }
.sidebar-label { flex: 1; }
.sidebar-badge {
    background: #ef4444; color: #fff; font-size: 0.65rem; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px; display: flex;
    align-items: center; justify-content: center; padding: 0 6px;
}

/* Sidebar Footer */
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.06); }
.sidebar-user { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); text-transform: capitalize; }
.sidebar-version { font-size: 0.65rem; color: rgba(255,255,255,0.3); text-align: center; }

/* ========== MAIN WRAPPER ========== */
.main-wrapper { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: var(--transition); }

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-height); background: #fff;
    position: sticky; top: 0; z-index: 1030;
    box-shadow: var(--shadow); border-bottom: 1px solid rgba(0,0,0,0.04);
}
.topbar-inner {
    height: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem;
}
.sidebar-toggle-btn {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    border: 1px solid #e5e7eb; background: #fff; color: #374151;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; cursor: pointer; transition: var(--transition);
}
.sidebar-toggle-btn:hover { background: var(--primary-bg); border-color: var(--primary-light); color: var(--primary); }
.topbar-brand { color: var(--primary-dark); text-decoration: none; display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.topbar-icon-btn {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; text-decoration: none; position: relative;
    transition: var(--transition); font-size: 1.15rem; border: 1px solid transparent;
}
.topbar-icon-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-bg-soft); }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: #ef4444; color: #fff; font-size: 0.6rem; font-weight: 700;
    width: 18px; height: 18px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center;
    animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge { 0%,100%{transform:scale(1)} 50%{transform:scale(1.15)} }

.topbar-profile {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    border-radius: 50px; border: 1px solid #e5e7eb;
    background: #fff; cursor: pointer; transition: var(--transition);
}
.topbar-profile:hover { border-color: var(--primary-light); box-shadow: var(--shadow-green); }
.profile-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}
.profile-avatar.sm { width: 28px; height: 28px; font-size: 0.75rem; }

/* ========== PAGE CONTENT ========== */
.page-content { flex: 1; padding: 0; }
.content-container { padding: 1.5rem; }

/* ========== FOOTER ========== */
.app-footer { background: #fff; border-top: 1px solid rgba(0,0,0,0.05); }
.footer-inner { padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: #9ca3af; }

/* ========== CARDS ========== */
.card {
    border: none; border-radius: var(--radius); background: #fff;
    box-shadow: var(--shadow); transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    background: transparent; border-bottom: 1px solid #f3f4f6;
    padding: 1.25rem 1.5rem; font-weight: 600;
}
.card-body { padding: 1.5rem; }
.card-footer { background: transparent; border-top: 1px solid #f3f4f6; padding: 1rem 1.5rem; }

/* Stat Cards */
.stat-card { position: relative; overflow: hidden; padding: 1.5rem; }
.stat-card::after {
    content: ''; position: absolute; top: -20px; right: -20px;
    width: 100px; height: 100px; border-radius: 50%;
    background: rgba(22,163,74,0.04); transition: var(--transition);
}
.stat-card:hover::after { transform: scale(1.5); }
.stat-icon-green {
    width: 52px; height: 52px; border-radius: var(--radius-sm);
    background: var(--primary-bg-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    transition: var(--transition);
}
.stat-card:hover .stat-icon-green { background: var(--primary); color: #fff; transform: scale(1.1) rotate(-5deg); }
.stat-value { font-size: 1.75rem; font-weight: 800; color: #111827; line-height: 1; margin: 0.5rem 0; }
.stat-label { font-size: 0.8rem; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-link { font-size: 0.8rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.stat-link:hover { color: var(--primary-dark); }

/* Vehicle Card */
.vehicle-card { transition: var(--transition); border: 1px solid #f3f4f6; }
.vehicle-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-bg-soft); }

/* ========== BUTTONS ========== */
.btn { border-radius: var(--radius-sm); font-weight: 500; padding: 0.6rem 1.2rem; transition: var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-green); }
.btn-success { background: var(--primary-light); border-color: var(--primary-light); }
.btn-success:hover { background: var(--primary); border-color: var(--primary); transform: translateY(-2px); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); transform: translateY(-2px); }
.btn-outline-success { color: var(--primary); border-color: var(--primary-light); }
.btn-outline-success:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ========== FORMS ========== */
.form-control, .form-select {
    border-radius: var(--radius-sm); border: 1px solid #e5e7eb;
    padding: 0.65rem 1rem; font-size: 0.9rem; transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(22,163,74,0.1);
}
.form-label { font-size: 0.85rem; font-weight: 600; color: #374151; margin-bottom: 0.4rem; }
.input-group-text { background: #f9fafb; border-color: #e5e7eb; color: #6b7280; }

/* ========== TABLES ========== */
.table { font-size: 0.875rem; }
.table thead th { background: #f9fafb; font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; color: #6b7280; padding: 0.875rem 1.25rem; border-bottom: 1px solid #e5e7eb; }
.table tbody td { padding: 1rem 1.25rem; vertical-align: middle; color: #374151; }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--primary-bg); }

/* ========== BADGES ========== */
.bg-danger-subtle { background: #fef2f2 !important; }
.bg-warning-subtle { background: #fffbeb !important; }
.bg-success-subtle { background: #f0fdf4 !important; }
.bg-secondary-subtle { background: #f3f4f6 !important; }
.text-danger { color: #dc2626 !important; }
.text-success { color: #16a34a !important; }
.text-warning-emphasis { color: #b45309 !important; }

/* ========== PAGINATION ========== */
.pagination .page-link { border: none; color: #6b7280; border-radius: var(--radius-sm); margin: 0 2px; padding: 0.5rem 0.75rem; font-weight: 500; }
.pagination .page-item.active .page-link { background: var(--primary); color: #fff; }
.pagination .page-item:not(.active):not(.disabled) .page-link:hover { background: var(--primary-bg); color: var(--primary); }

/* ========== DETAILS GRID (Vehicle Details) ========== */
.details-grid { display: grid; gap: 0.75rem; }
.detail-item { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 0.6rem; border-bottom: 1px dashed #e5e7eb; }
.detail-item:last-child { border-bottom: none; padding-bottom: 0; }
.detail-label { font-weight: 500; color: #6b7280; font-size: 0.82rem; flex-shrink: 0; margin-right: 1rem; }
.detail-value { font-size: 0.85rem; color: #111827; text-align: right; word-break: break-word; font-weight: 500; }

/* ========== DOCUMENT UPLOAD ========== */
.upload-drop-zone {
    border: 2px dashed #d1d5db; border-radius: var(--radius); padding: 2rem;
    text-align: center; cursor: pointer; transition: var(--transition); background: #f9fafb;
}
.upload-drop-zone:hover, .upload-drop-zone.drag-over {
    border-color: var(--primary); background: var(--primary-bg); }
.document-thumb { cursor: pointer; transition: var(--transition); border: 1px solid #f3f4f6; border-radius: var(--radius-sm); overflow: hidden; }
.document-thumb:hover { transform: scale(1.03); box-shadow: var(--shadow-md); border-color: var(--primary-light); }

/* ========== NOTIFICATIONS ========== */
.notification-item { padding: 1rem 1.25rem; transition: var(--transition); cursor: pointer; border-left: 3px solid transparent; }
.notification-item:hover { background: #f9fafb; }
.notification-item.unread { background: var(--primary-bg); border-left-color: var(--primary); }

/* ========== LOGIN PAGE ========== */
.login-page-bg {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--primary-bg);
    position: relative; overflow: hidden;
}
.login-page-bg::before {
    content: ''; position: absolute; width: 600px; height: 600px;
    border-radius: 50%; background: rgba(22,163,74,0.08);
    top: -200px; right: -200px; animation: float 8s ease-in-out infinite;
}
.login-page-bg::after {
    content: ''; position: absolute; width: 400px; height: 400px;
    border-radius: 50%; background: rgba(132,204,22,0.06);
    bottom: -100px; left: -100px; animation: float 10s ease-in-out infinite reverse;
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-20px)} }
.login-card {
    background: #fff; border-radius: 24px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 440px; padding: 2.5rem; position: relative; z-index: 1;
    animation: loginSlide 0.6s ease;
}
@keyframes loginSlide { from { opacity:0; transform: translateY(30px); } to { opacity:1; transform: translateY(0); } }
.login-logo {
    width: 64px; height: 64px; background: var(--primary);
    border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem; font-size: 1.75rem; color: #fff;
    box-shadow: 0 4px 15px rgba(22,163,74,0.3);
    animation: logoPulse 2s ease-in-out infinite;
}
@keyframes logoPulse { 0%,100%{box-shadow:0 4px 15px rgba(22,163,74,0.3)} 50%{box-shadow:0 4px 25px rgba(22,163,74,0.5)} }
.login-title { font-size: 1.5rem; font-weight: 700; color: #111827; text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: #6b7280; font-size: 0.875rem; margin-bottom: 1.5rem; }
.login-input {
    width: 100%; padding: 0.875rem 1rem 0.875rem 2.75rem;
    border: 1.5px solid #e5e7eb; border-radius: var(--radius-sm);
    font-size: 0.9rem; transition: var(--transition); background: #f9fafb;
}
.login-input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(22,163,74,0.1); }
.login-input-group { position: relative; margin-bottom: 1rem; }
.login-input-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #9ca3af; font-size: 1.1rem; }
.login-btn {
    width: 100%; padding: 0.875rem; background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.login-btn:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-green); }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

/* ========== PERMISSION CARDS ========== */
.permission-card { border: 2px solid #e5e7eb; transition: var(--transition); cursor: pointer; }
.permission-card:hover { border-color: var(--primary-light); }
.permission-card.selected { border-color: var(--primary); background: var(--primary-bg); }
.permission-card .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ========== MOBILE SIDEBAR ========== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1039; backdrop-filter: blur(4px); }
.sidebar-overlay.show { display: block; animation: fadeIn 0.3s ease; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.animate-fade-up { animation: fadeUp 0.5s ease forwards; }
.animate-scale-in { animation: scaleIn 0.4s ease forwards; }

/* ========== ACCESS DENIED ========== */
.access-denied { text-align: center; padding: 4rem 1rem; }
.access-denied i { font-size: 5rem; color: #ef4444; animation: shake 0.5s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-10px)} 75%{transform:translateX(10px)} }

/* ========== RESPONSIVE ========== */
@media (max-width: 767.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .content-container { padding: 1rem; }
    .stat-value { font-size: 1.5rem; }
    .topbar-inner { padding: 0 1rem; }
    .detail-item { flex-direction: column; }
    .detail-value { text-align: left; margin-top: 0.25rem; }
    .card-body { padding: 1rem; }
}

/* ========== PRINT ========== */
@media print {
    .sidebar, .topbar, .app-footer, .no-print, .btn, .dropdown-menu, .alert, .sidebar-overlay, .page-loader { display: none !important; }
    .main-wrapper { margin-left: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    body { background: white !important; }
}

/* ========== TOAST NOTIFICATIONS ========== */
.custom-toast {
    background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: 1rem 1.25rem; display: flex; align-items: center; gap: 0.75rem;
    min-width: 300px; font-size: 0.875rem; font-weight: 500;
    animation: toastSlide 0.4s ease; border-left: 4px solid var(--primary);
    margin-bottom: 0.5rem;
}
@keyframes toastSlide { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { border-left-color: var(--primary); color: var(--primary-dark); }
.toast-error { border-left-color: #ef4444; color: #b91c1c; }
.toast-warning { border-left-color: #f59e0b; color: #b45309; }
