/* ---------------------------------------------------------------------------
   Lumiks admin backend.
   ------------------------------------------------------------------------- */

:root {
    --bg:          #0b1120;
    --bg-2:        #111a2e;
    --panel:       #16203a;
    --panel-2:     #1c2947;
    --border:      rgba(148, 163, 184, 0.18);
    --text:        #e2e8f0;
    --muted:       #94a3b8;
    --heading:     #ffffff;
    --primary:     #3b82f6;
    --primary-600: #2563eb;
    --success:     #22c55e;
    --danger:      #ef4444;
    --warning:     #f59e0b;
    --radius:      12px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--primary); }

/* --- Sign-in / password screens ------------------------------------------ */
.lk-auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at top, #16203a 0%, #0b1120 55%, #05080f 100%);
}

.lk-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 40px 34px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}

.lk-auth-brand {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--heading);
    text-align: center;
    margin: 0 0 6px;
}

.lk-auth-sub { text-align: center; color: var(--muted); margin: 0 0 28px; font-size: 0.94rem; }

/* --- Layout --------------------------------------------------------------- */
.lk-admin-body { display: flex; min-height: 100vh; }

.lk-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.lk-sidebar__brand {
    display: block;
    padding: 24px 22px;
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.28rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--heading);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
.lk-sidebar__brand span {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 3px;
}

.lk-sidebar__nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.lk-sidebar__nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin-bottom: 3px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.94rem;
    transition: background 0.18s ease, color 0.18s ease;
}
.lk-sidebar__nav a:hover { background: rgba(59, 130, 246, 0.12); color: var(--text); }
.lk-sidebar__nav a.is-active { background: rgba(59, 130, 246, 0.22); color: #fff; }

.lk-sidebar__icon { width: 18px; text-align: center; opacity: 0.85; }

.lk-sidebar__foot { padding: 16px 12px 22px; border-top: 1px solid var(--border); }
.lk-sidebar__secondary {
    display: block;
    padding: 8px 14px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.88rem;
    border-radius: 8px;
}
.lk-sidebar__secondary:hover { color: var(--text); background: rgba(148, 163, 184, 0.1); }

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

.lk-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 28px;
    background: rgba(11, 17, 32, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.lk-topbar h1 { margin: 0; font-size: 1.25rem; color: var(--heading); font-weight: 600; flex: 1; }

.lk-topbar__user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lk-topbar__name { font-size: 0.88rem; color: var(--text); text-align: right; line-height: 1.25; }
.lk-topbar__name small {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.lk-sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
}

.lk-inline-form { display: inline; margin: 0; }

.lk-content { padding: 28px; flex: 1; }

/* --- Cards / panels ------------------------------------------------------- */
.lk-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
}

.lk-panel__title {
    margin: 0 0 16px;
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--heading);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.lk-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.lk-stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.lk-stat--success { border-left-color: var(--success); }
.lk-stat--warning { border-left-color: var(--warning); }

.lk-stat__label {
    margin: 0 0 6px;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    font-weight: 600;
}
.lk-stat__value { margin: 0; font-size: 2rem; font-weight: 700; color: var(--heading); line-height: 1.1; }
.lk-stat__note { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }

.lk-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 22px; }

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

/*
 * Grid and flex children default to `min-width: auto`, so the 640px min-width
 * of a table below propagates up and stretches its panel past the viewport —
 * even though the table has its own horizontal scroll. Letting these shrink
 * keeps the scrolling inside the wrapper where it belongs.
 */
.lk-grid-2 > *,
.lk-panel,
.lk-table-wrap { min-width: 0; }

.lk-table-wrap { overflow-x: auto; border-radius: var(--radius); max-width: 100%; }

.lk-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }

.lk-table th, .lk-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.lk-table th {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
    background: var(--panel-2);
    white-space: nowrap;
}

.lk-table tbody tr:hover { background: rgba(59, 130, 246, 0.06); }
.lk-table tbody tr:last-child td { border-bottom: none; }

.lk-code {
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #bfdbfe;
}

.lk-empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* --- Badges ---------------------------------------------------------------- */
.lk-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.lk-badge--ok      { background: rgba(34, 197, 94, 0.17);  color: #86efac; }
.lk-badge--muted   { background: rgba(148, 163, 184, 0.16); color: var(--muted); }
.lk-badge--danger  { background: rgba(239, 68, 68, 0.17);  color: #fca5a5; }
.lk-badge--info    { background: rgba(59, 130, 246, 0.18); color: #bfdbfe; }
.lk-badge--warning { background: rgba(245, 158, 11, 0.17); color: #fcd34d; }

/* --- Forms ----------------------------------------------------------------- */
.lk-field { margin-bottom: 16px; }

.lk-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text);
}

.lk-field small { display: block; margin-top: 5px; color: var(--muted); font-size: 0.78rem; }

.lk-input, .lk-select, .lk-textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.94rem;
}

.lk-input:focus, .lk-select:focus, .lk-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.lk-input:disabled, .lk-input[readonly] { opacity: 0.65; cursor: not-allowed; }

.lk-textarea { resize: vertical; min-height: 92px; line-height: 1.55; }

/* Password fields get a reveal toggle sitting inside the field. */
.lk-pw-wrap { position: relative; display: block; }

.lk-pw-wrap .lk-input,
.lk-pw-wrap input[type="password"],
.lk-pw-wrap input[type="text"] { padding-right: 46px; }

.lk-pw-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease;
}

.lk-pw-toggle:hover        { color: var(--text); background: rgba(148, 163, 184, 0.14); }
.lk-pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.lk-pw-toggle[aria-pressed="true"] { color: var(--primary); }
.lk-pw-toggle svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
    /* Comfortable touch target on a phone. */
    .lk-pw-toggle { width: 40px; height: 40px; right: 4px; }
    .lk-pw-wrap .lk-input { padding-right: 50px; }
}

