/* ═══════════════════════════════════════════════
   Skurbogen Admin – Stylesheet
   ═══════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --brand:       #7c3aed;
    --brand-dark:  #6d28d9;
    --brand-light: #ede9fe;
    --header-bg:   #1e1b4b;
    --header-dark: #312e81;
    --sidebar-bg:  #1e1b4b;
    --sidebar-hover: #312e81;
    --sidebar-active: #4338ca;
    --text:        #1f2937;
    --text-muted:  #6b7280;
    --border:      #e5e7eb;
    --bg:          #f3f4f6;
    --white:       #ffffff;
    --success:     #059669;
    --danger:      #dc2626;
    --warning:     #d97706;
    --info:        #2563eb;
    --radius:      .5rem;
    --shadow:      0 1px 3px rgba(0,0,0,.1);
    --shadow-lg:   0 4px 12px rgba(0,0,0,.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shell ── */
.shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ── */
.header {
    background: var(--header-bg);
    color: #fff;
    height: 56px;
    flex-shrink: 0;
    z-index: 100;
}
.header__inner {
    max-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
}
.header__brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.logo {
    text-decoration: none !important;
    color: #fff !important;
}
.logo__text {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: .02em;
}
.logo__text strong {
    color: #c4b5fd;
    font-weight: 700;
}
.header__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.header__user {
    font-size: .875rem;
    color: rgba(255,255,255,.85);
}
.header__logout {
    display: flex;
    align-items: center;
    color: rgba(255,255,255,.7);
    transition: color .15s;
}
.header__logout:hover { color: #fff; text-decoration: none; }
.header__logout svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Burger ── */
.burger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.burger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: .2s;
}

/* ── Layout ── */
.layout {
    display: flex;
    flex: 1;
}

/* ── Sidebar ── */
.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    padding: 1rem 0;
    min-height: calc(100vh - 56px - 40px);
}
.admin-nav__list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.admin-nav__item { margin-bottom: 2px; }
.admin-nav__link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    color: rgba(255,255,255,.75);
    text-decoration: none !important;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.admin-nav__link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}
.admin-nav__link.is-active {
    background: var(--sidebar-active);
    color: #fff;
    border-left-color: #c4b5fd;
}
.admin-nav__link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* ── Main ── */
.main {
    flex: 1;
    padding: 1.5rem 2rem;
    min-width: 0;
}
.main--full {
    max-width: 480px;
    margin: 0 auto;
    padding-top: 4rem;
}

/* ── Footer ── */
.footer {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: .75rem;
    color: var(--text-muted);
    background: var(--white);
    border-top: 1px solid var(--border);
}
.footer__env {
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .65rem;
}

/* ── Page title bar ── */
.page-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-title-bar h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.page-title-bar h1 i {
    color: var(--brand);
    margin-right: .5rem;
}
.page-title-bar .subtitle {
    color: var(--text-muted);
    font-size: .85rem;
    margin: .15rem 0 0;
}

