/* ============================================================
   Lineage II Interlude - Fluent / Windows 11 Light Theme
   Palette: Blue #0078D4, Purple #6F42C1, Warm neutrals
   Surface: Mica + Acrylic blur
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
    --l2-blue: #0078D4;
    --l2-blue-hover: #005A9E;
    --l2-purple: #6F42C1;
    --l2-purple-hover: #5A32A3;
    --l2-red: #D13438;
    --l2-green: #107C10;
    --l2-amber: #CA8A04;

    --bg-body: #F0F2F5;
    --bg-surface: rgba(255, 255, 255, 0.78);
    --bg-surface-solid: #FFFFFF;
    --bg-elevated: rgba(255, 255, 255, 0.92);
    --bg-sidebar: rgba(255, 255, 255, 0.65);

    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-default: rgba(0, 0, 0, 0.10);
    --border-strong: rgba(0, 0, 0, 0.16);

    --text-primary: #1A1A1A;
    --text-secondary: #5C5C5C;
    --text-tertiary: #8A8A8A;
    --text-inverse: #FFFFFF;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    --font-main: 'DM Sans', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;

    --sidebar-width: 260px;
    --topbar-height: 56px;

    --transition-fast: 0.15s ease;
    --transition-default: 0.2s ease;
    --transition-slow: 0.35s ease;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-main);
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background:
        radial-gradient(900px 600px at 15% 10%, rgba(0, 120, 212, 0.06), transparent 60%),
        radial-gradient(800px 500px at 85% 80%, rgba(111, 66, 193, 0.04), transparent 60%),
        var(--bg-body);
}

a { color: var(--l2-blue); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--l2-blue-hover); }

/* ============================================================
   LAYOUT: ADMIN (sidebar + main)
   ============================================================ */
.layout-admin {
    display: flex;
    min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    transition: transform var(--transition-slow);
}

.sidebar-brand {
    padding: 20px 20px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 8px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--l2-blue), var(--l2-purple));
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.25);
}

.sidebar-brand-text {
    line-height: 1.2;
}

.sidebar-brand-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.sidebar-brand-sub {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar-section {
    padding: 4px 12px;
    margin-top: 12px;
}

.sidebar-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-tertiary);
    padding: 0 8px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    text-decoration: none;
    position: relative;
}

.sidebar-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(0, 120, 212, 0.08);
    color: var(--l2-blue);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 2px;
    background: var(--l2-blue);
}

.sidebar-link svg,
.sidebar-link i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link.active i {
    opacity: 1;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--l2-red);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* ---- MAIN CONTENT ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- TOPBAR ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    height: var(--topbar-height);
    background: var(--bg-elevated);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- PAGE WRAPPER ---- */
