/* Ministra PRO-inspired admin theme.
   Light sidebar + gradient topbar + light content area. */

:root {
    /* Sidebar (light) */
    --sidebar-bg: #ffffff;
    --sidebar-bg-hover: #f4f5f7;
    --sidebar-bg-active: #f0edfa;
    --sidebar-text: #4b5261;
    --sidebar-text-muted: #98a0b0;
    --sidebar-text-active: #3e2d91;
    --sidebar-border: #e5e7eb;

    /* Topbar (gradient) */
    --topbar-grad-from: #4b3899;
    --topbar-grad-to:   #2f4bb6;
    --topbar-text: #ffffff;
    --topbar-text-muted: rgba(255, 255, 255, 0.75);
    --topbar-height: 56px;

    /* Brand + accents */
    --brand: #3e2d91;               /* Ministra deep purple */
    --brand-hover: #4a37a8;
    --brand-soft: rgba(62, 45, 145, 0.08);
    --accent: #3e2d91;              /* primary action = deep purple */
    --accent-hover: #4a37a8;
    --accent-soft: rgba(62, 45, 145, 0.12);

    /* Content (light) */
    --bg: #f4f5f7;
    --panel: #ffffff;
    --panel-alt: #f9fafb;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #1f2937;
    --text-muted: #6b7280;
    --text-subtle: #9ca3af;
    --link: #3e2d91;
    --link-hover: #4a37a8;

    /* Snippet / code block (dark) */
    --code-bg: #1e1f36;
    --code-text: #e5e7eb;

    /* Status */
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #fef3c7;

    --radius: 4px;
    --radius-lg: 6px;
    --gap: 1rem;
    --sidebar-width: 220px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

code, pre {
    font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
}

code {
    background: #eef0f3;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    color: #b13a00;
    font-size: 0.85em;
}

pre code { background: none; padding: 0; color: inherit; }

/* -------- App shell -------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* -------- Sidebar (light) -------- */

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.25rem;
    color: var(--brand);
    text-decoration: none;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: var(--topbar-height);
    font-weight: 700;
}

.sidebar__brand:hover { text-decoration: none; color: var(--brand-hover); }

.sidebar__brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    background: linear-gradient(135deg, var(--topbar-grad-from), var(--topbar-grad-to));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0;
    flex-shrink: 0;
}

.sidebar__brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.sidebar__brand-name { font-size: 0.95rem; letter-spacing: 0.02em; }
.sidebar__brand-tag {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.sidebar__nav {
    list-style: none;
    margin: 0;
    padding: 0.75rem 0.5rem;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.85rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar__link:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.sidebar__link.is-active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.sidebar__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.75;
}

.sidebar__link.is-active .sidebar__icon { opacity: 1; }

.sidebar__footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    font-size: 0.7rem;
    color: var(--text-subtle);
}

/* -------- Main column -------- */

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

/* -------- Topbar (gradient) -------- */

.topbar {
    background: linear-gradient(90deg, var(--topbar-grad-from) 0%, var(--topbar-grad-to) 100%);
    color: var(--topbar-text);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.topbar__breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--topbar-text-muted);
    font-size: 0.875rem;
    flex: 1 1 auto;
    min-width: 0;
}

.topbar__breadcrumbs > .crumb--current {
    color: var(--topbar-text);
    font-weight: 600;
}

