/* =====================================================
   УчиЛегко — styles.css
   Modern study-helper SPA
   ===================================================== */

/* --- CSS Variables --- */
:root {
  --bg:        #0f0f1a;
  --bg2:       #16162a;
  --bg3:       #1e1e36;
  --surface:   #22223b;
  --surface2:  #2a2a45;
  --border:    #33335a;
  --text:      #eeeef6;
  --text2:     #a0a0c0;
  --text3:     #7070a0;
  --primary:   #6c5ce7;
  --primary2:  #a29bfe;
  --success:   #00cec9;
  --accent:    #fd79a8;
  --warning:   #fdcb6e;
  --danger:    #ff6b6b;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
  --sidebar-w: 240px;
}

/* --- Reset & base --- */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
  font-family:'Segoe UI',system-ui,-apple-system,sans-serif;
  background:var(--bg);
  color:var(--text);
  display:flex;
  min-height:100vh;
  overflow-x:hidden;
  line-height:1.6;
}

/* --- Scrollbar --- */
::-webkit-scrollbar{width:6px}
::-webkit-scrollbar-track{background:var(--bg2)}
::-webkit-scrollbar-thumb{background:var(--primary);border-radius:3px}

/* --- Sidebar --- */
.sidebar{
  position:fixed;left:0;top:0;bottom:0;
  width:var(--sidebar-w);
  background:var(--bg2);
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;
  z-index:100;
  transition:transform .3s ease;
}
.sidebar__logo{
  font-size:1.3rem;font-weight:700;
  padding:1.2rem 1rem;
  background:linear-gradient(135deg,var(--primary),var(--accent));
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;
  border-bottom:1px solid var(--border);
}
.sidebar__nav{flex:1;padding:.5rem 0}
.sidebar__footer{padding:.8rem 1rem;border-top:1px solid var(--border)}
.sidebar__tip{font-size:.75rem;color:var(--text3);line-height:1.4}

/* Menu items */
.menu-item{
  display:flex;align-items:center;gap:.7rem;
  padding:.7rem 1rem;margin:.15rem .5rem;
  border-radius:var(--radius-sm);
  cursor:pointer;transition:all .2s;
  color:var(--text2);font-size:.9rem;
}
.menu-item:hover{background:var(--surface);color:var(--text)}
.menu-item.active{background:var(--primary);color:#fff}
.menu-item__icon{font-size:1.1rem;width:24px;text-align:center}

/* Burger */
.burger{
  display:none;position:fixed;top:.8rem;left:.8rem;z-index:200;
  background:var(--surface);border:1px solid var(--border);
  color:var(--text);font-size:1.4rem;
  width:42px;height:42px;border-radius:var(--radius-sm);
  cursor:pointer;align-items:center;justify-content:center;
}

/* --- Main --- */
.main{
  margin-left:var(--sidebar-w);
  flex:1;padding:2rem 2.5rem 4rem;
  max-width:1100px;
}

/* --- Pages --- */
.page{display:none;animation:fadeIn .35s ease}
.page.active{display:block}
@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}

/* --- Header --- */
.page-header{margin-bottom:1.5rem}
.page-header h1{font-size:1.8rem;font-weight:700;margin-bottom:.3rem}
.page-subtitle{color:var(--text2);font-size:1rem}
.text-gradient{
  background:linear-gradient(135deg,var(--primary),var(--accent),var(--warning));
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;
}

/* --- Section titles --- */
.section-title{
  font-size:1.1rem;font-weight:600;
  color:var(--text2);margin:1.2rem 0 .6rem;
  padding-left:.2rem;
}

/* --- Buttons --- */
.btn{
  display:inline-flex;align-items:center;gap:.4rem;
  padding:.55rem 1.1rem;border-radius:var(--radius-sm);
  font-size:.88rem;font-weight:500;
  cursor:pointer;border:none;transition:all .2s;
}
.btn--primary{background:var(--primary);color:#fff}
.btn--primary:hover{background:var(--primary2);color:#111}
.btn--secondary{background:var(--surface2);color:var(--text2);border:1px solid var(--border)}
.btn--secondary:hover{background:var(--surface);color:var(--text)}
.btn--danger{background:var(--danger);color:#fff;font-size:.8rem;padding:.4rem .8rem;opacity:.6}
.btn--danger:hover{opacity:1}
.btn--back{background:none;color:var(--primary2);padding:.4rem 0;font-size:.9rem;margin-bottom:.5rem}
.btn--back:hover{color:var(--primary)}
.btn--large{padding:.75rem 1.5rem;font-size:1rem}

/* --- Stat cards --- */
.stats-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:.8rem}
.stat-card{
  background:var(--surface);border-radius:var(--radius);padding:1rem;
  text-align:center;border:1px solid var(--border);
  transition:transform .2s;
}
.stat-card:hover{transform:translateY(-2px)}
.stat-card__icon{font-size:1.5rem;margin-bottom:.3rem}
.stat-card__number{font-size:1.6rem;font-weight:700;color:var(--text)}
.stat-card__label{font-size:.75rem;color:var(--text3);margin-top:.15rem}

/* --- Subject cards --- */
.subjects-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:1rem}
.subject-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:1.2rem;cursor:pointer;
  transition:all .25s;position:relative;overflow:hidden;
}
.subject-card::before{
  content:'';position:absolute;top:0;left:0;right:0;height:3px;
  background:var(--card-color,var(--primary));
}
.subject-card:hover{transform:translateY(-3px);box-shadow:var(--shadow);border-color:var(--card-color,var(--primary))}
.subject-card__icon{font-size:2rem;margin-bottom:.5rem}
.subject-card__name{font-size:1.05rem;font-weight:600;margin-bottom:.2rem}
.subject-card__desc{font-size:.8rem;color:var(--text2);margin-bottom:.5rem;line-height:1.4}
.subject-card__count{font-size:.72rem;color:var(--text3)}

