@import url('https://fonts.googleapis.com/css2?family=Mukta+Vaani:wght@300;400;600;700&display=swap');

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { 
  margin: 0; padding: 0; 
  font-family: 'Mukta Vaani', 'Segoe UI', Tahoma, sans-serif; 
  background: #f4f7f6; overflow-x: hidden; color: #2c3e50; 
}

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --blue:    #3498db; --blue-d:  #2980b9;
  --green:   #2ecc71; --green-d: #27ae60;
  --red:     #e74c3c; --red-d:   #c0392b;
  --orange:  #f39c12; --orange-d:#d35400;
  --purple:  #9b59b6; --purple-d:#8e44ad;
  --dark:    #2c3e50; --grey:    #7f8c8d;
  --light:   #ecf0f1; --white:   #ffffff;
  --shadow:  0 4px 6px rgba(0,0,0,0.05);
}

/* ── Auth Screen (Login/Register) ────────────────────────── */
#auth-wrapper {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; background: linear-gradient(135deg, var(--blue), var(--purple));
  padding: 20px;
}
.auth-box {
  background: var(--white); padding: 30px 40px; 
  border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  width: 100%; max-width: 420px; text-align: center;
}
.auth-logo { font-size: 45px; color: var(--blue); margin-bottom: 10px; }
.auth-title { margin: 0 0 20px 0; color: var(--dark); font-size: 24px; font-weight: 700; }
.auth-switch { color: var(--blue); cursor: pointer; font-size: 14px; font-weight: 600; margin-top: 15px; display: inline-block; }
.auth-switch:hover { text-decoration: underline; }

/* ── Layout (Sidebar & Main Content) ─────────────────────── */
#app-wrapper { display: none; min-height: 100vh; }
#sidebar {
  width: 260px; background: var(--dark); color: var(--white);
  display: flex; flex-direction: column; transition: 0.3s ease;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-header {
  padding: 20px; text-align: center; background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 { margin: 0; font-size: 20px; letter-spacing: 1px; }
.sidebar-menu { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.nav-item {
  padding: 15px 20px; cursor: pointer; transition: 0.2s;
  display: flex; align-items: center; gap: 15px; font-size: 15px;
  border-left: 4px solid transparent;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.1); border-left-color: var(--blue); }
.nav-item i { width: 20px; text-align: center; font-size: 16px; }

#main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-height: 100vh; transition: 0.3s; }
.topbar {
  background: var(--white); height: 60px; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); position: sticky; top: 0; z-index: 90;
}
.menu-toggle-btn { display: none; background: none; border: none; font-size: 22px; color: var(--dark); cursor: pointer; }
#sidebar-overlay {
  display: none; position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(0,0,0,0.5); z-index: 95;
}

/* ── UI Components (Cards, Buttons, Inputs) ──────────────── */
.app-panel { display: none; padding: 20px; animation: fadeIn 0.3s; }
.app-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card { background: var(--white); border-radius: 8px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--light); padding-bottom: 12px; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.card-title { margin: 0; font-size: 18px; color: var(--dark); font-weight: 700; }

.input-group { margin-bottom: 15px; text-align: left; }
.input-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #555; font-size: 14px; }
.input-group input, .input-group select {
  width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px;
  font-family: inherit; font-size: 14px; transition: 0.2s;
}
.input-group input:focus, .input-group select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(52,152,219,0.2); }

.btn {
  padding: 10px 20px; border: none; border-radius: 6px; font-family: inherit;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: 0.2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: var(--blue-d); }