.crumb-sep {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* -------- Health indicator (in topbar, adapted to gradient bg) -------- */

.health {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1;
    backdrop-filter: blur(4px);
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    display: inline-block;
    transition: background 0.2s ease;
}

.health.is-ok      .health-dot { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.health.is-fail    .health-dot { background: #fb7185; box-shadow: 0 0 6px #fb7185; }
.health.is-checking .health-dot { background: #fbbf24; animation: pulse 1s ease infinite; }

.health.is-ok      .health-label::before { content: "Healthy"; }
.health.is-fail    .health-label::before { content: "Down"; }
.health.is-checking .health-label::before { content: "Checking…"; }

.health-refresh {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    cursor: pointer;
    padding: 0 0.15rem;
    font-size: 0.95rem;
    line-height: 1;
    border-radius: 3px;
}
.health-refresh:hover { color: #fff; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* -------- Content -------- */

.content {
    padding: 1.5rem 1.75rem 3rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.content__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.content__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text);
}

.content__subtitle {
    margin: 0.15rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* -------- Card (surface container) -------- */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card__header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--panel-alt);
}

.card__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card__body { padding: 1.5rem; }
.card__body--flush { padding: 0; }

.card__desc {
    color: var(--text-muted);
    margin: 0 0 1rem;
    font-size: 0.875rem;
}

/* -------- Section-style form block (Ministra "BASIC/DVR/EPG" pattern) -------- */

.form-section {
    padding: 1.5rem 1.75rem;
}

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

.form-section__title {
    margin: 0 0 1rem;
    padding-bottom: 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

/* Collapsible variant: <details><summary class="form-section__title"> */
details.form-section summary.form-section__title {
    cursor: pointer;
    list-style: none;
}
details.form-section summary.form-section__title::-webkit-details-marker { display: none; }
details.form-section summary.form-section__title::after {
    content: "";
    width: 7px; height: 7px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    margin-left: 0.5rem;
}
details.form-section[open] summary.form-section__title::after {
    transform: rotate(45deg);
}

/* -------- Horizontal form fields (label left / input right) -------- */

.form-rows {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.form-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    gap: 1rem;
}

.form-row__label {
    text-align: right;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
}

.form-row__label--required::after {
    content: " *";
    color: var(--danger);
}

.form-row__control {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.form-row__hint {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.form-row__error {
    color: var(--danger);
    font-size: 0.72rem;
    min-height: 0;
}

.form-row--error .form-row__control input,
.form-row--error .form-row__control select,
.form-row--error .form-row__control textarea {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* Inputs (shared) */
.form-row__control input,
.form-row__control select,
.form-row__control textarea {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0.45rem 0.7rem;
    font: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    max-width: 480px;
}

.form-row__control input:hover,
.form-row__control select:hover,
.form-row__control textarea:hover { border-color: var(--text-subtle); }

.form-row__control input:focus,
.form-row__control select:focus,
.form-row__control textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row__control textarea {
    font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    resize: vertical;
    max-width: none;
}

/* -------- Buttons (Ministra deep-purple style) -------- */

.btn {
    background: var(--brand);
    color: #ffffff;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.2;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--brand-hover); text-decoration: none; color: #ffffff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--secondary {
    background: var(--panel);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--panel-alt); border-color: var(--text-subtle); color: var(--text); }

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}
.btn--ghost:hover { background: var(--panel-alt); color: var(--text); }

.btn--danger {
    background: var(--danger);
    color: #fff;
}
.btn--danger:hover { background: #b91c1c; color: #fff; }

/* -------- Tables -------- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th,
.table td {
    padding: 0.6rem 0.85rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--panel-alt);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-strong);
}

.table tbody tr:hover { background: var(--panel-alt); }
.table tbody tr:last-child td { border-bottom: none; }

/* -------- Badges -------- */

.badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 3px;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    line-height: 1.3;
}
.badge--current    { background: var(--success-soft); color: var(--success); }
.badge--deprecated { background: var(--danger-soft);  color: var(--danger); }
.badge--info       { background: var(--brand-soft);   color: var(--brand); }

/* -------- Snippet block (contrast) -------- */

.snippet {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05),
                0 1px 2px rgba(0, 0, 0, 0.08);
    position: relative;
}

.snippet + .snippet { margin-top: 0.4rem; }

.snippet code { background: none; padding: 0; color: inherit; font-size: inherit; }

.snippet__label {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* -------- Responsive -------- */

@media (max-width: 900px) {
    .app { grid-template-columns: 60px 1fr; }
    .sidebar__brand-text,
    .sidebar__link span:not(.sidebar__icon),
    .sidebar__footer { display: none; }
    .sidebar__brand { justify-content: center; padding: 0; }
    .sidebar__link  { justify-content: center; padding: 0.75rem 0; }
}

@media (max-width: 640px) {
    .content       { padding: 1rem; }
    .topbar        { padding: 0 1rem; }
    .form-section  { padding: 1rem; }
    .form-row      { grid-template-columns: 1fr; gap: 0.35rem; }
    .form-row__label { text-align: left; }
    .health .health-label { display: none; }
}