/* --- Search --- */
.search-box{margin-bottom:1.2rem}
.search-box input{
  width:100%;padding:.7rem 1rem;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);color:var(--text);
  font-size:.95rem;outline:none;transition:border .2s;
}
.search-box input:focus{border-color:var(--primary)}
.search-box input::placeholder{color:var(--text3)}

/* --- Topic list --- */
.topics-list{display:flex;flex-direction:column;gap:.5rem}
.topic-item{
  display:flex;align-items:center;gap:1rem;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-sm);padding:.8rem 1rem;
  cursor:pointer;transition:all .2s;
}
.topic-item:hover{border-color:var(--primary);background:var(--surface2)}
.topic-item__num{
  width:32px;height:32px;border-radius:50%;
  background:var(--bg3);display:flex;align-items:center;justify-content:center;
  font-size:.85rem;font-weight:600;color:var(--text2);flex-shrink:0;
}
.topic-item__info{flex:1;min-width:0}
.topic-item__title{font-weight:600;font-size:.92rem}
.topic-item__preview{font-size:.78rem;color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topic-item__badge{
  font-size:.72rem;padding:.25rem .6rem;border-radius:999px;
  background:var(--bg3);color:var(--text3);white-space:nowrap;
}
.topic-item__badge.done{background:rgba(0,206,201,.15);color:var(--success)}

/* --- Topic content --- */
.topic-content{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:1.5rem 1.8rem;
  margin:1rem 0;line-height:1.8;font-size:.95rem;
}
.topic-content h2{font-size:1.15rem;color:var(--primary2);margin:1.2rem 0 .5rem;font-weight:600}
.topic-content h3{font-size:1rem;color:var(--warning);margin:1rem 0 .4rem}
.topic-content p{margin-bottom:.7rem;color:var(--text)}
.topic-content ul,.topic-content ol{margin:.5rem 0 .7rem 1.5rem}
.topic-content li{margin-bottom:.3rem}
.topic-content strong{color:var(--primary2)}
.topic-content code{
  background:var(--bg3);padding:.15rem .4rem;border-radius:4px;
  font-family:'Fira Code',monospace;font-size:.85rem;color:var(--warning);
}
.topic-content .formula{
  display:block;text-align:center;font-size:1.1rem;
  background:var(--bg3);padding:.6rem;margin:.6rem 0;border-radius:var(--radius-sm);
  color:var(--success);font-family:'Fira Code',monospace;
}

.topic-nav{
  display:flex;justify-content:space-between;align-items:center;
  margin-top:1.5rem;padding-top:1rem;border-top:1px solid var(--border);
}

/* --- Exam cards --- */
.exam-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:1rem;margin-top:1rem}
.exam-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:1.2rem;text-align:center;
  cursor:pointer;transition:all .25s;
}
.exam-card:hover{transform:translateY(-3px);box-shadow:var(--shadow);border-color:var(--primary)}
.exam-card__icon{font-size:2.5rem;margin-bottom:.5rem}
.exam-card__name{font-size:1rem;font-weight:600;margin-bottom:.3rem}
.exam-card__count{font-size:.78rem;color:var(--text3)}

/* --- Exam settings --- */
.exam-settings{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:1.5rem;max-width:500px;margin:1rem 0;
}
.exam-settings h2{font-size:1.2rem;margin-bottom:1rem}
.setting-row{
  display:flex;align-items:center;justify-content:space-between;
  padding:.6rem 0;border-bottom:1px solid var(--border);
}
.setting-row:last-of-type{border-bottom:none}
.setting-row label{color:var(--text2);font-size:.9rem}
.setting-row select{
  background:var(--bg3);border:1px solid var(--border);
  color:var(--text);padding:.4rem .8rem;border-radius:var(--radius-sm);
  font-size:.9rem;cursor:pointer;
}

