:root {
  --primary-color: #4f46e5;
  --secondary-color: #7c3aed;
  --background-light: #f8fafc;
  --background-dark: #0f172a;
  --surface-light: #ffffff;
  --surface-dark: #1e293b;
  --text-light: #e2e8f0;
  --text-dark: #0f172a;
  --border-light: #e2e8f0;
  --border-dark: #334155;
  --success: #10b981;
  --error: #ef4444;
}

/* --- Main Layout --- */
body {
  margin: 0;
  font-family: "Poppins", sans-serif;
  background-color: var(--background-light);
  color: var(--text-dark);
  transition: background-color 0.3s, color 0.3s;
}
body.dark-mode {
  background-color: var(--background-dark);
  color: var(--text-light);
}
.content-wrapper {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Header --- */
.main-header {
  background-color: var(--surface-light);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s;
}
body.dark-mode .main-header {
  background-color: var(--surface-dark);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  height: 70px;
}
.logo {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo img {
  height: 40px;
  width: auto;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.main-nav a {
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  transition: color 0.2s;
}
.main-nav a:hover {
  color: var(--primary-color);
}
.nav-email {
  font-size: 0.9rem;
  color: #64748b;
}
body.dark-mode .nav-email {
  color: #94a3b8;
}
.nav-button.logout {
  color: var(--error);
  font-weight: 600;
}
.theme-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-dark);
}
body.dark-mode .theme-toggle {
  color: var(--text-light);
}

/* --- Login Page & General Buttons --- */
.login-container {
  text-align: center;
  padding-top: 5rem;
  animation: fadeIn 1s;
}
.login-container h1 {
  font-size: 2.5rem;
}
.subtitle {
  font-size: 1.2rem;
  color: #64748b;
  margin-bottom: 2rem;
}
.button-container {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.submit-button,
.login-button {
  position: relative;
  min-height: 50px;
  padding: 12px 24px;
  background: linear-gradient(
    45deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.submit-button:hover,
.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Button Processing State */
.submit-button.processing .button-text {
  visibility: hidden;
  opacity: 0;
}
.submit-button.processing .button-loader {
  visibility: visible;
  opacity: 1;
}
.button-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.button-wrapper {
  margin-top: 1.5rem;
  text-align: center;
}

/* --- Dashboard Pages & Cards --- */
.page-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.5s;
  width: 100%;
}
.page-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
}
.card {
  background-color: var(--surface-light);
  padding: 0.15rem 1.5rem 2rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 600px;
  transition: background-color 0.3s;
}
body.dark-mode .card {
  background-color: var(--surface-dark);
  border: 1px solid var(--border-dark);
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
input[type="text"],
input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: 5px;
  font-size: 1rem;
}
body.dark-mode input[type="text"] {
  background-color: #334155;
  border-color: #475569;
  color: var(--text-light);
}
.loader-container {
  text-align: center;
  margin-top: 1rem;
}
.loader,
.loading {
  display: none;
}
.image-preview-box {
  width: 100%;
  height: 250px;
  border: 2px dashed var(--border-light);
  margin: 1rem 0;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
body.dark-mode .image-preview-box {
  border-color: var(--border-dark);
}
.image-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* --- Results Layout (Student Page) --- */
.results-wrapper {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
  width: 100%;
  max-width: 900px;
  align-items: start;
  animation: fadeIn 0.5s;
}
.image-preview-box-final {
  width: 100%;
  border: 2px dashed var(--border-light);
  border-radius: 12px;
  padding: 10px;
  box-sizing: border-box;
}
body.dark-mode .image-preview-box-final {
  border-color: var(--border-dark);
}
.image-preview-box-final img {
  width: 100%;
  border-radius: 8px;
  object-fit: contain;
}
/* Student Page Upload Card Title */
#upload-card h4 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

body.dark-mode #upload-card h4 {
  border-bottom-color: var(--border-dark);
}
.result-card {
  width: 100%;
  margin-top: 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.result-card h4 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  width: 100%;
  text-align: center;
}
body.dark-mode .result-card h4 {
  border-bottom-color: var(--border-dark);
}
.result-card p {
  margin: 0;
  font-size: 1.1rem;
}
#result-decision.accepted {
  font-weight: 700;
  color: var(--success);
}
#result-decision.rejected {
  font-weight: 700;
  color: var(--error);
}
#rejection-reasons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.rejection-reason {
  background-color: #f8d7da;
  color: #842029;
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}
body.dark-mode .rejection-reason {
  background-color: #581c22;
  color: #fecaca;
}
.result-card .submit-button {
  margin-top: 0.5rem;
}

/* --- Modal Styles --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-content {
  background: var(--surface-light);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  width: 90%;
  max-width: 400px;
  animation: fadeIn 0.3s;
}
body.dark-mode .modal-content {
  background-color: var(--surface-dark);
}
#alert-message {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}
.modal-button {
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Responsive Layouts --- */
@media (max-width: 768px) {
  .results-wrapper {
    grid-template-columns: 1fr;
  }
  .header-content {
    flex-direction: column;
    height: auto;
    padding: 1rem 0;
  }
  .main-nav {
    margin-top: 1rem;
  }
}

/* --- Admin Page Results Card --- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  margin-bottom: 1.5rem;
}
.result-item {
  background-color: var(--background-light);
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
}
body.dark-mode .result-item {
  background-color: var(--background-dark);
}
.result-label {
  display: block;
  font-size: 1.1rem;
  color: #6c757d;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.result-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.success-message-container {
  margin-top: 20px;
  text-align: center;
}

#successMessage {
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #a5d6a7;
  border-left: 5px solid #4caf50;
  background-color: #f9f9f9;
  color: #631d1d;
  line-height: 1.6;
}

.dark-mode #successMessage {
  background-color: #2e2e2e;
  border-color: #444;
  border-left-color: #66bb6a;
  color: #fa8585;
}

#successMessage .count {
  font-weight: 700;
  font-size: 1.2em;
  color: #4caf50;
}

.dark-mode #successMessage .count {
  color: #81c784;
}

#successMessage .batch-label {
  font-weight: 500;
  color: #068a99;
}

.dark-mode #successMessage .batch-label {
  color: #69f0ff;
}

#successMessage .batch-id {
  font-family: "Courier New", Courier, monospace;
  font-weight: 600;
  color: #424242;
  background-color: #eeeeee;
  padding: 2px 5px;
  border-radius: 4px;
  margin-left: 5px;
}

.dark-mode #successMessage .batch-id {
  color: #d0d0d0;
  background-color: #383838;
}
