/* =========================================================
   دفتر مذاكرة يوسف أحمد — تصميم "مكتب المذاكرة الليلي"
   ========================================================= */

:root{
  --bg:            #0F1424;
  --bg-glow:       #171E3C;
  --surface:       #171E36;
  --surface-2:     #1E2748;
  --paper:         #F4EFE3;
  --paper-line:    #DCCFAE;
  --ink:           #EDE7D9;
  --ink-soft:      #C9C2AE;
  --muted:         #8B93B0;
  --gold:          #F4B740;
  --gold-dim:      #C9932E;
  --teal:          #34C3A6;
  --teal-dim:      #227E68;
  --danger:        #E2665A;
  --radius-lg:     28px;
  --radius-md:     16px;
  --font-display:  'Aref Ruqaa', serif;
  --font-body:     'Tajawal', sans-serif;
}

*{ box-sizing:border-box; }

html,body{
  margin:0;
  padding:0;
  background:
    radial-gradient(1100px 600px at 15% -10%, var(--bg-glow) 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #1A2140 0%, transparent 55%),
    var(--bg);
  color:var(--ink);
  font-family:var(--font-body);
  min-height:100vh;
}

.page{
  max-width:920px;
  margin:0 auto;
  padding:32px 20px 80px;
}

/* ===== هيدر ===== */
.header{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:20px;
  flex-wrap:wrap;
  margin-bottom:36px;
}

.header__eyebrow{
  display:block;
  font-size:13px;
  letter-spacing:.5px;
  color:var(--gold);
  margin-bottom:4px;
  font-weight:700;
}

.header__name{
  font-family:var(--font-display);
  font-weight:700;
  font-size:52px;
  margin:0;
  line-height:1;
  color:var(--ink);
}

.link-btn{
  background:none;
  border:none;
  color:var(--muted);
  font-family:var(--font-body);
  font-size:12.5px;
  text-decoration:underline;
  cursor:pointer;
  padding:0;
  margin-top:6px;
}
.link-btn:hover{ color:var(--danger); }

/* ===== صفحة الدخول ===== */
.auth-body{
  display:flex;
  align-items:center;
  min-height:100vh;
}

.auth-page{
  max-width:920px;
  width:100%;
  margin:0 auto;
  padding:32px 20px;
  display:grid;
  grid-template-columns:1.1fr 1fr;
  gap:40px;
  align-items:center;
}

.auth-brand__title{
  font-family:var(--font-display);
  font-size:40px;
  line-height:1.25;
  margin:10px 0 14px;
  color:var(--ink);
}

.auth-brand__sub{
  color:var(--muted);
  font-size:14px;
  line-height:1.9;
  max-width:38ch;
}

.auth-card{
  background:var(--surface);
  border:1px solid rgba(244,183,64,.18);
  border-radius:var(--radius-lg);
  padding:26px;
  box-shadow:0 20px 40px rgba(0,0,0,.35);
}

.auth-tabs{
  display:flex;
  gap:6px;
  background:var(--surface-2);
  border-radius:99px;
  padding:5px;
  margin-bottom:22px;
}

.auth-tab{
  flex:1;
  border:none;
  background:none;
  color:var(--muted);
  font-family:var(--font-body);
  font-weight:700;
  font-size:13.5px;
  padding:10px 12px;
  border-radius:99px;
  cursor:pointer;
  transition:background .2s ease, color .2s ease;
}

.auth-tab.is-active{
  background:linear-gradient(180deg, var(--gold), var(--gold-dim));
  color:#241505;
}

.auth-form{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:12.5px;
  color:var(--muted);
}

.field input{
  font-family:var(--font-body);
  background:var(--surface-2);
  border:1px solid rgba(139,147,176,.25);
  border-radius:12px;
  padding:12px 14px;
  color:var(--ink);
  font-size:14px;
  outline:none;
}

.field input:focus{
  border-color:var(--gold);
}

.auth-submit{
  margin-top:6px;
}

.auth-error{
  color:var(--danger);
  font-size:12.5px;
  min-height:16px;
  margin:0;
}

.auth-note{
  color:var(--muted);
  font-size:11.5px;
  line-height:1.7;
  margin:0;
}

.auth-loading{
  text-align:center;
  color:var(--muted);
  font-size:13px;
}

@media (max-width:720px){
  .auth-page{ grid-template-columns:1fr; }
  .auth-brand{ text-align:center; }
  .auth-brand__sub{ margin:0 auto; }
}

.level-card{
  background:var(--surface);
  border:1px solid rgba(244,183,64,.18);
  border-radius:var(--radius-md);
  padding:16px 20px;
  min-width:240px;
}

.level-card__top{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
}

.level-card__label{
  font-size:12px;
  color:var(--muted);
}

.level-card__points{
  font-size:13px;
  font-weight:700;
  color:var(--gold);
}

.level-card__title{
  font-family:var(--font-display);
  font-size:26px;
  color:var(--ink);
  margin-bottom:10px;
}

.level-bar{
  height:6px;
  border-radius:99px;
  background:var(--surface-2);
  overflow:hidden;
  margin-bottom:6px;
}

.level-bar__fill{
  height:100%;
  width:0%;
  background:linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition:width .5s ease;
}

.level-card__next{
  font-size:11px;
  color:var(--muted);
}

/* ===== منطقة التركيز / الحلقة ===== */
.focus-zone{
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  margin-bottom:28px;
}

.subject-field{
  width:100%;
  max-width:380px;
  margin-bottom:22px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.subject-field__label{
  font-size:12.5px;
  color:var(--muted);
}

.subject-field input{
  font-family:var(--font-body);
  background:var(--surface-2);
  border:1px solid rgba(139,147,176,.25);
  border-radius:12px;
  padding:12px 14px;
  color:var(--ink);
  font-size:14px;
  outline:none;
  text-align:center;
}

.subject-field input:focus{
  border-color:var(--gold);
}

.ring__subject{
  font-size:13px;
  font-weight:700;
  color:var(--gold);
  max-width:220px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.ring-wrap{
  position:relative;
  width:300px;
  height:300px;
  margin-bottom:24px;
}

.ring{
  width:100%;
  height:100%;
  transform:rotate(-90deg);
}

.ring__track{
  fill:none;
  stroke:var(--surface-2);
  stroke-width:14;
}

.ring__progress{
  fill:none;
  stroke:var(--gold);
  stroke-width:14;
  stroke-linecap:round;
  stroke-dasharray:816.8;
  stroke-dashoffset:816.8;
  transition:stroke-dashoffset .4s linear, stroke .4s ease;
  filter:drop-shadow(0 0 10px rgba(244,183,64,.55));
}

.ring__progress.is-break{
  stroke:var(--teal);
  filter:drop-shadow(0 0 10px rgba(52,195,166,.55));
}

.ring__center{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
}

.ring__status{
  font-size:14px;
  color:var(--muted);
  letter-spacing:.3px;
}

.ring__time{
  font-family:var(--font-body);
  font-weight:900;
  font-size:44px;
  font-variant-numeric:tabular-nums;
  color:var(--ink);
  direction:ltr;
}

.ring__sub{
  font-size:12px;
  color:var(--muted);
}

/* ===== الأزرار ===== */
.controls{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  justify-content:center;
  margin-bottom:10px;
}

.btn{
  border:none;
  cursor:pointer;
  font-family:var(--font-body);
  font-weight:700;
  font-size:15px;
  padding:14px 30px;
  border-radius:99px;
  transition:transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active{ transform:scale(.96); }

.btn--gold{
  background:linear-gradient(180deg, var(--gold), var(--gold-dim));
  color:#241505;
  box-shadow:0 8px 20px rgba(244,183,64,.25);
}

.btn--teal{
  background:linear-gradient(180deg, var(--teal), var(--teal-dim));
  color:#04241d;
  box-shadow:0 8px 20px rgba(52,195,166,.22);
}

.btn--ghost{
  background:transparent;
  color:var(--ink-soft);
  border:1px solid rgba(237,231,217,.25);
}

.btn--tiny{
  background:transparent;
  color:var(--muted);
  border:1px solid rgba(139,147,176,.3);
  font-size:12px;
  padding:8px 16px;
  border-radius:99px;
}
.btn--tiny:hover{ color:var(--danger); border-color:var(--danger); }

.btn--tiny-danger{
  color:var(--danger);
  border-color:rgba(226,102,90,.35);
  margin-inline-start:6px;
}
.btn--tiny-danger:hover{
  color:#fff;
  background:var(--danger);
  border-color:var(--danger);
}

.hidden{ display:none !important; }

.hint{
  min-height:18px;
  font-size:13px;
  color:var(--teal);
  margin:0;
}

/* ===== شرح نظام البونص ===== */
.bonus-note{
  display:flex;
  gap:14px;
  align-items:flex-start;
  background:var(--surface);
  border:1px solid rgba(244,183,64,.15);
  border-radius:var(--radius-md);
  padding:16px 20px;
  margin-bottom:34px;
}

.bonus-note__icon{
  color:var(--gold);
  font-size:20px;
  line-height:1;
  margin-top:2px;
}

.bonus-note p{
  margin:0;
  font-size:13.5px;
  line-height:1.9;
  color:var(--ink-soft);
}

.bonus-note strong{ color:var(--ink); }

/* ===== السجل — شكل ورقة دفتر ===== */
.log__header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
  margin-bottom:6px;
}

.log__header h2{
  font-family:var(--font-display);
  font-size:24px;
  margin:0;
  color:var(--ink);
}

.log__header-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

.sheet-status{
  font-size:11.5px;
  color:var(--muted);
  padding:6px 12px;
  border-radius:99px;
  background:var(--surface-2);
  border:1px solid rgba(139,147,176,.25);
  white-space:nowrap;
}

.sheet-status.is-linked{
  color:#0F1424;
  background:var(--teal);
  border-color:var(--teal);
  font-weight:700;
}

.btn--tiny-gold{
  color:var(--gold);
  border-color:rgba(244,183,64,.4);
}
.btn--tiny-gold:hover{ color:#0F1424; background:var(--gold); border-color:var(--gold); }

.sheet-hint{
  font-size:12px;
  color:var(--muted);
  margin:0 0 14px;
}

.log__table-wrap{
  background:
    repeating-linear-gradient(
      var(--paper) 0px,
      var(--paper) 42px,
      var(--paper-line) 43px
    );
  border-radius:var(--radius-lg);
  padding:6px 4px;
  box-shadow:0 20px 40px rgba(0,0,0,.35);
  overflow-x:auto;
}

.log__table{
  width:100%;
  border-collapse:collapse;
  min-width:640px;
  color:#2A2416;
}

.log__table thead th{
  font-size:12.5px;
  font-weight:700;
  color:#6B5E3C;
  text-align:right;
  padding:12px 14px 8px;
}

.log__table tbody td{
  font-size:13.5px;
  padding:10px 14px;
  text-align:right;
  direction:ltr;
  text-align:right;
}

.log__table tbody td:last-child,
.log__table tbody td:nth-child(2),
.log__table tbody td:nth-child(3),
.log__table tbody td:nth-child(4),
.log__table tbody td:nth-child(5){
  direction:ltr;
  text-align:right;
  font-variant-numeric:tabular-nums;
}

.log__table tbody tr:not(.log__empty):hover{
  background:rgba(244,183,64,.14);
}

.log__points{
  color:var(--gold-dim);
  font-weight:800;
}

.log__empty td{
  text-align:center;
  color:#8A7E5E;
  font-size:13px;
  padding:26px 10px;
}

/* ===== لوحة المشرف ===== */
.admin-table-wrap .log__table tbody td:nth-child(2){
  direction:rtl;
  text-align:right;
}

/* ===== موبايل ===== */
@media (max-width:560px){
  .header{ flex-direction:column; align-items:flex-start; }
  .header__name{ font-size:38px; }
  .ring-wrap{ width:250px; height:250px; }
  .ring__time{ font-size:34px; }
  .btn{ padding:13px 22px; font-size:14px; }
}

/* ===== إتاحة ===== */
.btn:focus-visible,
.btn--tiny:focus-visible{
  outline:2px solid var(--gold);
  outline-offset:3px;
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; }
}