.btn-success { background: var(--green); color: #fff; } .btn-success:hover { background: var(--green-d); }
.btn-danger  { background: var(--red); color: #fff; } .btn-danger:hover  { background: var(--red-d); }
.btn-warning { background: var(--orange); color: #fff; } .btn-warning:hover { background: var(--orange-d); }
.btn-info    { background: var(--purple); color: #fff; } .btn-info:hover    { background: var(--purple-d); }
.btn-secondary{ background: var(--grey); color: #fff; } .btn-secondary:hover{ background: #636e72; }

/* ── Tables & Stats ──────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px; text-align: left; border-bottom: 1px solid #eee; }
.data-table th { background: #f8f9fa; color: var(--dark); font-weight: 700; white-space: nowrap; }
.data-table tr:hover { background: #fdfdfd; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-box { background: var(--white); padding: 20px; border-radius: 8px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 15px; }
.stat-icon { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-info h3 { margin: 0; font-size: 24px; color: var(--dark); }
.stat-info p { margin: 0; color: var(--grey); font-size: 13px; font-weight: 600; }

.multi-select-box { border: 1px solid #ccc; border-radius: 6px; padding: 10px; max-height: 150px; overflow-y: auto; background: #fff; }
.multi-select-box label { display: block; margin-bottom: 5px; font-weight: normal; cursor: pointer; font-size: 13px; color: #333; }
.upload-zone { border: 2px dashed #ccc; border-radius: 8px; padding: 20px; background: #fafafa; text-align: center; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.key-badge { background: #f1f2f6; border: 1px dashed #7f8c8d; padding: 3px 8px; border-radius: 5px; font-family: monospace; font-weight: bold; font-size: 13px; color: #2c3e50; }

/* ── Quiz Engine (Live Exam/Practice) ────────────────────── */
#s-quiz-area { display: none; height: 100vh; background: #f0f2f5; flex-direction: column; overflow: hidden; }
.quiz-header { background: var(--white); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.05); z-index: 10; }
.quiz-main { display: flex; flex: 1; overflow: hidden; position: relative; }
.quiz-left { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; }
.quiz-right { width: 300px; background: var(--white); border-left: 1px solid #ddd; display: flex; flex-direction: column; transition: 0.3s; z-index: 5; }

.q-box { background: var(--white); padding: 25px; border-radius: 10px; box-shadow: var(--shadow); flex: 1; display: flex; flex-direction: column; }
.q-text { font-size: 18px; font-weight: 600; margin-bottom: 20px; color: var(--dark); line-height: 1.5; }
.opt-label {
  display: flex; align-items: center; padding: 12px 15px; border: 2px solid #eee;
  border-radius: 8px; margin-bottom: 10px; cursor: pointer; transition: 0.2s; font-size: 15px; font-weight: 600;
}
.opt-label:hover { border-color: var(--blue); background: #f4f9fc; }
.opt-label input { margin-right: 15px; transform: scale(1.2); }
.opt-selected { border-color: var(--blue); background: #ebf5fb; }
.opt-correct  { border-color: var(--green); background: #e9f7ef; color: var(--green-d); }
.opt-wrong    { border-color: var(--red); background: #fdedec; color: var(--red-d); text-decoration: line-through; }
.opt-disabled { pointer-events: none; opacity: 0.8; }

.exp-box { margin-top: 15px; padding: 15px; background: #fef9e7; border-left: 4px solid var(--orange); border-radius: 5px; font-size: 14px; animation: fadeIn 0.3s; }
.quiz-action-strip { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.palette-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 15px; overflow-y: auto; }
.q-btn {
  height: 35px; border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 13px; cursor: pointer; color: #fff; border: 2px solid transparent;
}
.p-not-visited { background: #bdc3c7; color: #333; }
.p-unanswered  { background: var(--red); }
.p-answered    { background: var(--green); }
.p-review      { background: var(--purple); }
.p-retry       { background: var(--orange); }
.p-current     { border-color: var(--dark); transform: scale(1.1); box-shadow: 0 0 8px rgba(0,0,0,0.3); }

/* ── Modal, Toast & FAB ──────────────────────────────────── */
.modal-overlay { display: none; position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(0,0,0,0.6); z-index: 1000; overflow-y: auto; padding: 20px; }
.modal-content { background: #fff; width: 100%; max-width: 700px; margin: 40px auto; border-radius: 10px; padding: 25px; position: relative; animation: fadeIn 0.3s; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.modal-close { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: #aaa; border: none; background: none; }
.modal-close:hover { color: var(--red); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px);
  padding: 12px 25px; border-radius: 30px; color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2); transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 9999;
}
#toast.show { transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--green-d); }
.toast-error   { background: var(--red-d); }
.toast-sync    { background: var(--dark); }

#fab-wrapper { position: fixed; bottom: 30px; right: 30px; z-index: 90; display: none; flex-direction: column; align-items: flex-end; }
.fab-menu { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; opacity: 0; pointer-events: none; transform: translateY(20px); transition: 0.3s; align-items: flex-end; }
.fab-menu.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.fab-item { background: var(--white); padding: 10px 15px; border-radius: 20px; box-shadow: var(--shadow); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--dark); display: flex; align-items: center; gap: 8px; border: 1px solid #eee; transition: 0.2s; }
.fab-item:hover { background: #f8f9fa; color: var(--blue); }
.fab-btn { width: 60px; height: 60px; border-radius: 50%; background: var(--blue); color: white; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; box-shadow: 0 4px 15px rgba(52,152,219,0.4); border: none; transition: 0.3s; }
.fab-btn.active { transform: rotate(45deg); background: var(--red); box-shadow: 0 4px 15px rgba(231,76,60,0.4); }

#loader { position: fixed; top:0; left:0; right:0; bottom:0; background: rgba(255,255,255,0.9); z-index: 9999; display: none; flex-direction: column; justify-content: center; align-items: center; }
.spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid var(--blue); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ── Responsive & Print Rules ────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.active { transform: translateX(0); }
  #main-content { margin-left: 0; }
  .menu-toggle-btn { display: block; }
  .upload-zone { grid-template-columns: 1fr; }
  .quiz-main { flex-direction: column; }
  .quiz-right { width: 100%; border-left: none; border-top: 1px solid #ddd; max-height: 40vh; }
}

@media print {
  body * { visibility: hidden; }
  .print-only, .print-only * { visibility: visible; }
  #common-modal, #common-modal * { visibility: visible; }
  #common-modal { position: absolute; left: 0; top: 0; width: 100%; background: none; padding: 0; margin: 0; box-shadow: none; }
  .modal-content { max-width: 100%; border-radius: 0; padding: 0; box-shadow: none; margin: 0; }
  .no-print { display: none !important; }
  .rev-card { border: 1px solid #000; margin-bottom: 10px; page-break-inside: avoid; }
}

/* ── Force Landscape for Mobile Quiz ─────────────────────── */
.force-landscape::before {
  content: "Please rotate your phone to Landscape mode for the best exam experience.";
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--dark); color: #fff; z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: bold; text-align: center; padding: 20px;
}

@media print {
    /* ૧. બ્રાઉઝરને પૂરું પેજ બતાવવાની મંજૂરી આપવા */
    body, html {
        height: auto !important;
        overflow: visible !important;
    }
    
    /* ૨. પોપ-અપ (Modal) ના સ્ક્રોલ કાઢીને તેને પૂરી લંબાઈ આપવા */
    .modal, .modal-content, .modal-body, #app-modal, .card {
        position: static !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    /* ૩. સ્ક્રોલ થતા કોઈપણ બોક્સને ખુલ્લું કરવા */
    div {
        overflow: visible !important;
    }
    
    /* ૪. પ્રિન્ટમાં નકામા બટનો છુપાવવા (જેમ કે પ્રિન્ટ બટન, ક્લોઝ બટન) */
    button, .btn, .fa-print {
        display: none !important;
    }
}