/* ============================================================
 *  JAGALAYAR - Layout CSS
 *  File: assets/css/layout.css
 *  Version: V1.0
 *  Last Update: 2026-04-21
 * ------------------------------------------------------------
 *  FEATURES:
 *   - Layout grid (sidebar + main)
 *   - Card, alert, badge, switch components
 *   - Form controls
 *   - Table
 * ============================================================ */

/* ── Layout Wrapper ────────────────────────────────────────── */
.layout {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    min-height: calc(100vh - 64px);
}
body.has-sidebar .layout {
    grid-template-columns: 240px 1fr;
}

.main-content {
    padding: 2rem 1.5rem;
    min-width: 0; /* prevent grid overflow */
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-1);
    border-right: 1px solid var(--glass-br);
    padding: 1.5rem 0.8rem;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sidebar__header { padding: 0 0.8rem 1rem; border-bottom: 1px solid var(--glass-br); margin-bottom: 1rem; }
.sidebar__badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: linear-gradient(90deg, var(--neon), var(--neon-2));
    color: #000;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
}
.sidebar__plan small {
    display: block;
    font-size: 0.7rem;
    color: var(--txt-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.sidebar__plan strong { display: block; font-size: 1rem; margin-top: 0.2rem; }
.sidebar__quota { margin-top: 0.6rem; font-size: 0.75rem; color: var(--txt-dim); }
.sidebar__quota-bar {
    height: 4px;
    background: var(--bg-2);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.3rem;
}
.sidebar__quota-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon), var(--neon-2));
    transition: width 0.4s;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.sidebar__item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--txt-dim);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}
.sidebar__item:hover {
    background: var(--glass);
    color: var(--txt);
}
.sidebar__item.is-active {
    background: color-mix(in srgb, var(--neon) 12%, transparent);
    color: var(--neon);
    font-weight: 600;
}
.sidebar__item.is-active::before {
    content: '';
    position: absolute;
    left: -0.8rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--neon);
    border-radius: 0 2px 2px 0;
}
.sidebar__item.is-locked { opacity: 0.5; pointer-events: none; }
.sidebar__lock { margin-left: auto; }
.sidebar__icon { width: 20px; text-align: center; }
.sidebar__footer { padding-top: 1rem; border-top: 1px solid var(--glass-br); margin-top: 1rem; }

/* ── Container ─────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 1rem; }

/* ── Card ──────────────────────────────────────────────────── */
.card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-br);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-br);
}
.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex; align-items: center; gap: 0.5rem;
}
.card-title::before {
    content: '';
    display: inline-block;
    width: 3px; height: 18px;
    background: linear-gradient(180deg, var(--neon), var(--neon-2));
    border-radius: 2px;
}

/* ── Stats grid ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-box {
    background: var(--glass);
    border: 1px solid var(--glass-br);
    border-radius: var(--radius);
    padding: 1.2rem;
    position: relative;
    overflow: hidden;
}
.stat-box::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 60px;
    background: radial-gradient(circle, var(--neon) 0%, transparent 70%);
    opacity: 0.15;
}
.stat-box__label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--txt-faint); }
.stat-box__value { font-size: 1.8rem; font-weight: 800; margin-top: 0.3rem; }
.stat-box__delta { font-size: 0.8rem; margin-top: 0.2rem; }
.stat-box__delta.up { color: var(--success); }
.stat-box__delta.down { color: var(--danger); }

/* ── Alert ─────────────────────────────────────────────────── */
.alert {
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 3px solid;
    font-size: 0.9rem;
}
.alert-success { background: color-mix(in srgb, var(--success) 12%, transparent); border-color: var(--success); }
.alert-warn    { background: color-mix(in srgb, var(--warn) 12%, transparent);    border-color: var(--warn); }
.alert-danger  { background: color-mix(in srgb, var(--danger) 12%, transparent);  border-color: var(--danger); }
.alert-info    { background: color-mix(in srgb, var(--info) 12%, transparent);    border-color: var(--info); }

/* ── Badge ─────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-safe    { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.badge-block   { background: color-mix(in srgb, var(--danger) 20%, transparent);  color: var(--danger); }
.badge-pending { background: color-mix(in srgb, var(--warn) 20%, transparent);    color: var(--warn); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.8rem;
    color: var(--txt-dim);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    background: color-mix(in srgb, var(--bg-0) 60%, transparent);
    border: 1px solid var(--glass-br);
    border-radius: var(--radius-sm);
    color: var(--txt);
    font-size: 0.9rem;
    transition: border 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--neon);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--neon) 15%, transparent);
}

/* ── Toggle Switch ─────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
    position: absolute; inset: 0;
    background: var(--bg-2);
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
}
.switch__slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}
.switch input:checked + .switch__slider { background: var(--neon); }
.switch input:checked + .switch__slider::before { transform: translateX(20px); }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--glass-br); }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th, .table td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-br);
}
.table th {
    background: var(--bg-1);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--txt-faint);
}
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: var(--glass); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
    body.has-sidebar .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: -100%;
        top: 64px;
        width: 240px;
        z-index: 150;
        transition: left 0.3s;
    }
    .sidebar.is-open { left: 0; }
}
