/**
 * UI Kit & Admin Template Showcase Custom CSS
 * 100% Offline, Supports Dark/Light Mode, Modern Dashboard Widgets
 */

:root {
    --primary: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-subtle: #cfe2ff;
    --secondary: #6c757d;
    --secondary-subtle: #e2e3e5;
    --success: #198754;
    --success-subtle: #d1e7dd;
    --warning: #ffc107;
    --warning-subtle: #fff3cd;
    --danger: #dc3545;
    --danger-subtle: #f8d7da;
    --info: #0dcaf0;
    --info-subtle: #cff4fc;
    
    --bg-body: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --sidebar-color: #cbd5e1;
    --sidebar-active-bg: #0d6efd;
    --sidebar-active-color: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
}

[data-bs-theme="dark"] {
    --bg-body: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #111827;
    --bg-sidebar: #0f172a;
    --sidebar-color: #94a3b8;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #1f2937;
    --primary-subtle: rgba(13, 110, 253, 0.2);
    --success-subtle: rgba(25, 135, 84, 0.2);
    --warning-subtle: rgba(255, 193, 7, 0.2);
    --danger-subtle: rgba(220, 53, 69, 0.2);
    --info-subtle: rgba(13, 202, 240, 0.2);
    --secondary-subtle: rgba(108, 117, 125, 0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Layout Wrapper */
.app-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--sidebar-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: width 0.3s ease, transform 0.3s ease;
    border-right: 1px solid var(--border-color);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.nav-heading {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: #64748b;
    padding: 0.75rem 0.75rem 0.25rem;
}

.nav-link-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    color: var(--sidebar-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    margin-bottom: 0.15rem;
}

.nav-link-custom i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-link-custom:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.nav-link-custom.active {
    color: #ffffff;
    background-color: var(--sidebar-active-bg);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.35);
}

/* Collapsed Sidebar */
body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .nav-heading,
body.sidebar-collapsed .nav-text,
body.sidebar-collapsed .badge-pill-nav {
    display: none !important;
}

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

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* Header Navbar */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.header-search {
    max-width: 320px;
    width: 100%;
}

.header-search input {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 20px;
    padding-left: 2.25rem;
    font-size: 0.85rem;
}

/* Content Container */
.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* Page Header & Breadcrumb */
.page-title-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

/* Cards & Widgets */
.card-custom {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-custom:hover {
    box-shadow: var(--shadow-md);
}

.card-header-custom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
}

.card-header-custom .card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-body-custom {
    padding: 1.25rem;
}

/* KPI Stat Cards */
.stat-card {
    padding: 1.25rem;
    border-radius: 0.75rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-val {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
    margin-top: 0.25rem;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* Subtle Badges */
.badge-subtle-primary { background-color: var(--primary-subtle); color: var(--primary); border: 1px solid rgba(13, 110, 253, 0.3); }
.badge-subtle-success { background-color: var(--success-subtle); color: var(--success); border: 1px solid rgba(25, 135, 84, 0.3); }
.badge-subtle-warning { background-color: var(--warning-subtle); color: #b45309; border: 1px solid rgba(255, 193, 7, 0.4); }
.badge-subtle-danger { background-color: var(--danger-subtle); color: var(--danger); border: 1px solid rgba(220, 53, 69, 0.3); }
.badge-subtle-info { background-color: var(--info-subtle); color: #0284c7; border: 1px solid rgba(13, 202, 240, 0.3); }
.badge-subtle-secondary { background-color: var(--secondary-subtle); color: var(--secondary); border: 1px solid rgba(108, 117, 125, 0.3); }

/* Live Pulse Marker */
.pulse-online {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7);
    animation: pulseAnim 1.6s infinite;
}

@keyframes pulseAnim {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(25, 135, 84, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(25, 135, 84, 0); }
}

/* Aside Live Settings Drawer */
.aside-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
}

.aside-drawer.open {
    right: 0;
}

.aside-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
    display: none;
}

.aside-backdrop.show {
    display: block;
}

/* Footer */
.app-footer {
    height: 50px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show-mobile {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0 !important;
    }
}
