:root {
  /* --- Core Colors --- */
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #60a5fa;
  --secondary: #10b981;
  --accent: #f59e0b;

  /* --- Functional Colors (with Aliases for Script Compatibility) --- */
  --error: #dc2626;
  --error-color: var(--error); /* Script.js expects this name */

  --success: #059669;
  --success-color: var(--success); /* Script.js expects this name */

  /* --- Light Theme Defaults --- */
  --bg-color: #fafafa;
  --card-bg: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;

  /* --- UI Elements --- */
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* --- Dark Theme Overrides (Matches Main Site) --- */
[data-theme="dark"] {
  --primary: #3b82f6; /* Lighter blue for better contrast on dark */
  --primary-dark: #1d4ed8;

  --bg-color: #121212; /* Deep dark background */
  --card-bg: #1e1e1e; /* Slightly lighter for cards */

  --text-main: #f3f4f6; /* Off-white text */
  --text-muted: #9ca3af; /* Light gray muted text */

  --border-color: #374151; /* Dark gray borders */

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

/* --- Dark Mode Specific Element Fixes --- */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] .upload-area {
  background-color: #27272a; /* Dark input background */
  color: var(--text-main);
  border-color: var(--border-color);
}

[data-theme="dark"] .upload-area:hover {
  background-color: #2e2e33;
}

[data-theme="dark"] select {
  /* Updates dropdown arrow to white in dark mode */
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
/* --- Fix for Buttons in Dark Mode --- */
[data-theme="dark"] .btn-secondary {
  background-color: transparent; /* Makes it blend with the dark card */
  border-color: var(--border-color);
  color: var(--text-main);
}

[data-theme="dark"] .btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1); /* Subtle white tint on hover */
  border-color: var(--text-muted);
  color: #ffffff;
}

/* Optional: Make the Logout button stand out a bit more */
[data-theme="dark"] #logoutBtn,
[data-theme="dark"] #logoutBtnPending {
  border: 1px solid var(--error);
  color: var(--error);
}

[data-theme="dark"] #logoutBtn:hover,
[data-theme="dark"] #logoutBtnPending:hover {
  background-color: var(--error);
  color: #ffffff;
}

/* --- Fix for Toast Notifications in Dark Mode --- */
[data-theme="dark"] .toast {
  background-color: var(--card-bg); /* Uses the dark card color (#1e1e1e) */
  color: var(--text-main); /* Uses the light text color */
  border: 1px solid var(--border-color); /* Adds a subtle border for visibility */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); /* Stronger shadow so it pops */
}

/* Ensure the success/error icons stand out */
[data-theme="dark"] .toast.success i {
  color: var(--success); /* Green */
}

[data-theme="dark"] .toast.error i {
  color: var(--error); /* Red */
}

/* --- Base Reset & Layout --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.3s ease,
    color 0.3s ease; /* Smooth Theme Transition */
  -webkit-font-smoothing: antialiased;
}

/* 2. Apply Poppins to Key UI Elements */
h1, h2, h3, h4,
.logo h1,          /* The "ClassNotes" text in header */
.section-title,    /* "Upload New Notes" title */
.btn,              /* Buttons look great in Poppins */
.toast,            /* Pop-up messages */
.admin-header h2 {
  font-family: "Poppins", sans-serif;
  letter-spacing: -0.02em; /* Poppins often looks better slightly tightened */
}

/* Optional: Make the logo slightly heavier to stand out */
.logo h1 {
  font-weight: 700;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* --- Utilities --- */
.hidden {
  display: none !important;
}
.text-center {
  text-align: center;
}
.text-primary {
  color: var(--primary);
}
.text-muted {
  color: var(--text-muted);
}
.text-sm {
  font-size: 0.875rem;
}
.mb-4 {
  margin-bottom: 1.5rem;
}
.mt-4 {
  margin-top: 1.5rem;
}
.py-4 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
.cursor-pointer {
  cursor: pointer;
}
.hidden-input {
  display: none;
}
.flex-1 {
  flex: 1;
}
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.max-w-400 {
  max-width: 420px;
  margin: 0 auto;
}
.icon-large {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}
.accent-color {
  color: var(--accent);
}
/* --- Header --- */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-content {
  display: flex;
  align-items: center;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo i {
  font-size: 1.75rem;
  color: var(--primary);
}
.logo h1 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* --- Main Content Cards --- */
.main {
  flex: 1;
  padding: 3rem 0;
  position: relative;
}

.pdf-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  position: relative;
}

/* Card Sizes */
.auth-card {
  max-width: 440px;
  margin: 0 auto;
}
.upload-card {
  max-width: 720px;
  margin: 0 auto;
}
.wide {
  max-width: 560px;
}

/* --- Admin Header --- */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.admin-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}
.admin-header h2 span {
  font-size: 1.125rem;
  font-weight: 500;
}

/* --- Section Title --- */
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1.25rem;
  position: relative;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-main);
}
.form-group label i {
  width: 18px;
  text-align: center;
  margin-right: 0.375rem;
  font-size: 0.875rem;
  opacity: 0.7;
}

