/* Internal admin/client dashboard theme. Shares the public site's brand
   tokens (warm ink, deep emerald accent, Plus Jakarta Sans) so the product
   feels like one thing end to end, instead of a polished marketing site
   bolted onto stock unstyled Bootstrap. Re-skins Bootstrap 5.3 mostly by
   overriding its own CSS variables (--bs-primary, --bs-body-font-family,
   --bs-border-radius, --bs-focus-ring-color) so buttons, form focus rings,
   links, etc. pick the theme up automatically instead of needing a
   per-component override each. */

:root {
    --pe-bg: #F5F6F4;
    --pe-card: #FFFFFF;
    --pe-ink: #15181C;
    --pe-ink-muted: #676D66;
    --pe-accent: #0B6E4F;
    --pe-accent-ink: #FFFFFF;
    --pe-accent-dark: #08543C;
    --pe-accent-soft: rgba(11, 110, 79, 0.08);
    --pe-line: rgba(21, 24, 28, 0.10);
    --pe-line-strong: rgba(21, 24, 28, 0.20);
    --pe-warn: #B5792A;
    --pe-font-display: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    --pe-font-body: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --bs-primary: var(--pe-accent);
    --bs-primary-rgb: 11, 110, 79;
    --bs-body-font-family: var(--pe-font-body);
    --bs-border-radius: 8px;
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 10px;
    --bs-focus-ring-color: rgba(11, 110, 79, 0.25);
    --bs-link-color: var(--pe-accent);
    --bs-link-hover-color: var(--pe-accent-dark);
}

body {
    background: var(--pe-bg);
    color: var(--pe-ink);
    font-size: 0.95rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--pe-font-display);
    letter-spacing: -0.01em;
    color: var(--pe-ink);
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    background: #12181B;
    color: #fff;
    min-height: 100vh;
}

.dashboard-topbar {
    background: #12181B;
    color: #fff;
}

.dashboard-topbar-brand {
    font-family: var(--pe-font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.dashboard-topbar .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.dashboard-topbar .nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 150ms ease, opacity 150ms ease;
}

.dashboard-topbar .nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.dashboard-topbar .nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.dashboard-topbar .nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile: the sidebar is a huge stacked nav block by default (Bootstrap
   collapses col-md-2 to 100% width above col-md-10), which used to push
   every page's real content below a full-viewport-height nav dump on every
   navigation. Collapse it behind the topbar toggle instead, same pattern as
   the public site's mobile nav. */
@media (max-width: 767.98px) {
    .sidebar {
        display: none;
        min-height: auto;
        position: absolute;
        top: 48px;
        left: 0;
        right: 0;
        z-index: 30;
        max-height: calc(100vh - 48px);
        overflow-y: auto;
    }

    .sidebar.is-open {
        display: block;
    }

    .app-shell {
        position: relative;
    }
}

.sidebar h5 {
    font-family: var(--pe-font-display);
    letter-spacing: -0.01em;
}

.sidebar a {
    color: #a9b0ac;
    display: block;
    margin: 0.15rem 0.65rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--bs-border-radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 120ms ease, color 120ms ease;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar a.active {
    background: var(--pe-accent);
    color: #fff;
    font-weight: 600;
}

.nav-section {
    color: #6c766f;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding: 1rem 1rem 0.35rem;
    text-transform: uppercase;
}

/* Cards */
.metric-card {
    border: 0;
    border-radius: var(--bs-border-radius);
    box-shadow: 0 1px 2px rgba(21, 24, 28, 0.04), 0 4px 14px rgba(21, 24, 28, 0.06);
}

.metric-card .card-header {
    background: var(--pe-card);
    border-bottom-color: var(--pe-line);
    font-weight: 600;
    padding: 0.9rem 1.15rem;
}

/* Card headers and status rows commonly pair a title with a status badge
   via d-flex justify-content-between with no wrap allowed -- when the two
   don't both fit (a longer title, a longer badge, a narrower card), the
   badge overflows past the card's edge instead of dropping to its own
   line. Let it wrap instead. */
.card-header.d-flex,
.metric-card .d-flex.justify-content-between {
    flex-wrap: wrap;
    row-gap: 0.35rem;
}

.metric-card .card-body {
    padding: 1.15rem;
}

.product-card {
    border-left: 4px solid var(--pe-accent);
}

.product-card h4 {
    font-size: 1.25rem;
}

/* Buttons -- Bootstrap picks up --bs-primary automatically for solid
   .btn-primary; outline variants need their own tint since Bootstrap
   derives those from --bs-primary too but the border/hover math benefits
   from being explicit here. */
.btn {
    border-radius: var(--bs-border-radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
}

.btn-primary {
    --bs-btn-bg: var(--pe-accent);
    --bs-btn-border-color: var(--pe-accent);
    --bs-btn-hover-bg: var(--pe-accent-dark);
    --bs-btn-hover-border-color: var(--pe-accent-dark);
    --bs-btn-active-bg: var(--pe-accent-dark);
    --bs-btn-active-border-color: var(--pe-accent-dark);
    --bs-btn-disabled-bg: var(--pe-accent);
    --bs-btn-disabled-border-color: var(--pe-accent);
}

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

/* Form controls */
.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--pe-ink-muted);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-color: var(--pe-line-strong);
    border-radius: var(--bs-border-radius-sm);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    color: var(--pe-ink);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--pe-accent);
    box-shadow: 0 0 0 0.2rem var(--bs-focus-ring-color);
}

