/* =====================================================================
   core.css — Shared design system for the Study Platform
   Tokens, base layout, and reusable components.
   Every page links this file first, then its own page/panel css.
   ===================================================================== */

:root {
    --bg: #0f0f0f;
    --bg-elev: #161619;
    --card: rgba(24, 24, 28, 0.85);
    --card-solid: #1c1c21;
    --card-border: rgba(255, 255, 255, 0.12);
    --text: #f5f5f5;
    --subtext: #a9a9b3;
    --accent: #ffd700;
    --accent-ink: #111111;
    --danger: #ff4757;
    --danger-soft: rgba(255, 71, 87, 0.1);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 12px;
    --radius-pill: 999px;
    --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.35);
    --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.5);
    --font: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --nav-h: 76px;
    --metal-dark: #1a1a1a;
    --metal-light: #333333;
    --wood-dark: #331a0d;
    --wood-light: #4d3319;
    --accent-gold: #b38600;
    --neon-glow: rgba(255, 230, 0, 0.5);
    --background-dark: #0d0d0d;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; }

p { margin: 0 0 10px; }

a { color: var(--accent); text-decoration: none; }

button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- Reusable components ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.card.subtle-card {
    background: rgba(255, 255, 255, 0.03);
}

.panel-title { margin-bottom: 14px; }
.panel-title h2 { font-size: 20px; }
.panel-title h3 { font-size: 17px; }
.panel-title.small { margin-bottom: 10px; }
.panel-subtitle { display: block; color: var(--subtext); font-size: 13px; font-weight: 500; }

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.notice {
    margin-top: 14px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 215, 0, 0.1);
    color: var(--accent);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

/* Buttons */
.btn,
.primary-btn,
.secondary-btn {
    cursor: pointer;
    font-weight: 700;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--card-border);
    transition: transform 0.12s ease, filter 0.2s ease, background 0.2s ease;
    font-family: inherit;
}
.btn:active,
.primary-btn:active,
.secondary-btn:active { transform: scale(0.97); }

.primary-btn { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.primary-btn:hover { filter: brightness(1.06); }

.secondary-btn { background: transparent; color: var(--text); }
.secondary-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* Form controls */
.field-label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--subtext); }

select,
input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    margin: 10px 0;
    font-family: inherit;
    font-size: 15px;
}
select:focus,
input:focus { outline: 2px solid rgba(255, 215, 0, 0.5); outline-offset: 1px; }

/* Dropdown options: dark bg + light text so choices are always readable
   (native <option> lists render white-on-white in some browsers otherwise). */
select option {
    background: #1c1c21;
    color: #f5f5f5;
}
select optgroup {
    background: #161619;
    color: var(--accent);
}

/* Badges / pills */
.badge {
    background: rgba(255, 215, 0, 0.16);
    color: var(--accent);
    border: 1px solid rgba(255, 215, 0, 0.25);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 13px;
}

/* Filter tabs */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: var(--radius-sm);
}
.filter-btn {
    flex: 1;
    padding: 10px;
    color: var(--subtext);
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    transition: 0.3s;
    background: transparent;
    border: none;
}
.filter-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Leaderboard / list rows */
.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: 0.2s;
    position: relative;
}
.leaderboard-item:hover { border-color: var(--card-border); }

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 16px;
}
.modal.is-open { display: flex; }
.modal-content {
    background: var(--card-solid);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: min(92vw, 420px);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    position: relative;
}
.warning-box {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-weight: 700;
}
.code-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 14px;
    border-radius: var(--radius-sm);
    text-align: center;
    margin-bottom: 10px;
    font-family: monospace;
    font-size: 20px;
    color: var(--accent);
    word-break: break-all;
}

/* Banners */
#announce-bar {
    display: none;
    background: var(--accent);
    color: #000;
    text-align: center;
    padding: 12px;
    font-weight: 700;
    font-size: 14px;
    z-index: 500;
}
#update-banner {
    background: var(--accent);
    color: #000;
    text-align: center;
    padding: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

/* Utilities */
.center-note { text-align: center; color: var(--subtext); margin: 12px 0; }
.small-box { margin-top: 12px; padding: 12px; background: rgba(255, 255, 255, 0.04); border-radius: var(--radius-sm); }