input,
textarea,
select {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) - 2px);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: all 0.2s;
  background: var(--card-bg);
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
input::placeholder,
textarea::placeholder {
  color: #9ca3af;
}
textarea {
  min-height: 100px;
  resize: vertical;
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
}

.password-toggle {
  position: absolute;
  right: 0.875rem;
  top: 2.75rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: color 0.2s;
}
.password-toggle:hover {
  color: var(--text-main);
}

/* --- Buttons --- */
.btn {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-secondary {
  background: var(--bg-color);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}
.btn-secondary:hover {
  background: #f3f4f6;
}

/* --- Upload Area --- */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--bg-color);
  cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
}
.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.upload-icon {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  opacity: 0.6;
}
.upload-content p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}
.upload-content span {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.file-info {
  color: var(--success);
  font-weight: 500;
  margin-top: 0.5rem;
  display: none;
  font-size: 0.875rem;
}

/* --- Alert Boxes --- */
.alert-box {
  padding: 0.875rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: start;
  font-size: 0.875rem;
  line-height: 1.5;
}
.alert-box.warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #78350f;
}
.alert-box.info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #075985;
}
.alert-box i {
  font-size: 1rem;
  margin-top: 1px;
  flex-shrink: 0;
}
.alert-box strong {
  display: block;
  margin-bottom: 0.125rem;
}
.alert-box p {
  margin: 0;
}

/* --- Form Toggle Link --- */
.form-toggle-link {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.form-toggle-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}
.form-toggle-link a:hover {
  text-decoration: underline;
}

/* --- Loader --- */
.app-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 4rem;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.app-loader p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* --- Footer --- */
footer {
  margin-top: auto;
  padding: 2rem 0;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
  font-size: 0.875rem;
  color: var(--text-muted);
}
.footer-content {
  max-width: 600px;
  margin: 0 auto;
}
.footer-content p {
  margin-bottom: 0.5rem;
}
.thanks-message {
  font-size: 1rem;
  margin-bottom: 0.75rem !important;
}
.heart {
  color: #dc2626;
}
.credits {
  font-weight: 500;
}
.copyright-text {
  margin-top: 1rem;
  font-size: 0.8125rem;
  opacity: 0.7;
}
footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
footer a:hover {
  text-decoration: underline;
}
.policy-links {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
}
.policy-links a {
  margin: 0 0.5rem;
}

/* --- Toast --- */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  max-width: 400px;
}
.toast {
  background: white;
  padding: 0.875rem 1.125rem;
  border-radius: calc(var(--radius) - 2px);
  box-shadow: var(--shadow-lg);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
  border-left: 3px solid var(--success);
  font-size: 0.875rem;
}
.toast.error {
  border-left-color: var(--error);
}
.toast i {
  font-size: 1.125rem;
  flex-shrink: 0;
}
.toast.success i {
  color: var(--success);
}
.toast.error i {
  color: var(--error);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .admin-header {
    flex-direction: column;
    gap: 1rem;
  }
  .admin-header h2 {
    font-size: 1.25rem;
  }
  .form-row {
    flex-direction: column;
  }
  .pdf-card {
    padding: 1.5rem;
  }
  .main {
    padding: 2rem 0;
  }
  #toastContainer {
    left: 20px;
    right: 20px;
    max-width: none;
  }
}

/* =========================================
   SKELETON LOADING (Auth/Upload)
   ========================================= */
.skeleton {
  background: #e1e4e8;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

[data-theme="dark"] .skeleton {
  background: #2d2d30;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.2) 20%,
    rgba(255, 255, 255, 0.5) 60%,
    rgba(255, 255, 255, 0)
  );
  animation: shimmer 2s infinite;
}

[data-theme="dark"] .skeleton::after {
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0.05) 20%,
    rgba(255, 255, 255, 0.1) 60%,
    rgba(255, 255, 255, 0)
  );
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Skeleton Card Layout */
.skeleton-card-auth {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sk-title {
  height: 32px;
  width: 60%;
  margin: 0 auto;
}
.sk-input {
  height: 48px;
  width: 100%;
}
.sk-btn {
  height: 48px;
  width: 100%;
  margin-top: 0.5rem;
  border-radius: var(--radius);
}
.sk-text {
  height: 16px;
  width: 40%;
  margin: 0 auto;
}

/* =========================================
   "OBVIOUS" UPLOAD ZONE STYLES
   ========================================= */
.upload-area {
  border: 2px dashed var(--primary-light); /* More visible border color */
  background: rgba(37, 99, 235, 0.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Pulsing Invite Animation when idle */
@keyframes softPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.1);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

.upload-area:not(.dragover) {
  animation: softPulse 3s infinite;
}

.upload-area:hover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.06);
  transform: translateY(-2px);
}

.upload-icon {
  font-size: 3rem; /* Bigger icon */
  color: var(--primary); /* Blue instead of muted */
  margin-bottom: 0.5rem;
  transition: transform 0.3s ease;
}

.upload-area:hover .upload-icon {
  transform: scale(1.1) rotate(-5deg); /* Fun bounce on hover */
}

/* Make "Browse files" look like a button */
.upload-content strong {
  display: inline-block;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  margin: 0 4px;
  transition: all 0.2s ease;
}

.upload-content strong:hover {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.3);
}
