/* =====================================================================
   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: #05060a;
    --bg-radial:
        radial-gradient(ellipse 60% 50% at 85% 15%, rgba(13, 22, 34, 0.5), transparent 60%),
        radial-gradient(ellipse 60% 50% at 15% 85%, rgba(4, 18, 36, 0.42), transparent 60%),
        #05060a;
    --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;
    --cyan: #7dd3fc;
    --cyan-soft: rgba(125, 211, 252, 0.18);
    --cyan-strong: rgba(125, 211, 252, 0.55);
    --mint: #83f2d0;
    --mint-soft: rgba(131, 242, 208, 0.22);
    --gold: #ffd700;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg-radial);
    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; }

.panel-toggle-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--subtext);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    margin-top: 8px;
    transition: all 0.2s;
}
.panel-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text);
}
.card.collapsed .panel-toggle-btn {
    transform: rotate(-90deg);
}
.panel-body {
    overflow: hidden;
}
.card.collapsed .panel-body {
    display: none;
}

.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); }
/* --- Loading Spinner --- */
.loader {
  width: 12px;
  height: 12px;
  background: transparent;
  border: 2px solid var(--subtext);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- Settings Button Loader --- */
.settings-loader {
  width: 24px;
  height: 24px;
  background: #353535;
  display: block;
  position: relative;
  box-sizing: border-box;
  animation: settingsRotation 1s ease-in-out infinite reverse;
}

.settings-loader::before {
  content: '';
  box-sizing: border-box;
  left: 0;
  top: 0;
  transform: rotate(45deg);
  position: absolute;
  width: 24px;
  height: 24px;
  background: #2e2e2e;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}

.settings-loader::after {
  content: '';
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgb(0, 0, 0);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}

@keyframes settingsRotation {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(-360deg); }
}

/* --- Ticket Cloud Loader --- */
.ticket-loader {
  position: relative;
  border-style: solid;
  box-sizing: border-box;
  border-width: 8px 12px 6px 12px;
  border-color: #3760C9 #96DDFC #96DDFC #36BBF7;
  animation: envFloating 1s ease-in infinite alternate;
}

.ticket-loader:after {
  content: "";
  position: absolute;
  right: 12px;
  top: -8px;
  height: 14px;
  width: 10px;
  background-image: linear-gradient(#fff 4px, transparent 0),
            linear-gradient(#fff 4px, transparent 0),
            linear-gradient(#fff 4px, transparent 0);
  background-repeat: no-repeat;
  background-size: 6px 1px;
  background-position: 0px 2px , 2px 7px, 0px 12px;
  animation: envDropping 0.75s linear infinite;
}

@keyframes envFloating {
  0% { transform: translate(-0.4px, -1px); }
  100% { transform: translate(0, 1px); }
}

@keyframes envDropping {
  0% {
    background-position: 20px 2px , 23px 7px, 21px 12px;
    opacity: 1;
  }
  50% {
    background-position: 0px 2px , 3px 7px, 0px 12px;
  }
  60% {
    background-position: -6px 2px , 0px 7px, -2px 12px;
  }
   75%, 100% {
    background-position: -6px 2px , -6px 7px, -6px 12px;
    opacity: 0;
  }
}

/* ===== GEMS COIN ===== */
.coin {
  position: relative;
  width: 22px;
  height: 22px;
  background-color: #d4af37;
  border-radius: 50%;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
  background-image: radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 80%);
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  border: none;
  outline: none;
}

.engraving {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.5);
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.5);
  border: none;
  outline: none;
}

/* Uncomment below to enable flipping animation */
/* .coin { animation: fli 1s infinite; } */
/* @keyframes fli {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
} */