/* ========================================================
   CHEMXACT - MAIN STYLESHEET
   ======================================================== */

:root {
  --google-blue: #4285F4;
  --google-red: #EA4335;
  --google-yellow: #FBBC04;
  --google-green: #34A853;
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-hover: #E8F0FE;
  --surface-alt: #F8F9FA;
  --text: #202124;
  --text-secondary: #5F6368;
  --border: #DADCE0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow: 0 4px 12px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 24px;
  --transition: 0.2s ease;
  --font: 'Hind Siliguri', sans-serif;
}

body.dark-theme {
  --bg: #121212;
  --surface: #1E1E1E;
  --surface-hover: #2D3136;
  --surface-alt: #252525;
  --text: #E8EAED;
  --text-secondary: #9AA0A6;
  --border: #3C4043;
}

/* RESET */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
  overflow-x: hidden;
}

/* NAVBAR */
.navbar {
  background: var(--surface);
  padding: 0 1.8rem;
  display: flex;
  justify-content: space-between;
  height: 64px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1000;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-brand {
  font-size: 1.35rem; font-weight: 700;
  color: var(--google-blue); text-decoration: none;
  display: flex; gap: 5px; align-items: center;
  cursor: pointer; white-space: nowrap;
}
.nav-brand:hover { opacity: 0.9; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-r { background: var(--google-red); }
.dot-y { background: var(--google-yellow); }
.dot-g { background: var(--google-green); }
.dot-b { background: var(--google-blue); }
.nav-links { display: flex; list-style: none; gap: 0.2rem; align-items: center; }
.nav-links a, .icon-btn {
  color: var(--text-secondary); text-decoration: none;
  padding: 0.5rem 1rem; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  border: none; background: transparent; white-space: nowrap;
  transition: var(--transition); font-family: var(--font);
}
.nav-links a:hover, .icon-btn:hover {
  background: var(--surface-hover); color: var(--google-blue);
}
.nav-links a.active {
  color: var(--google-blue); font-weight: 700; background: var(--surface-hover);
}
.btn-login { background: var(--google-blue) !important; color: #fff !important; }
.btn-login:hover { opacity: 0.9; color: #fff !important; }

/* PORTAL BAR */
.portal-bar {
  background: var(--surface); padding: 0.5rem 1.8rem;
  display: none; gap: 0.6rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; position: sticky; top: 64px; z-index: 999;
  align-items: center; -webkit-overflow-scrolling: touch;
}
.portal-chip {
  padding: 0.4rem 1rem; border-radius: 20px;
  font-size: 0.85rem; border: 1px solid var(--border);
  cursor: pointer; font-weight: 600; white-space: nowrap;
  color: var(--text-secondary); transition: var(--transition);
  background: var(--surface); font-family: var(--font);
}
.portal-chip:hover { background: var(--surface-hover); border-color: var(--google-blue); }
.portal-chip.active {
  background: var(--surface-hover); border-color: var(--google-blue); color: var(--google-blue);
}

/* SECTIONS */
.section {
  display: none !important;
  padding: 2rem 1.8rem;
  max-width: 1200px; margin: 0 auto;
  animation: fadeIn 0.3s ease; min-height: 60vh;
}
.section.active { display: block !important; }
#section-home.active {
  display: flex !important; flex-direction: column;
  align-items: center; justify-content: flex-start;
  min-height: 80vh; padding-top: 3rem;
  position: relative; z-index: 1;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hidden { display: none !important; }

/* Watermark */
#section-home::before {
  content: ""; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 100%; height: 100%;
  background-image: url('cx-logo.png');
  background-size: 350px; background-position: center;
  background-repeat: no-repeat; opacity: 0.15;
  z-index: -1; pointer-events: none;
}
body.dark-theme #section-home::before {
  filter: invert(1) hue-rotate(180deg); opacity: 0.08;
}

/* TYPOGRAPHY */
.section-title { font-size: 2rem; font-weight: 700; margin-bottom: 0.2rem; color: var(--google-blue); }
.section-subtitle { color: var(--text-secondary); font-size: 1rem; margin-bottom: 1.5rem; }

/* BUTTONS */
.btn {
  padding: 0.6rem 1.2rem; border-radius: var(--radius-pill);
  font-weight: 600; border: none; cursor: pointer;
  transition: var(--transition); font-size: 0.95rem;
  display: inline-block; text-align: center;
  font-family: var(--font); text-decoration: none;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-blue   { background: var(--google-blue);   color: #fff; box-shadow: var(--shadow-sm); }
.btn-green  { background: var(--google-green);  color: #fff; box-shadow: var(--shadow-sm); }
.btn-red    { background: var(--google-red);    color: #fff; }
.btn-yellow { background: var(--google-yellow); color: #000; }
.btn-outline {
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--google-blue); font-weight: 700;
}
.btn-outline:hover { background: var(--surface-hover); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.back-btn {
  background: none; border: none;
  color: var(--text-secondary); font-weight: 700;
  cursor: pointer; font-size: 0.95rem; margin-bottom: 1rem;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font); transition: var(--transition);
}
.back-btn:hover { color: var(--google-blue); }

/* PORTAL CARDS (HOME) */
.portal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem; width: 100%; max-width: 900px; margin-top: 2rem;
}
.portal-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 2rem 1.5rem; text-align: center;
  border: 1.5px solid var(--border); box-shadow: var(--shadow);
  cursor: pointer; transition: 0.3s;
  position: relative; overflow: hidden;
}
.portal-card:hover {
  border-color: var(--google-blue); transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(66, 133, 244, 0.15);
}
.portal-card .icon { font-size: 3.5rem; margin-bottom: 10px; }
.portal-card h3 { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.portal-card p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 5px; }

/* NOTICE BOARD */
.notice-board {
  background: #FFFDE7; border-left: 4px solid var(--google-yellow);
  padding: 1.5rem; border-radius: var(--radius-sm);
  margin-top: 3rem; width: 100%; max-width: 900px;
  text-align: left; box-shadow: var(--shadow-sm);
}
body.dark-theme .notice-board { background: #33301a; border-left-color: #F57F17; }
.notice-board h3 {
  color: #F57F17; margin-bottom: 15px;
  display: flex; align-items: center; gap: 8px; font-size: 1.2rem;
}
body.dark-theme .notice-board h3 { color: #FBC02D; }
.notice-list { list-style: none; padding-left: 5px; }
.notice-list li {
  padding: 10px 0; border-bottom: 1px dashed var(--border);
  font-size: 1rem; color: var(--text);
  display: flex; gap: 10px; align-items: flex-start;
}
.notice-list li:last-child { border-bottom: none; }
.notice-list .date {
  font-size: 0.8rem; color: var(--text-secondary);
  white-space: nowrap; background: rgba(0,0,0,0.05);
  padding: 2px 8px; border-radius: 10px;
}

/* FEATURE CARDS (PORTAL HOME) */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem; margin-top: 2rem;
}
.feature-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 2rem; text-align: center;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: var(--transition);
}
.feature-card:hover { border-color: var(--google-blue); transform: translateY(-3px); }
.feature-card .f-icon { font-size: 3rem; margin-bottom: 10px; }
.feature-card h4 { font-size: 1.2rem; color: var(--text); }

/* CLASS TABS & TOPICS */
.class-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.class-tab {
  padding: 0.5rem 1.5rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; color: var(--text-secondary);
  font-family: var(--font); transition: var(--transition);
}
.class-tab:hover { background: var(--surface-hover); }
.class-tab.active {
  background: var(--surface-hover); border-color: var(--google-blue);
  color: var(--google-blue);
}
.search-input {
  width: 100%; max-width: 400px;
  padding: 0.8rem 1.2rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); margin-bottom: 1rem; outline: none;
  font-family: var(--font); font-size: 0.95rem; transition: var(--transition);
}
.search-input:focus {
  border-color: var(--google-blue);
  box-shadow: 0 0 0 3px rgba(66,133,244,0.1);
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.topic-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 1rem; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm); transition: var(--transition);
}
.topic-card:hover { border-color: var(--google-blue); transform: translateY(-2px); }
.topic-card h4 { font-size: 1rem; color: var(--text); }

/* REVISION TABS */
.rev-tabs {
  display: flex; gap: 10px;
  background: var(--surface-alt); padding: 5px;
  border-radius: var(--radius-sm); margin-bottom: 1.5rem;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.rev-tab {
  flex: 1; text-align: center; padding: 0.8rem;
  font-weight: 700; font-size: 0.95rem;
  color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-sm); border: none;
  background: transparent; white-space: nowrap;
  font-family: var(--font); transition: var(--transition);
}
.rev-tab:hover { color: var(--google-blue); }
.rev-tab.active {
  background: var(--surface); color: var(--google-blue);
  box-shadow: var(--shadow-sm);
}
.rev-content {
  background: var(--surface); padding: 1.5rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  line-height: 1.8; font-size: 1.05rem;
}

/* Q&A Boxes */
.qna-box { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.qna-box:last-child { border-bottom: none; }
.qna-q { font-weight: 700; color: var(--google-blue); margin-bottom: 5px; font-size: 1.1rem; }
.qna-a { color: var(--text); padding-left: 20px; }

/* Formula Boxes */
.formula-box {
  background: rgba(251, 188, 4, 0.1);
  border-left: 4px solid var(--google-yellow);
  padding: 1rem; margin-bottom: 1rem;
  font-family: 'Courier New', monospace;
  font-weight: bold; font-size: 1.1rem;
}

/* PDF VIEWER */
.pdf-viewer-container {
  background: var(--surface-alt); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 1rem;
  text-align: center; min-height: 400px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.pdf-viewer-container iframe {
  width: 100%; height: 600px;
  border-radius: 8px; border: 1px solid var(--border);
}

/* QUIZ / MOCK TEST */
.quiz-container {
  background: var(--surface); padding: 2rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  max-width: 600px; margin: 0 auto;
}
.quiz-question { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; }
.quiz-option {
  display: block; padding: 0.8rem 1rem; margin: 0.5rem 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--surface);
  font-weight: 500; font-size: 1.05rem;
  transition: var(--transition); font-family: var(--font);
}
.quiz-option:hover { background: var(--surface-hover); border-color: var(--google-blue); }
.quiz-option.selected { border-color: var(--google-blue); background: rgba(66,133,244,0.1); }
.quiz-option.correct {
  border-color: var(--google-green) !important;
  background: rgba(52,168,83,0.1) !important;
  color: var(--google-green);
}
.quiz-option.wrong {
  border-color: var(--google-red) !important;
  background: rgba(234,67,53,0.1) !important;
  color: var(--google-red);
}

/* VIDEO GRID */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}
.video-card {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); transition: var(--transition);
}
.video-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.video-card iframe { width: 100%; height: 190px; border: none; }
.video-card .v-info { padding: 0.8rem 1rem; }
.video-card .v-info h4 { color: var(--text); font-size: 1rem; }

/* DASHBOARD */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.dash-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.5rem; text-align: center;
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.dash-card h3 { font-size: 2rem; color: var(--google-blue); }
.dash-card p { color: var(--text-secondary); font-size: 0.9rem; }

/* ADMIN BOXES */
.admin-box {
  background: rgba(66, 133, 244, 0.05);
  border: 1px solid var(--google-blue);
  padding: 1.5rem; border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.admin-box input,
.admin-box textarea,
.admin-box select {
  width: 100%; padding: 0.8rem; margin-bottom: 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 0.95rem;
  transition: var(--transition);
}
.admin-box input:focus,
.admin-box textarea:focus,
.admin-box select:focus {
  border-color: var(--google-blue); outline: none;
  box-shadow: 0 0 0 2px rgba(66,133,244,0.1);
}
.admin-box h3 {
  color: var(--google-blue); border-bottom: 2px solid var(--google-blue);
  padding-bottom: 5px; margin-bottom: 15px;
  display: flex; align-items: center; gap: 8px;
}
.admin-flex { display: flex; gap: 10px; flex-wrap: wrap; }
.chapter-list {
  list-style: none; margin-top: 10px;
  max-height: 200px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px;
}
.chapter-list li {
  display: flex; justify-content: space-between;
  align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--border); font-size: 0.95rem;
}
.chapter-list li:last-child { border-bottom: none; }

/* MODALS */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 2000;
  justify-content: center; align-items: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); padding: 2rem;
  border-radius: var(--radius); width: 90%; max-width: 420px;
  position: relative; box-shadow: var(--shadow);
  max-height: 90vh; overflow-y: auto;
}
.auth-tabs {
  display: flex; gap: 5px; margin-bottom: 1.5rem;
  background: var(--surface-alt); padding: 5px;
  border-radius: var(--radius-pill);
}
.auth-tab {
  flex: 1; text-align: center; padding: 0.6rem;
  font-weight: 700; font-size: 0.9rem;
  color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-pill); border: none;
  background: transparent; transition: var(--transition);
  font-family: var(--font);
}
.auth-tab:hover { color: var(--google-blue); }
.auth-tab.active { background: var(--surface); color: var(--google-blue); box-shadow: var(--shadow-sm); }

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.85rem; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 5px;
}
.form-group input,
.form-group select {
  width: 100%; padding: 0.8rem; margin-bottom: 0;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-family: var(--font); outline: none;
  transition: var(--transition); font-size: 0.95rem;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--google-blue);
  box-shadow: 0 0 0 2px rgba(66,133,244,0.1);
}

