/* ============================================================
   Kingdom of Stormwind - Ministry of Justice
   Modern Blue Theme + Light / Dark Mode
   Green is forbidden.
   ============================================================ */

:root {
    /* Light mode (default) */
    --bg-body:          #f0f4f8;
    --bg-card:          #ffffff;
    --bg-header:        #0b1e3d;
    --bg-sidebar:       #12294d;
    --bg-input:         #ffffff;
    --bg-table-header:  #e8eef6;
    --bg-hover:         #e2eaf4;

    --text-primary:     #0f172a;
    --text-secondary:   #475569;
    --text-muted:       #64748b;
    --text-on-dark:     #e2e8f0;
    --text-link:        #1d4ed8;

    --border:           #cbd5e1;
    --border-strong:    #94a3b8;

    --accent:           #1e40af;       /* Deep Stormwind blue */
    --accent-hover:     #1e3a8a;
    --accent-light:     #3b82f6;
    --accent-soft:      #dbeafe;

    --success:          #1d4ed8;       /* Still blue family */
    --danger:           #b91c1c;
    --warning:          #b45309;

    --shadow:           0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md:        0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.08);
    --radius:           8px;
    --radius-sm:        6px;
    --font:             'Segoe UI', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg-body:          #0b1220;
    --bg-card:          #111b2e;
    --bg-header:        #060e1c;
    --bg-sidebar:       #0a1628;
    --bg-input:         #0f1a2e;
    --bg-table-header:  #152238;
    --bg-hover:         #1a2740;

    --text-primary:     #e2e8f0;
    --text-secondary:   #94a3b8;
    --text-muted:       #64748b;
    --text-on-dark:     #e2e8f0;
    --text-link:        #60a5fa;

    --border:           #1e293b;
    --border-strong:    #334155;

    --accent:           #3b82f6;
    --accent-hover:     #60a5fa;
    --accent-light:     #93c5fd;
    --accent-soft:      #1e3a5f;

    --success:          #3b82f6;
    --danger:           #f87171;
    --warning:          #fbbf24;

    --shadow:           0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md:        0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    transition: background 0.2s ease, color 0.2s ease;
}

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

img { max-width: 100%; height: auto; }

/* Layout */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ========== HEADER ========== */
.site-header {
    background: var(--bg-header);
    color: var(--text-on-dark);
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

.header-brand .logo-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e3a8a;
    border: 2px solid #60a5fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.header-nav a {
    color: var(--text-on-dark);
    opacity: 0.85;
    font-size: 0.92rem;
}
.header-nav a:hover { opacity: 1; text-decoration: none; }

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: var(--text-on-dark);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.15s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.1); }

/* ========== MAIN LAYOUT WITH SIDEBAR ========== */
.main-layout {
    display: flex;
    flex: 1;
}

/* Sidebar (management only) */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    padding: 1.5rem 0;
    flex-shrink: 0;
    min-height: calc(100vh - 60px);
}

.sidebar-user {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.sidebar-user .username {
    font-weight: 600;
    font-size: 1rem;
}
.sidebar-user .ic-name {
    font-size: 0.85rem;
    opacity: 0.75;
    margin-top: 0.15rem;
}
.sidebar-user .role-badge {
    display: inline-block;
    margin-top: 0.4rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--accent);
    border-radius: 4px;
}

/* Sidebar IC character switcher – high contrast */
.sidebar-char-select {
    width: 100%;
    margin-top: 0.15rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
    font-family: inherit;
    background-color: #0a1628;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 4px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%94a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 1.6rem;
}
.sidebar-char-select:hover,
.sidebar-char-select:focus {
    border-color: #60a5fa;
    outline: none;
}
.sidebar-char-select option {
    background-color: #0f1a2e;
    color: #e2e8f0;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav a {
    display: block;
    padding: 0.65rem 1.25rem;
    color: var(--text-on-dark);
    opacity: 0.8;
    font-size: 0.92rem;
    transition: all 0.15s;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
    opacity: 1;
    background: rgba(255,255,255,0.07);
    text-decoration: none;
    border-left: 3px solid var(--accent-light);
    padding-left: calc(1.25rem - 3px);
}

.sidebar-section-title {
    padding: 1rem 1.25rem 0.4rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.5;
}

/* Content area */
.content {
    flex: 1;
    padding: 1.75rem 2rem;
    max-width: 1400px;
}

/* ========== CARDS & TABLES ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

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

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

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

table.data-table th {
    background: var(--bg-table-header);
    text-align: left;
    padding: 0.7rem 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tr:hover td {
    background: var(--bg-hover);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-active   { background: var(--accent-soft); color: var(--accent); }
.badge-inactive { background: #fee2e2; color: #b91c1c; }
[data-theme="dark"] .badge-inactive { background: #450a0a; color: #fca5a5; }

.badge-role-webmaster { background: #1e3a8a; color: #bfdbfe; }
.badge-role-officer   { background: #1e40af; color: #dbeafe; }
.badge-role-user      { background: #334155; color: #cbd5e1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-primary);
}
.btn-secondary:hover { background: var(--bg-hover); }

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

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.tab-btn {
    padding: 0.65rem 1.1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Flash messages */
.flash {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}
.flash-success { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-light); }
.flash-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
[data-theme="dark"] .flash-error { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* Login page specific */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0b1e3d 0%, #12294d 50%, #0b1e3d 100%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    padding: 2.25rem;
}
.login-card h1 {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}
.login-card .subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.75rem;
}

/* Character switcher in header – high contrast */
.char-switcher {
    background-color: #0a1628;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: 0.3rem 1.6rem 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%94a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}
.char-switcher:hover,
.char-switcher:focus {
    border-color: #60a5fa;
    outline: none;
}
.char-switcher option {
    background-color: #0f1a2e;
    color: #e2e8f0;
}

/* Utility */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { width: 220px; }
    .content { padding: 1.25rem; }
}
@media (max-width: 700px) {
    .main-layout { flex-direction: column; }
    .sidebar { width: 100%; min-height: auto; }
}
