/* ============================================================
   Anti Gravity – Dashboard Styles
   ============================================================ */

/* Dashboard Layout */
body.db {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

/* Sidebar */
.db-sidebar {
    width: 268px;
    flex-shrink: 0;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    transition: var(--t-med);
    z-index: 100;
}

.db-sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-h);
    flex-shrink: 0;
}

.db-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.db-nav-section {
    padding: 0 0.75rem;
    margin-bottom: 1.5rem;
}

.db-nav-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-subtle);
    padding: 0 0.75rem 0.5rem;
    display: block;
}

.db-nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    transition: var(--t-fast);
    position: relative;
}

.db-nav-link:hover {
    background: rgba(var(--primary-rgb), 0.07);
    color: var(--primary);
}

.db-nav-link.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.db-nav-link.active::after {
    content: '';
    position: absolute;
    inset-inline-end: 0;
    top: 25%;
    bottom: 25%;
    width: 3px;
    background: var(--primary);
    border-radius: 4px 0 0 4px;
}

[dir="ltr"] .db-nav-link.active::after {
    border-radius: 0 4px 4px 0;
}

.db-nav-link .nav-badge {
    margin-inline-start: auto;
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: var(--r-full);
}

.db-sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.db-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--grad-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.db-user-info h5 {
    font-size: 0.875rem;
    margin: 0 0 0.15rem;
}

.db-user-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Area */
.db-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.db-header {
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
    gap: 1rem;
}

.db-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.db-header-left h4 {
    margin: 0;
    font-size: 1.05rem;
}

.db-breadcrumb {
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.db-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Metric Cards */
.db-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.db-metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--t-med);
    position: relative;
    overflow: hidden;
}

.db-metric::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: var(--grad-primary);
    opacity: 0.04;
    border-radius: 0 var(--r-lg) 0 50%;
}

.db-metric:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.db-metric-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.db-metric-icon.orange {
    background: rgba(var(--secondary-rgb), 0.1);
    color: var(--secondary);
}

.db-metric-icon.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.db-metric-icon.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.db-metric-body h3 {
    font-size: 1.75rem;
    font-weight: 900;
    margin: 0 0 0.25rem;
}

.db-metric-body p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}

.trend {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--r-full);
}

.trend.up {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.trend.down {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* Charts Grid */
.db-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width:1100px) {
    .db-charts {
        grid-template-columns: 1fr;
    }
}

.db-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
}

.db-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.db-panel-header h4 {
    margin: 0;
    font-size: 1rem;
}

/* Table */
.db-table-wrap {
    overflow-x: auto;
}

.db-table {
    width: 100%;
    border-collapse: collapse;
}

.db-table th,
.db-table td {
    padding: 0.875rem 1.25rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

[dir="ltr"] .db-table th,
[dir="ltr"] .db-table td {
    text-align: left;
}

.db-table th {
    color: var(--text-subtle);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--bg-alt);
}

.db-table tr:last-child td {
    border-bottom: none;
}

.db-table tr:hover td {
    background: rgba(var(--primary-rgb), 0.025);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.7rem;
    border-radius: var(--r-full);
    font-size: 0.75rem;
    font-weight: 700;
}

.status-pill.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.status-pill.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-pill.primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.status-pill::before {
    content: '•';
    font-size: 0.9rem;
}

/* Mobile Sidebar */
@media (max-width: 992px) {
    body.db {
        display: block;
    }

    .db-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        transform: translateX(100%);
        height: 100%;
        z-index: 500;
    }

    [dir="ltr"] .db-sidebar {
        transform: translateX(-100%);
    }

    .db-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .db-main {
        min-height: 100vh;
    }

    .db-content {
        padding: 1.25rem;
    }
}