/* ============================================================
   Admin Panel — Custom Stylesheet
   Bootstrap 5.3 + jQuery · Inter font
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4f46e5;
    --body-bg: #f1f5f9;
    --border-color: #e2e8f0;
    --sidebar-width: 264px;
    --sidebar-width-collapsed: 78px;
    --topbar-height: 68px;
    --radius: 1rem;
}

/* ---------- Base ---------- */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: #0f172a;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

h1, h2, h3, h4, h5, h6 { letter-spacing: -0.01em; }

/* ---------- Bootstrap overrides ---------- */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary);
    --bs-btn-active-border-color: var(--primary);
}

.btn { border-radius: 0.65rem; font-weight: 600; }
.btn-lg { border-radius: 0.75rem; }
.btn-sm { border-radius: 0.5rem; }

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 0.65rem;
    font-size: 1.25rem;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.btn-icon:hover { background: #e2e8f0; color: var(--primary); }

.form-control, .form-select {
    border-radius: 0.65rem;
    padding: 0.6rem 0.85rem;
    border-color: var(--border-color);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.12);
}

.input-group-lg .form-control, .input-group-lg .input-group-text { border-radius: 0.75rem; }
.input-group > .input-group-text {
    background: #fff;
    color: #94a3b8;
    border-color: var(--border-color);
}

.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input { width: 2.4em; }

.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}
.card-body { padding: 1.25rem; }

.table > :not(caption) > * > * { padding: 0.85rem 1.25rem; }
.table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.badge { font-weight: 600; padding: 0.45em 0.75em; }

.text-bg-primary { background: var(--primary) !important; }

/* ---------- Page loader ---------- */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s, visibility 0.35s;
}
.page-loader.hidden { opacity: 0; visibility: hidden; }

/* ---------- Admin layout ---------- */
.admin-body {
    min-height: 100vh;
    display: flex;
    background: var(--body-bg);
}

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.brand-logo {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
}

.brand-text {
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    margin-left: 0.75rem;
}
.brand-accent { color: #818cf8; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0.9rem;
}

.sidebar-section-title {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    padding: 0 0.75rem;
    margin: 1.1rem 0 0.5rem;
    white-space: nowrap;
}
.sidebar-section-title:first-child { margin-top: 0; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--sidebar-text);
    padding: 0.65rem 0.75rem;
    border-radius: 0.65rem;
    margin-bottom: 0.2rem;
    font-weight: 500;
    font-size: 0.925rem;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.sidebar-nav .nav-link i { font-size: 1.15rem; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #e2e8f0; }
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.nav-badge { background: rgba(255, 255, 255, 0.15); font-weight: 600; }

.sidebar-footer { padding: 1rem 0.9rem; flex-shrink: 0; }
.sidebar-card {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 0.8rem 0.9rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-card-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.55rem;
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
}
.sidebar-card-text { font-size: 0.85rem; font-weight: 600; }
.sidebar-card small { display: block; color: #64748b; font-size: 0.7rem; }

/* collapsed sidebar (desktop) */
@media (min-width: 992px) {
    .sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
    .sidebar-collapsed .sidebar .brand-text,
    .sidebar-collapsed .sidebar .sidebar-section-title,
    .sidebar-collapsed .sidebar .sidebar-nav .nav-link span,
    .sidebar-collapsed .sidebar .sidebar-nav .nav-badge,
    .sidebar-collapsed .sidebar .sidebar-card { display: none; }
    .sidebar-collapsed .sidebar .sidebar-brand { justify-content: center; padding: 0; }
    .sidebar-collapsed .sidebar .sidebar-nav .nav-link { justify-content: center; padding: 0.7rem 0; }
    .sidebar-collapsed .sidebar .sidebar-card { justify-content: center; padding: 0.6rem; }
    .sidebar-collapsed .sidebar .sidebar-nav { padding: 1rem 0.6rem; }
}

/* sidebar overlay (mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* ---------- Main area ---------- */
.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.sidebar-collapsed .admin-main { margin-left: var(--sidebar-width-collapsed); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}
.topbar-title h6 { font-size: 0.95rem; font-weight: 700; }
.topbar-title small { font-size: 0.75rem; }

.topbar-search { position: relative; }
.topbar-search i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
    z-index: 5;
}
.topbar-search .form-control {
    padding-left: 2.2rem;
    background: #f8fafc;
    min-width: 240px;
    border-radius: 2rem;
}

.user-menu {
    background: transparent;
    border: none;
    padding: 0.3rem 0.5rem;
    border-radius: 0.75rem;
    transition: background 0.2s;
}
.user-menu:hover { background: #f1f5f9; }

/* ---------- Avatars ---------- */
.avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}
.avatar-sm { width: 34px; height: 34px; font-size: 0.75rem; }
.avatar-xl { width: 84px; height: 84px; font-size: 1.6rem; }
.avatar-dim { filter: grayscale(0.7); opacity: 0.65; }

/* ---------- Dropdowns ---------- */
.user-dropdown { min-width: 240px; border-radius: 0.9rem; border-color: var(--border-color); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12); padding: 0.6rem; }
.user-dropdown .dropdown-item { border-radius: 0.6rem; padding: 0.55rem 0.8rem; font-weight: 500; font-size: 0.9rem; display: flex; align-items: center; gap: 0.6rem; }
.user-dropdown .dropdown-item i { font-size: 1rem; width: 18px; text-align: center; }
.user-dropdown .dropdown-item:hover { background: var(--primary-soft); }
.dropdown-header { font-size: 0.8rem; }