/* TOAST */
#toastContainer {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 3000; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: #202124; color: white;
  padding: 1rem 1.5rem; border-radius: var(--radius-pill);
  animation: slideUp 0.3s ease; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  min-width: 200px; text-align: center;
}
@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* FOOTER */
footer {
  display: block !important; width: 100%;
  background: var(--surface); padding: 2rem 1rem;
  text-align: center; border-top: 1px solid var(--border);
  margin-top: 3rem; position: relative; z-index: 10;
}
footer h3 { color: var(--google-blue); margin-bottom: 10px; }
footer p { color: var(--text-secondary); margin-bottom: 5px; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .navbar { padding: 0 1rem; }
  .nav-brand { font-size: 1.1rem; }
  .nav-links a, .icon-btn { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
  .section { padding: 1.5rem 1rem; }
  .section-title { font-size: 1.5rem; }
  .portal-cards { grid-template-columns: 1fr; }
  .feature-cards { grid-template-columns: 1fr 1fr; }
  .video-grid { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: 1fr; }
  .dash-cards { grid-template-columns: 1fr; }
  .quiz-container { padding: 1rem; }
  .modal { width: 95%; padding: 1.5rem; }
  .admin-flex { flex-direction: column; }
  footer { padding: 1.5rem 1rem; }
}

@media (max-width: 480px) {
  .nav-links { gap: 0; }
  .nav-links a, .icon-btn { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
  .portal-card { padding: 1.5rem 1rem; }
  .portal-card .icon { font-size: 2.5rem; }
  .feature-cards { grid-template-columns: 1fr; }
}

/* UTILITY CLASSES */
.field-input {
  flex: 1; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-family: inherit;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.u-mb-sm { margin-bottom: 10px; }
.u-mb-md { margin-bottom: 15px; }
.u-mb-lg { margin-bottom: 1rem; }
.u-w-full { width: 100%; }
.admin-subsection {
  background: var(--surface); padding: 1.5rem;
  border-radius: 12px; margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* ========================================================
   OMR SCANNER CUSTOM STYLES
   ======================================================== */
#cameraContainer {
  position: relative;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}

#cameraContainer video {
  width: 100%;
  display: block;
  object-fit: cover;
}

.omr-overlay-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 35px solid rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.omr-guide-box {
  width: 100%;
  height: 100%;
  border: 2px dashed #00FF00;
  box-sizing: border-box;
  position: relative;
}

.omr-guide-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #00FF00;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.85rem;
  white-space: nowrap;
}

#omrKeyGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap: 12px;
  max-height: 250px;
  overflow-y: auto;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

#omrKeyGrid::-webkit-scrollbar {
  width: 6px;
}
#omrKeyGrid::-webkit-scrollbar-thumb {
  background: var(--google-blue);
  border-radius: 10px;
}

#omrResultBox {
  animation: fadeIn 0.4s ease-in-out;
}

@media (max-width: 480px) {
  #omrKeyGrid {
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    gap: 8px;
    padding: 10px;
  }
  #omrFinalScore {
    font-size: 3rem !important;
  }
}