/* Root theme variables (TweakCN palette) */
:root {
  --background: #f5f1e6;
  --foreground: #4a3f35;
  --card: #fffcf5;
  --card-foreground: #4a3f35;
  --popover: #fffcf5;
  --popover-foreground: #4a3f35;
  --primary: #a67c52;
  --primary-foreground: #ffffff;
  --secondary: #e2d8c3;
  --secondary-foreground: #5c4d3f;
  --muted: #ece5d8;
  --muted-foreground: #7d6b56;
  --accent: #d4c8aa;
  --accent-foreground: #4a3f35;
  --destructive: #b54a35;
  --destructive-foreground: #ffffff;
  --border: #dbd0ba;
  --input: #dbd0ba;
  --ring: #a67c52;
  --radius: 0.5rem;
}

.dark {
  --background: #2d2621;
  --foreground: #ece5d8;
  --card: #3a322c;
  --card-foreground: #ece5d8;
  --popover: #3a322c;
  --popover-foreground: #ece5d8;
  --primary: #c0a080;
  --primary-foreground: #2d2621;
  --secondary: #4a4039;
  --secondary-foreground: #ece5d8;
  --muted: #312b26;
  --muted-foreground: #c5bcac;
  --accent: #59493e;
  --accent-foreground: #ece5d8;
  --destructive: #b54a35;
  --destructive-foreground: #ffffff;
  --border: #4a4039;
  --input: #4a4039;
  --ring: #c0a080;
}

/* Global base styles that Tailwind normally adds via @apply */

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: "Libre Baskerville", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

/* Exam switch buttons */

.exam-switch {
  padding: 0.25rem 0.75rem;            /* px-3 py-1 */
  font-size: 0.75rem;                  /* text-xs */
  font-weight: 700;                    /* font-bold */
  border-radius: 0.125rem;             /* rounded-sm */
  border: none;
  background: transparent;
  color: #7d6b56;                      /* muted-foreground-ish */
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.exam-switch:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.exam-switch.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.exam-switch:not(.active):hover {
  background-color: rgba(245, 241, 230, 0.8); /* background/50 */
  color: var(--foreground);
}

/* Icon toolbar buttons */

.tool-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7d6b56;
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tool-btn:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.tool-btn:focus-visible {
  outline: 1px solid var(--ring);
  outline-offset: 2px;
}

/* Stats cards */

.stats-card {
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  transition: box-shadow 0.15s ease;
}

.stats-card:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-foreground);
}

.stats-value {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.progress-track {
  width: 100%;
  height: 0.375rem;
  border-radius: 9999px;
  overflow: hidden;
  background-color: var(--secondary);
}

.progress-fill {
  height: 100%;
  width: 0%;
  transition: width 0.5s ease-out;
}

/* Sidebar navigation items */

.nav-item {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item:focus-visible {
  outline: none;
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.nav-item.active {
  background-color: rgba(166, 124, 82, 0.08); /* primary/10 */
  color: var(--primary);
  border-left: 2px solid var(--primary);
  border-radius: 0; /* left strip look */
}

.nav-item:not(.active):hover {
  background-color: var(--muted);
  color: var(--foreground);
}

/* Custom checkbox */

.custom-checkbox {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  border: 1px solid var(--primary);
  background-color: transparent;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.custom-checkbox:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.custom-checkbox:checked {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.dark .custom-checkbox:checked {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232d2621' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='20 6 9 17 4 12'%3e%3c/polyline%3e%3c/svg%3e");
}

/* Scrollbar styling */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: rgba(125, 107, 86, 0.2);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(125, 107, 86, 0.4);
}

/* Mobile sidebar open state 
   (body.sidebar-open is toggled in app.js) */

body.sidebar-open #sidebar {
  transform: translateX(0);
}

body.sidebar-open #sidebarBackdrop {
  opacity: 1;
  pointer-events: auto;
}