/* --- Quiz --- */
.quiz-header{
  display:flex;align-items:center;gap:1rem;
  margin-bottom:1.5rem;flex-wrap:wrap;
}
.quiz-timer{
  background:var(--surface);border:1px solid var(--border);
  padding:.4rem 1rem;border-radius:var(--radius-sm);
  font-weight:600;font-size:.95rem;color:var(--warning);
}
.quiz-progress{flex:1;min-width:150px}
.quiz-progress__bar{
  height:6px;background:var(--bg3);border-radius:3px;overflow:hidden;
}
.quiz-progress__fill{
  height:100%;background:linear-gradient(90deg,var(--primary),var(--accent));
  border-radius:3px;transition:width .4s ease;
}
.quiz-progress__text{font-size:.75rem;color:var(--text3);margin-top:.2rem}

.quiz-question{
  font-size:1.1rem;font-weight:600;
  margin-bottom:1.2rem;line-height:1.5;
}

.quiz-options{display:flex;flex-direction:column;gap:.5rem;margin-bottom:1rem}
.quiz-option{
  display:flex;align-items:center;gap:.8rem;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-sm);padding:.8rem 1rem;
  cursor:pointer;transition:all .2s;font-size:.92rem;
}
.quiz-option:hover:not(.disabled){border-color:var(--primary);background:var(--surface2)}
.quiz-option.selected{border-color:var(--primary);background:rgba(108,92,231,.15)}
.quiz-option.disabled{cursor:default;opacity:.7}
.quiz-option__letter{
  width:28px;height:28px;border-radius:50%;
  background:var(--bg3);display:flex;align-items:center;justify-content:center;
  font-size:.8rem;font-weight:700;color:var(--text2);flex-shrink:0;
}
.quiz-option.selected .quiz-option__letter{background:var(--primary);color:#fff}

.quiz-hint{
  display:none;background:rgba(253,203,110,.1);
  border:1px solid var(--warning);border-radius:var(--radius-sm);
  padding:.8rem 1rem;margin-bottom:1rem;font-size:.88rem;
  color:var(--warning);line-height:1.5;
}
.quiz-hint.visible{display:block;animation:fadeIn .3s ease}

.quiz-actions{
  display:flex;justify-content:space-between;align-items:center;
  padding-top:.5rem;flex-wrap:wrap;gap:.5rem;
}

/* --- Results --- */
.results-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:2rem;text-align:center;
  max-width:500px;margin:1rem auto;
}
.results-emoji{font-size:3.5rem;margin-bottom:.5rem}
.results-title{font-size:1.5rem;font-weight:700;margin-bottom:1rem}
.results-score__number{font-size:2.5rem;font-weight:700;color:var(--primary2)}
.results-details{
  display:flex;justify-content:center;gap:1.5rem;
  margin:1rem 0;color:var(--text2);font-size:.9rem;flex-wrap:wrap;
}
.results-actions{
  display:flex;flex-direction:column;gap:.5rem;
  margin-top:1.5rem;
}

/* --- Review --- */
.review-item{
  background:var(--surface);border-radius:var(--radius-sm);
  padding:1rem;margin-bottom:.7rem;border-left:4px solid var(--border);
}
.review-item.right{border-left-color:var(--success)}
.review-item.wrong{border-left-color:var(--danger)}
.review-question{font-weight:600;margin-bottom:.4rem;font-size:.92rem}
.review-answer{font-size:.85rem;color:var(--text2);margin-bottom:.2rem}
.review-explanation{font-size:.8rem;color:var(--warning);margin-top:.3rem;padding-top:.3rem;border-top:1px solid var(--border)}

/* --- Progress page --- */
.progress-overall{
  text-align:center;padding:1.5rem;
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);margin-bottom:1rem;
}
.big-number{font-size:3rem;font-weight:700;color:var(--primary2)}
.progress-cards{display:flex;flex-direction:column;gap:.6rem}
.progress-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-sm);padding:.8rem 1rem;
}
.progress-card__header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.3rem}
.progress-card__name{font-weight:600;font-size:.9rem}
.progress-card__pct{color:var(--primary2);font-weight:700;font-size:.9rem}
.progress-bar{height:5px;background:var(--bg3);border-radius:3px;overflow:hidden;margin-bottom:.3rem}
.progress-bar__fill{height:100%;background:linear-gradient(90deg,var(--primary),var(--accent));border-radius:3px}
.progress-card__detail{font-size:.75rem;color:var(--text3)}

/* --- Mobile --- */
@media(max-width:768px){
  .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0)}
  .burger{display:flex}
  .main{margin-left:0;padding:1.2rem 1rem 3rem;padding-top:3.5rem}
  .page-header h1{font-size:1.4rem}
  .subjects-grid{grid-template-columns:1fr}
  .stats-row{grid-template-columns:repeat(2,1fr)}
  .exam-grid{grid-template-columns:repeat(2,1fr)}
}