.notif-dropdown { width: 320px; border-radius: 0.9rem; border-color: var(--border-color); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12); }
.notif-header {
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.notif-item { display: flex; gap: 0.8rem; padding: 0.8rem 1rem; align-items: flex-start; }
.notif-item:hover { background: #f8fafc; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }

/* ---------- Content ---------- */
.admin-content {
    flex: 1;
    padding: 1.5rem;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h4 { font-size: 1.35rem; }
.page-header p { font-size: 0.9rem; }

/* ---------- Stat cards ---------- */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08); }

.stat-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.9rem;
    font-size: 1.35rem;
}
.stat-icon-primary { background: #eef2ff; color: #4f46e5; }
.stat-icon-success { background: #ecfdf5; color: #059669; }
.stat-icon-warning { background: #fffbeb; color: #d97706; }
.stat-icon-danger { background: #fef2f2; color: #dc2626; }

.stat-label { font-size: 0.78rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: #0f172a; }

/* ---------- Footer ---------- */
.admin-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: #64748b;
    border-top: 1px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
}

/* ---------- Toasts ---------- */
.toast {
    border: none;
    border-radius: 0.85rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
}
.toast .toast-body { display: flex; align-items: flex-start; gap: 0.6rem; font-weight: 500; }
.toast .toast-body i { font-size: 1.1rem; margin-top: 1px; }

/* ---------- Modals ---------- */
.modal-content { border: none; border-radius: 1.1rem; box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2); }
.modal-header { border-bottom: 1px solid var(--border-color); padding: 1.1rem 1.25rem; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 1rem 1.25rem; }

.delete-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fef2f2;
    color: #dc2626;
    font-size: 1.6rem;
}

/* ---------- Login page ---------- */
.login-body { min-height: 100vh; background: var(--body-bg); }

.login-wrapper { display: flex; min-height: 100vh; }

.login-brand-panel {
    flex: 1.15;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(129, 140, 248, 0.35), transparent 55%),
        radial-gradient(ellipse at 90% 85%, rgba(99, 102, 241, 0.3), transparent 55%),
        linear-gradient(135deg, #0f172a 0%, #1e1b4b 60%, #312e81 100%);
    overflow: hidden;
}
.login-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
    pointer-events: none;
}

.login-brand-inner { position: relative; max-width: 460px; }
.brand-logo-light { background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px); box-shadow: none; }
.brand-text-light { color: #fff; }
.login-headline { font-size: 2.1rem; line-height: 1.2; }
.login-headline span { color: #a5b4fc; }

.login-features li {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: #cbd5e1;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.55rem 0;
}
.login-features i { color: #34d399; font-size: 1.1rem; }

.login-brand-footer { position: relative; }

.login-form-panel {
    flex: 1;
    padding: 2rem;
}

.login-form-wrap { width: 100%; max-width: 430px; }

.login-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.08);
    padding: 2.25rem;
}
.login-title { font-size: 1.6rem; }

.btn-login {
    border-radius: 0.8rem;
    padding: 0.8rem;
    font-weight: 700;
    font-size: 1rem;
}

/* ---------- Business Workflow ---------- */
.workflow-timeline {
    position: relative;
    padding-left: 1.5rem;
}
.workflow-timeline::before {
    content: '';
    position: absolute;
    left: 0.95rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: #e2e8f0;
    border-radius: 2px;
}
.workflow-step {
    position: relative;
    display: flex;
    gap: 1rem;
    padding-bottom: 1.5rem;
}
.workflow-step:last-child { padding-bottom: 0; }
.workflow-node {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #cbd5e1;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.workflow-node-auto {
    background: #dcfce7;
    border-color: #16a34a;
    color: #15803d;
}
.workflow-body { padding-top: 0.2rem; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        box-shadow: 12px 0 32px rgba(15, 23, 42, 0.25);
    }
    .sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0 !important; }
    .sidebar-collapsed .admin-main { margin-left: 0 !important; }
}

@media (max-width: 767.98px) {
    .admin-content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .login-brand-panel { display: none; }
    .login-card { padding: 1.75rem; }
}
