:root {
  --brand-primary: #0d4794;
  /* Teal */
  --brand-primary-dark: #0f2276;
  --brand-light: #f0fdfa;
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --border-color: #e5e7eb;
  --font-family: "Inter", sans-serif;
  --danger-red: #dc2626;
  --danger-red-dark: #b91c1c;
  --success-green: #16a34a;
  --warning-yellow: #f59e0b;
}

/* --- Basic Reset & Utilities --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  position: relative;
}

.hidden {
  display: none !important;
}

/* --- Login Page Styles --- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  padding: 1rem;
  transition: opacity 0.5s ease-in-out;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--bg-secondary);
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  padding: 2.5rem;
  border: 1px solid var(--border-color);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--brand-primary);
  margin: 0 auto 0.5rem;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.login-header p {
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* --- Forms & Buttons --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 1rem;
  font-family: var(--font-family);
  background-color: #fff;
}

/* Style for file inputs */
.form-group input[type="file"] {
  padding: 0.5rem;
  background-color: var(--bg-primary);
}

.form-group input[type="file"]::file-selector-button {
  margin-right: 1rem;
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  background-color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.form-group input[type="file"]::file-selector-button:hover {
  background-color: var(--brand-light);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2);
}

.button-primary,
.button-secondary,
.button-danger {
  width: 100%;
  padding: 0.875rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s, box-shadow 0.3s;
}

.button-danger {
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.button-primary {
  background-color: var(--brand-primary);
  color: white;
}

.button-primary:hover {
  background-color: var(--brand-primary-dark);
}

.button-primary:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.button-secondary {
  width: auto;
  background-color: var(--brand-light);
  color: var(--brand-primary);
  padding: 0.5rem 1rem;
  border: 1px solid var(--brand-primary);
}

.button-danger {
  background-color: var(--danger-red);
  color: white;
}

.button-danger:hover {
  background-color: var(--danger-red-dark);
}

/* --- Main Application Layout --- */
.app-layout {
  display: flex;
  height: 100vh;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

.sidebar {
  width: 256px;
  background-color: var(--bg-secondary);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease-in-out;
  border-right: 1px solid var(--border-color);
}

.sidebar-header {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  color: var(--brand-primary);
  position: relative;
}

.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
}

.sidebar-nav {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
  cursor: pointer;
}

.nav-link:hover {
  background-color: var(--brand-light);
  color: var(--brand-primary);
}

.nav-link.active {
  background-color: var(--brand-primary);
  color: white;
}

#logout-link {
  margin-top: auto;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.main-header {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.main-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--brand-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.user-name {
  font-weight: 600;
}

.user-role {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.content-header h2 {
  font-size: 1.5rem;
}

.content-header .button-primary {
  width: auto;
  padding: 0.6rem 1.2rem;
}

/* --- Card & Grid Layouts --- */
.grid-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.grid-layout-3-col {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background-color: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.3s, transform 0.3s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.query-card {
  cursor: pointer;
}

.card h3 {
  margin-bottom: 0.5rem;
  color: var(--brand-primary);
}

.card p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.card-footer {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-footer-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* --- NEW STYLES for Query Detail View --- */
#page-query-detail {
  max-width: 900px;
  margin: 0 auto;
}

.answer-card {
  background-color: var(--bg-light);
  border-left: 4px solid var(--brand-primary);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
}

.answer-card p {
  margin-bottom: 0.5rem;
}

.answer-card .card-footer {
  margin-top: 0.5rem;
  font-weight: 600;
}

/* --- Status Badges --- */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.live {
  background-color: #dcfce7;
  color: var(--success-green);
}

.status-badge.upcoming {
  background-color: #fefce8;
  color: var(--warning-yellow);
}

.status-badge.ended {
  background-color: #fee2e2;
  color: var(--danger-red);
}

.status-badge.completed {
  background-color: #f3f4f6;
  color: var(--text-secondary);
}

/* --- Quiz Attempt UI --- */
.quiz-container {
  max-width: 800px;
  margin: auto;
}

.quiz-question-header {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.quiz-options {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: #fff;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.quiz-option:hover {
  background-color: var(--brand-light);
}

.quiz-option.selected {
  background-color: var(--brand-light);
  border-color: var(--brand-primary);
  font-weight: 600;
}

.quiz-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quiz-navigation button {
  width: auto;
}

.quiz-result {
  text-align: center;
  padding: 2rem;
}

.quiz-result h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.quiz-result p {
  font-size: 1.5rem;
}

/* --- Modal Styles --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-overlay:not(.hidden) {
  opacity: 1;
}

.modal-content {
  background-color: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.3s;
}

.modal-overlay:not(.hidden) .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.5rem;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  overflow-y: auto;
  flex-grow: 1;
}

.modal-body .button-primary {
  margin-top: 1rem;
}

#quiz-questions-container .form-group {
  background-color: var(--bg-primary);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

#quiz-questions-container .grid-layout {
  gap: 1rem;
  margin-top: 0.5rem;
}

#quiz-questions-container label {
  margin-top: 0.5rem;
}

/* --- Toast Notification --- */
#toast-notification {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--text-primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: bottom 0.5s ease-in-out;
  z-index: 9999;
}

#toast-notification.show {
  bottom: 20px;
}

/* --- Responsive Design --- */
.hamburger-menu {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    height: 100%;
    z-index: 2000;
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: block;
  }

  .main-header {
    padding: 0 1rem;
  }

  .user-profile .user-name,
  .user-profile .user-role {
    display: none;
  }

  .page-content {
    padding: 1rem;
  }

  .hamburger-menu {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
  }

  .hamburger-menu span {
    width: 24px;
    height: 3px;
    background-color: var(--text-primary);
    border-radius: 10px;
    transition: all 0.3s linear;
  }
}