/* ── Cards ── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card__header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.card__body { padding: 1.25rem; }

/* ── Stat grid ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    border-radius: var(--radius);
    padding: 1.25rem;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    box-shadow: var(--shadow);
}
.stat-card__label {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .85;
}
.stat-card__value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}
.stat-card--purple  { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.stat-card--green   { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-card--blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card--orange  { background: linear-gradient(135deg, #fb923c, #f97316); }
.stat-card--red     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card--indigo  { background: linear-gradient(135deg, #818cf8, #4f46e5); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none !important;
    transition: background .15s, opacity .15s;
    line-height: 1.4;
}
.btn--primary {
    background: var(--brand);
    color: #fff;
}
.btn--primary:hover { background: var(--brand-dark); }
.btn--secondary {
    background: var(--border);
    color: var(--text);
}
.btn--secondary:hover { background: #d1d5db; }
.btn--danger {
    background: var(--danger);
    color: #fff;
}
.btn--danger:hover { background: #b91c1c; }
.btn--ghost {
    background: transparent;
    color: var(--text);
}
.btn--ghost:hover { background: rgba(0,0,0,.05); }
.btn--sm {
    padding: .3rem .65rem;
    font-size: .8rem;
}
.btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
table.admin-table th,
table.admin-table td {
    padding: .65rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.admin-table th {
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    background: #f9fafb;
}
table.admin-table tbody tr:hover {
    background: #f9fafb;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 999px;
    line-height: 1.5;
}
.badge--pro     { background: #dbeafe; color: #1e40af; }
.badge--pro-plus{ background: #ede9fe; color: #6d28d9; }
.badge--basic-plus { background: #dbeafe; color: #1d4ed8; }
.badge--free    { background: #f3f4f6; color: #6b7280; }
.badge--admin   { background: #ede9fe; color: #5b21b6; }
.badge--active  { background: #d1fae5; color: #065f46; }
.badge--inactive { background: #fee2e2; color: #dc2626; }

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: .8125rem;
    margin-bottom: .3rem;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: .5rem .75rem;
    font-size: .875rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    transition: border-color .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .15);
}
select.form-control { appearance: auto; }

/* Sticky save bar (opt-in forms) */
body.has-sticky-save-bar .main {
    padding-bottom: 5.5rem;
}
.sticky-save-bar {
    position: fixed;
    left: calc(var(--sidebar-w, 230px) + 1rem);
    right: 1rem;
    bottom: .9rem;
    z-index: 140;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    padding: .7rem .8rem;
    border-radius: .65rem;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.96);
    box-shadow: var(--shadow-lg);
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}
.sticky-save-bar.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.sticky-save-bar__text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-width: 0;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}
.sticky-save-bar__text i {
    font-size: .5rem;
    color: #f59e0b;
}
.sticky-save-bar__actions {
    display: inline-flex;
    justify-content: center;
    gap: .45rem;
    flex-wrap: wrap;
}

/* ── Flash ── */
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .875rem;
    font-weight: 500;
}
.flash--success { background: #d1fae5; color: #065f46; }
.flash--error   { background: #fee2e2; color: #dc2626; }
.flash--warning { background: #fef3c7; color: #92400e; }
.flash--info    { background: #dbeafe; color: #1e40af; }

/* ── Toast stack ── */
.toast-stack {
    position: fixed;
    top: 68px;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 400px;
}
.toast {
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn .3s ease;
    cursor: pointer;
}
.toast--success { background: #065f46; color: #fff; }
.toast--error   { background: #dc2626; color: #fff; }
.toast--warning { background: #92400e; color: #fff; }
.toast--info    { background: #2563eb; color: #fff; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Login page ── */
.login-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    margin: 0 auto;
}
.login-box h2 {
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
    text-align: center;
    color: var(--text);
}
.login-box .btn--primary {
    width: 100%;
    justify-content: center;
    padding: .65rem;
    font-size: .9375rem;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}
.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 95vw;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform .2s;
}
.modal-overlay.is-open .modal {
    transform: translateY(0);
}
.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1rem;
}
.modal__close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
}
.modal__body { padding: 1.25rem; }
.modal__footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}

/* ── Icon Buttons (inline actions) ── */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    font-size: .85rem;
    transition: background .15s, color .15s;
}
.btn-icon:hover {
    background: var(--border);
    color: var(--text);
}
.btn-icon--danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .burger { display: flex; }
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 250px;
        z-index: 90;
        transform: translateX(-100%);
        transition: transform .25s;
    }
    .sidebar.is-open { transform: translateX(0); }
    .main { padding: 1rem; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .sticky-save-bar {
        left: .75rem;
        right: .75rem;
        bottom: .75rem;
        flex-direction: column;
        align-items: stretch;
    }
    .sticky-save-bar__actions {
        width: 100%;
    }
    .sticky-save-bar__actions .btn {
        flex: 1;
        justify-content: center;
    }
}