.lk-checkbox { display: flex; align-items: center; gap: 9px; font-size: 0.9rem; cursor: pointer; }
.lk-checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

.lk-field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.lk-form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* --- Buttons --------------------------------------------------------------- */
.lk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
    white-space: nowrap;
}
.lk-btn:hover  { background: var(--primary-600); }
.lk-btn:active { transform: translateY(1px); }
.lk-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.lk-btn--ghost   { background: transparent; border-color: var(--border); color: var(--text); }
.lk-btn--ghost:hover { background: rgba(148, 163, 184, 0.12); }

.lk-btn--danger  { background: var(--danger); }
.lk-btn--danger:hover { background: #dc2626; }

.lk-btn--sm { padding: 6px 12px; font-size: 0.8rem; }
.lk-btn--block { width: 100%; }

/* --- Alerts ---------------------------------------------------------------- */
.lk-alert {
    padding: 13px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 0.92rem;
    border-left: 4px solid;
}
.lk-alert--success { background: rgba(34, 197, 94, 0.12); border-color: var(--success); color: #bbf7d0; }
.lk-alert--error   { background: rgba(239, 68, 68, 0.12); border-color: var(--danger);  color: #fecaca; }
.lk-alert--info    { background: rgba(59, 130, 246, 0.12); border-color: var(--primary); color: #bfdbfe; }
.lk-alert--warning { background: rgba(245, 158, 11, 0.12); border-color: var(--warning); color: #fde68a; }

/* --- Filters / toolbar ------------------------------------------------------ */
.lk-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
}
.lk-toolbar .lk-input, .lk-toolbar .lk-select { width: auto; min-width: 180px; }
.lk-toolbar__spacer { flex: 1; }

/* --- Pagination ------------------------------------------------------------- */
.lk-pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.lk-pagination a, .lk-pagination span {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}
.lk-pagination .is-current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.lk-pagination__info { border: none; color: var(--muted); }

/* --- Bar chart -------------------------------------------------------------- */
.lk-bars { display: flex; flex-direction: column; gap: 11px; }
.lk-bar__row { display: grid; grid-template-columns: minmax(90px, 190px) 1fr auto; gap: 12px; align-items: center; font-size: 0.86rem; }
.lk-bar__label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-bar__track { background: rgba(148, 163, 184, 0.13); border-radius: 999px; height: 9px; overflow: hidden; }
.lk-bar__fill  { background: linear-gradient(90deg, var(--primary), #60a5fa); height: 100%; border-radius: 999px; }
.lk-bar__value { color: var(--text); font-weight: 600; min-width: 34px; text-align: right; }

/* --- Detail lists ----------------------------------------------------------- */
.lk-deflist { margin: 0; font-size: 0.88rem; }
.lk-deflist div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.lk-deflist div:last-child { border-bottom: none; }
.lk-deflist dt { color: var(--muted); margin: 0; }
.lk-deflist dd { margin: 0; color: var(--text); font-weight: 500; text-align: right; }

.lk-muted { color: var(--muted); }
.lk-nowrap { white-space: nowrap; }
.lk-mono { font-family: 'SF Mono', Monaco, Consolas, monospace; font-size: 0.85em; }

/* --- Responsive -------------------------------------------------------------- */
@media (max-width: 900px) {
    .lk-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }
    .lk-sidebar.is-open { transform: translateX(0); }
    .lk-sidebar-toggle { display: block; width: 44px; height: 44px; }
    .lk-content { padding: 18px 16px; }
    .lk-topbar { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
    .lk-topbar h1 { font-size: 1.05rem; }

    /* Comfortable touch targets — the small buttons sat under 36px. */
    .lk-btn--sm { padding: 10px 14px; font-size: 0.84rem; min-height: 40px; }
    .lk-topbar__name { font-size: 0.8rem; }
    .lk-topbar__user { gap: 8px; }

    .lk-panel { padding: 18px 16px; }
    .lk-panel__title { font-size: 0.98rem; }
    .lk-stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
    .lk-stat { padding: 14px 16px; }
    .lk-stat__value { font-size: 1.7rem; }
    .lk-grid-2 { grid-template-columns: 1fr; gap: 16px; }
    .lk-field-row { grid-template-columns: 1fr; }
    .lk-toolbar .lk-input, .lk-toolbar .lk-select { width: 100%; min-width: 0; }
    .lk-form-actions .lk-btn { flex: 1 1 auto; }

    /* iOS zooms the page when a focused field is under 16px. */
    .lk-input, .lk-select, .lk-textarea { font-size: 16px; padding: 12px 13px; }

    /* Tables scroll inside their wrapper; nudge that it is scrollable. */
    .lk-table-wrap { -webkit-overflow-scrolling: touch; }
    .lk-bar__row { grid-template-columns: minmax(70px, 110px) 1fr auto; font-size: 0.8rem; }

    /* The products screen puts the image beside the form on desktop. */
    .lk-panel form > div[style*="grid-template-columns"] {
        display: block !important;
    }
    .lk-panel form > div[style*="grid-template-columns"] > div:first-child {
        max-width: 220px;
        margin-bottom: 18px;
    }
}

@media (max-width: 520px) {
    .lk-content { padding: 14px 12px; }
    .lk-panel { padding: 16px 13px; }
    .lk-auth-card { padding: 32px 22px; }
    .lk-stat-grid { grid-template-columns: 1fr 1fr; }
    .lk-stat__value { font-size: 1.5rem; }
    .lk-topbar h1 { font-size: 0.98rem; width: 100%; order: 3; }
}