.form-control::placeholder {
    color: #9aa19c;
}

.form-control-sm,
.form-select-sm {
    border-radius: 6px;
    font-size: 0.85rem;
}

.form-check-input {
    border-color: var(--pe-line-strong);
}

.form-check-input:checked {
    background-color: var(--pe-accent);
    border-color: var(--pe-accent);
}

.form-check-input:focus {
    border-color: var(--pe-accent);
    box-shadow: 0 0 0 0.2rem var(--bs-focus-ring-color);
}

.form-text {
    font-size: 0.8rem;
    color: var(--pe-ink-muted);
}

/* Vertical tab nav used to split long admin pages (Settings, Admin
   Dashboard, Learning Insights) into sections instead of one long scroll. */
.settings-tab-nav,
.admin-tab-nav {
    flex: 0 0 220px;
    min-width: 200px;
    position: sticky;
    top: 1rem;
}

.settings-tab-nav .nav-link,
.admin-tab-nav .nav-link {
    text-align: left;
    color: var(--pe-ink-muted);
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: normal;
    transition: background-color 120ms ease, color 120ms ease;
}

.settings-tab-nav .nav-link:hover,
.admin-tab-nav .nav-link:hover {
    background: var(--pe-accent-soft);
    color: var(--pe-accent-dark);
}

.settings-tab-nav .nav-link.active,
.admin-tab-nav .nav-link.active {
    background: var(--pe-accent);
    color: #fff;
    font-weight: 600;
}

@media (max-width: 767.98px) {
    .settings-tab-nav,
    .admin-tab-nav {
        flex: 1 1 100%;
        flex-direction: row !important;
        flex-wrap: wrap;
        position: static;
        gap: 0.4rem;
    }
}

/* Badges -- keep the semantic Bootstrap colors (success/warning/danger) for
   status meaning, just tone down the weight/size to match the rest of the
   theme instead of stock Bootstrap's heavier default. */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    padding: 0.4em 0.65em;
}

.badge.text-bg-success {
    background-color: var(--pe-accent) !important;
}

/* Tables */
.table-wrap {
    max-height: 560px;
    overflow: auto;
}

/* Safety net: a form-select/form-control sitting in a table cell will
   otherwise shrink to whatever sliver of width the browser's table layout
   algorithm leaves it -- unlike a plain input in a normal form, which just
   gets narrower and stays legible, a shrunk dropdown/input inside a table
   truncates its own text into something unreadable. Give these a floor and
   let the table scroll horizontally instead of crushing them. */
.table td .form-control,
.table td .form-select {
    min-width: 130px;
}

.table td .form-control-sm,
.table td .form-select-sm {
    min-width: 110px;
}

.table {
    font-size: 0.88rem;
}

.table thead th {
    background: #FAFAF9;
    color: var(--pe-ink-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
    border-bottom-color: var(--pe-line-strong);
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--pe-accent-soft);
}

.small-label {
    color: var(--pe-ink-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.ocr-preview {
    background: #0f172a;
    border-radius: var(--bs-border-radius);
    color: #dbeafe;
    font-size: 0.85rem;
    max-height: 360px;
    overflow: auto;
    padding: 1rem;
    white-space: pre-wrap;
}

/* Alerts -- soften the default Bootstrap alert fills to match the muted,
   warm palette instead of stock saturated red/green/yellow. */
.alert {
    border: 1px solid transparent;
    border-radius: var(--bs-border-radius-sm);
    font-size: 0.88rem;
}

.alert-success {
    background-color: var(--pe-accent-soft);
    border-color: rgba(11, 110, 79, 0.2);
    color: var(--pe-accent-dark);
}