.page-content {
    flex: 1;
    padding: 24px 28px 40px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* ============================================================
   LAYOUT: CLIENT (topbar + sidebar + main)
   ============================================================ */
.layout-client {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.layout-client .topbar {
    height: 60px;
    padding: 0 32px;
    background: var(--bg-surface);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-bottom: 1px solid var(--border-subtle);
}

.layout-client .topbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--l2-blue);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px;
    transition: box-shadow var(--transition-default);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Prevent canvas/chart from expanding cards */
.card canvas {
    max-width: 100%;
    max-height: 220px;
}

/* Prevent inline SVGs from expanding containers */
.card svg,
.stat-card svg {
    flex-shrink: 0;
    overflow: visible;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title svg,
.card-title i {
    width: 16px;
    height: 16px;
    color: var(--l2-blue);
}

/* ============================================================
   STAT CARDS (Dashboard KPIs)
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: all var(--transition-default);
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.stat-icon svg,
.stat-icon i {
    width: 20px;
    height: 20px;
}

.stat-icon.blue { background: rgba(0, 120, 212, 0.10); color: var(--l2-blue); }
.stat-icon.green { background: rgba(16, 124, 16, 0.10); color: var(--l2-green); }
.stat-icon.red { background: rgba(209, 52, 56, 0.10); color: var(--l2-red); }
.stat-icon.purple { background: rgba(111, 66, 193, 0.10); color: var(--l2-purple); }
.stat-icon.amber { background: rgba(202, 138, 4, 0.10); color: var(--l2-amber); }

.stat-info { flex: 1; }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

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

thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-tertiary);
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: rgba(0, 120, 212, 0.02);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg, .btn i { width: 15px; height: 15px; }

.btn-primary {
    background: var(--l2-blue);
    color: white;
    border-color: var(--l2-blue);
}
.btn-primary:hover {
    background: var(--l2-blue-hover);
    color: white;
}

.btn-danger {
    background: var(--l2-red);
    color: white;
    border-color: var(--l2-red);
}
.btn-danger:hover {
    background: #B22222;
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}
.btn-outline:hover {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 10px;
}
.btn-ghost:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-online { background: rgba(16, 124, 16, 0.10); color: var(--l2-green); }
.badge-offline { background: rgba(0, 0, 0, 0.05); color: var(--text-tertiary); }
.badge-danger { background: rgba(209, 52, 56, 0.10); color: var(--l2-red); }
.badge-warning { background: rgba(202, 138, 4, 0.10); color: var(--l2-amber); }
.badge-info { background: rgba(0, 120, 212, 0.10); color: var(--l2-blue); }
.badge-purple { background: rgba(111, 66, 193, 0.10); color: var(--l2-purple); }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online { background: var(--l2-green); box-shadow: 0 0 0 2px rgba(16, 124, 16, 0.2); }
.status-dot.offline { background: var(--text-tertiary); }
.status-dot.dead { background: var(--l2-red); box-shadow: 0 0 0 2px rgba(209, 52, 56, 0.2); }

/* ============================================================
   CONSOLE (Server Logs)
   ============================================================ */
.console-output {
    background: #1B1B1F;
    color: #D4D4D8;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.55;
    padding: 20px;
    border-radius: var(--radius-md);
    overflow-y: auto;
    max-height: 65vh;
    white-space: pre-wrap;
    word-break: break-all;
}

.console-output .log-error { color: #F87171; }
.console-output .log-info { color: #60A5FA; }
.console-output .log-warn { color: #FBBF24; }

/* ============================================================
   FORMS
   ============================================================ */
.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.88rem;
    background: var(--bg-surface-solid);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--l2-blue);
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235C5C5C' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* ============================================================
   CHARACTER CARDS (Client Panel)
   ============================================================ */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.char-card {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-default);
}

.char-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.char-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.char-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--l2-blue);
}

.char-level {
    background: rgba(0, 120, 212, 0.08);
    color: var(--l2-blue);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 700;
}

.char-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.88rem;
}

.char-stat-row span:first-child { color: var(--text-secondary); }
.char-stat-row span:last-child { font-weight: 500; color: var(--text-primary); }

.char-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.char-actions .btn { flex: 1; justify-content: center; }

/* ============================================================
   ENCHANT HIGHLIGHT
   ============================================================ */
.enchant-high {
    color: var(--l2-red);
    font-weight: 700;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-2 > * { min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-3 > * { min-width: 0; }

@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   ALERT ITEMS
   ============================================================ */
.alert-item {
    padding: 12px 14px;
    border-left: 3px solid var(--l2-red);
    background: rgba(209, 52, 56, 0.04);
    margin-bottom: 8px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
}

.alert-item-type {
    font-weight: 600;
    color: var(--text-primary);
}

.alert-item-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ============================================================
   TECH FONT (monospace)
   ============================================================ */
.mono {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.3px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-280px);
    }

    .sidebar.open {
        transform: translateX(0);
        width: 280px;
        box-shadow: var(--shadow-lg);
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 16px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   SCROLLBAR (subtle)
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.22); }

/* ============================================================
   UTILITY
   ============================================================ */
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
