/* ===================================================================
   Supplement to Bootstrap 5 — Agency Platform
   Variables injetadas via inline style no <body>:
     --primary-color  (ex: #2563eb)
     --sidebar-color  (ex: #111827)
=================================================================== */

:root {
    --primary-color: #2563eb;
    --sidebar-color: #111827;
    --bg-main: #F5F3ED;
    --border: #E5E5E5;
}

html, body { height: 100%; }

body {
    background: var(--bg-main);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Layout ─────────────────────────────────────────────────────── */

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

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content {
    flex: 1;
    padding: 28px 32px;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.btn-primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-color);
    color: #fff;
    border: 0;
    font-weight: 700;
}

.btn-primary-action:hover {
    background: color-mix(in srgb, var(--primary-color) 84%, #000);
    color: #fff;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
    width: 260px;
    background: var(--sidebar-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width 0.25s ease;
    z-index: 100;
}

.sidebar.collapsed { width: 72px; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(15,23,42,.42);
    z-index: 150;
}

/* Logo / brand */
.sidebar-logo {
    padding: 20px 18px;
    min-height: 72px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo img {
    max-width: 140px;
    max-height: 44px;
    object-fit: contain;
}

.sidebar-logo .agency-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-logo { padding: 20px 16px; justify-content: center; }
.sidebar.collapsed .sidebar-logo .menu-text,
.sidebar.collapsed .agency-name { display: none; }

/* Section labels */
.menu-section {
    padding: 18px 18px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,.4);
    white-space: nowrap;
}

.sidebar.collapsed .menu-section { display: none; }

/* Nav links */
.nav-link-side {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 2px 10px;
    border-radius: 8px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.nav-link-side i {
    font-size: 1.05rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.nav-link-side:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.nav-link-side.active {
    background: rgba(255,255,255,.15);
    color: #fff;
    font-weight: 600;
}

.sidebar.collapsed .nav-link-side {
    justify-content: center;
    padding: 10px;
    margin: 2px 8px;
}

.sidebar.collapsed .nav-link-side .menu-text { display: none; }

/* Client logo in sidebar */
.client-mini-logo {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Topbar ──────────────────────────────────────────────────────── */

.topbar {
    height: 62px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .topbar {
    background: #1b2029;
    border-color: #303847;
}

.topbar-toggle {
    background: none;
    border: none;
    font-size: 1.35rem;
    color: #6b7280;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    transition: background .15s, color .15s;
}

.topbar-toggle:hover { background: #f3f4f6; color: #111; }

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #18202f;
    margin: 0;
}

[data-bs-theme="dark"] .topbar-title { color: #f3f4f6; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6b7280;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0,0,0,.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #6b7280;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

/* ── Metric cards ────────────────────────────────────────────────── */

.metric-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(15,23,42,.05);
}

[data-bs-theme="dark"] .metric-card {
    background: #1b2029;
    border-color: #303847;
}

.metric-card .label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin-bottom: 8px;
}

.metric-card .value {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.1;
    color: #18202f;
}

[data-bs-theme="dark"] .metric-card .value { color: #f3f4f6; }

/* ── Chart / panel cards ─────────────────────────────────────────── */

.chart-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 1px 3px rgba(15,23,42,.05);
}

[data-bs-theme="dark"] .chart-panel {
    background: #1b2029;
    border-color: #303847;
}

.chart-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 18px;
    color: #18202f;
}

[data-bs-theme="dark"] .chart-panel-title { color: #f3f4f6; }

.chart-box {
    position: relative;
    width: 100%;
    height: 280px;
}

.chart-box canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ── Dashboard directory cards ───────────────────────────────────── */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.dashboard-card {
    display: block;
    min-height: 310px;
    padding: 0 0 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(15,23,42,.05);
    transition: transform .18s, border-color .18s, box-shadow .18s;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 12px 28px rgba(15,23,42,.1);
    color: inherit;
}

[data-bs-theme="dark"] .dashboard-card {
    background: #1b2029;
    border-color: #303847;
}

.dashboard-card-kicker {
    display: inline-block;
    margin: 18px 20px 10px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    color: var(--primary-color);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dashboard-card strong {
    display: block;
    font-size: 1.02rem;
    margin-bottom: 6px;
    padding: 0 20px;
}

.dashboard-card p {
    margin: 0;
    padding: 0 20px;
    font-size: 0.88rem;
    color: #6b7280;
    line-height: 1.45;
}

.dashboard-visual {
    position: relative;
    display: block;
    height: 132px;
    background:
        radial-gradient(circle at 24% 22%, rgba(255,255,255,.44), transparent 22%),
        linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 82%, #111827), #14b8a6 58%, #f59e0b);
    overflow: hidden;
}

.dashboard-visual::after {
    content: "";
    position: absolute;
    inset: 18px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 8px;
}

.dashboard-visual-bars {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 22px;
    height: 70px;
    display: flex;
    align-items: end;
    gap: 10px;
    z-index: 1;
}

.dashboard-visual-bars span {
    flex: 1;
    border-radius: 8px 8px 0 0;
    background: rgba(255,255,255,.72);
}

.dashboard-visual-line {
    position: absolute;
    left: 28px;
    right: 28px;
    top: 44px;
    height: 3px;
    border-radius: 999px;
    background: rgba(255,255,255,.72);
    transform: rotate(-8deg);
    transform-origin: left center;
    z-index: 2;
}

.dashboard-card-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 16px 20px 0;
    color: var(--primary-color);
    font-size: .86rem;
    font-weight: 800;
}

/* ── Users / permissions ─────────────────────────────────────────── */

.responsive-table {
    width: 100%;
    overflow-x: auto;
}

.user-table th {
    padding: 16px 18px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
    background: #f8fafc;
}

.user-table td {
    padding: 18px;
}

[data-bs-theme="dark"] .user-table th {
    background: #151a22;
    color: #a7b0bf;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    background: #eef2ff;
    color: #4338ca;
    font-size: .75rem;
    font-weight: 800;
}

.status-admin {
    background: #ecfeff;
    color: #0f766e;
}

.status-active {
    background: #ecfdf5;
    color: #047857;
}

.status-muted {
    background: #f3f4f6;
    color: #6b7280;
}

.permission-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.permission-list span {
    border-radius: 999px;
    background: #f3f4f6;
    padding: 5px 9px;
    font-size: .75rem;
    color: #4b5563;
    font-weight: 700;
}

.form-section + .form-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.role-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.role-option {
    display: flex;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.role-option input {
    margin-top: 4px;
}

.role-option strong,
.role-option small {
    display: block;
}

.role-option small {
    color: #6b7280;
    line-height: 1.35;
    margin-top: 4px;
}

.dashboard-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.dashboard-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
}

.dashboard-check input {
    margin-top: 4px;
}

.help-list {
    display: grid;
    gap: 14px;
}

.help-list div {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    color: #4b5563;
    font-size: .92rem;
}

.help-list i {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.demo-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 190px;
    margin-bottom: 22px;
    padding: 28px;
    border-radius: 10px;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(15,23,42,.18), rgba(15,23,42,.46)),
        linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 78%, #111827), #14b8a6 60%, #f59e0b);
    overflow: hidden;
}

.demo-hero h2 {
    font-size: clamp(1.6rem, 3vw, 2.5rem);
    font-weight: 850;
    margin: 0 0 8px;
}

.demo-hero p {
    max-width: 620px;
    margin: 0;
    color: rgba(255,255,255,.82);
}

.chart-box.tall {
    height: 340px;
}

/* ── Login page ──────────────────────────────────────────────────── */

body.login-page {
    background: var(--bg-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 420px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 38px 36px;
    box-shadow: 0 20px 50px rgba(15,23,42,.1);
}

.login-logo {
    max-width: 180px;
    max-height: 60px;
    object-fit: contain;
}

/* ── Settings / forms ────────────────────────────────────────────── */

.preview-panel-sidebar {
    background: var(--sidebar-color);
    border-radius: 8px 0 0 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.preview-panel-sidebar img {
    max-width: 80px;
    max-height: 38px;
    object-fit: contain;
}

.preview-bar {
    height: 10px;
    border-radius: 5px;
    background: rgba(255,255,255,.2);
}

.preview-panel-content {
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.preview-accent {
    width: 64px;
    height: 10px;
    border-radius: 5px;
    background: var(--primary-color);
}

.preview-title {
    width: 80%;
    height: 22px;
    border-radius: 5px;
    background: #e5e7eb;
}

.preview-text {
    width: 58%;
    height: 14px;
    border-radius: 5px;
    background: #e5e7eb;
}

/* ── Alerts / messages ───────────────────────────────────────────── */

.messages-area {
    padding: 16px 32px 0;
}

/* ── Misc ────────────────────────────────────────────────────────── */

.section-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin: 0 0 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #18202f;
    margin: 0 0 24px;
}

[data-bs-theme="dark"] .page-title { color: #f3f4f6; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.empty-state i { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: 14px; }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: left .25s ease, width .25s ease;
        z-index: 200;
    }

    .sidebar.open { left: 0; }

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

    .main { margin-left: 0; }

    .content { padding: 20px 18px; }

    .topbar { padding: 0 18px; }
}

@media (max-width: 720px) {
    .page-actions,
    .demo-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .btn-primary-action,
    .demo-hero .btn {
        width: 100%;
    }

    .role-options,
    .dashboard-checkbox-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-card {
        min-height: auto;
    }

    .metric-card .value {
        font-size: 1.4rem;
    }

    .chart-box,
    .chart-box.tall {
        height: 250px;
    }
}
