/* Color Variables */
:root {
  --primary-color: #bb2125;
  --primary-hover: #b91c1c;
  --secondary-color: #1e40af;
  --secondary-hover: #1e3a8a;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #dc2626;
  --light-bg: #0f172a;
  --light-surface: #002147;
  --light-border: #334155;
  --dark-surface: #1a2d4d;
  --text-light: #f1f5f9;
  --text-muted: #94a3b8;
}


body {
  background: var(--light-bg);
  color: var(--text-light);
  font-family: 'Cairo', Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  box-sizing: border-box;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Custom scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) rgba(255, 255, 255, 0.08);
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary-color), #d43135);
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.6);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #d43135, var(--primary-color));
}

html {
  max-width: 100vw;
  overflow-x: hidden;
}

.site-header {
  width: 100%;
  background: var(--light-surface);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  border-bottom: 2px solid var(--light-border);
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.08);
  min-height: 120px;
}

.site-logo {
  width: 100vw;
  height: auto;
  display: block;
  object-fit: cover;
  margin: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem 1rem;
  box-sizing: border-box;
  overflow-x: hidden;
}

h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary-color);
}

#searchInput {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(187, 33, 37, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(10, 19, 36, 0.95), rgba(2, 33, 71, 0.85));
  color: var(--text-light);
  font-size: 1.1rem;
  margin-bottom: 2rem;
  transition: border 0.2s;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 52px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.search-row {
  position: relative;
  margin-bottom: 1.2rem;
}

.search-row #searchInput {
  margin-bottom: 0;
  padding-left: 3.2rem;
  padding-right: 1rem;
}

.scan-btn {
  background: transparent;
  border: 2px solid rgba(187, 33, 37, 0.6);
  border-radius: 999px;
  padding: 0.6rem 0.9rem;
  min-width: 48px;
  min-height: 48px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(187, 33, 37, 0.2);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.scan-btn:hover {
  background: rgba(187, 33, 37, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(187, 33, 37, 0.28);
}

.scan-icon {
  width: 24px;
  height: 24px;
  fill: var(--primary-color);
  display: block;
}

.scan-btn.inside .scan-icon {
  fill: #fff;
  animation: scan-wiggle 2.2s ease-in-out infinite;
}

@keyframes scan-wiggle {
  0% { transform: translateX(0); }
  20% { transform: translateX(-2px); }
  40% { transform: translateX(2px); }
  60% { transform: translateX(-1px); }
  80% { transform: translateX(1px); }
  100% { transform: translateX(0); }
}

.scan-btn.inside {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  transform: none;
  z-index: 25;
  width: 2.8rem;
  padding: 0;
  border-width: 0;
  box-shadow: 0 8px 18px rgba(187, 33, 37, 0.28);
  background: linear-gradient(135deg, var(--primary-color), #d43135);
  border-radius: 8px 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.scan-btn.inside:hover {
  background: linear-gradient(135deg, #d43135, var(--primary-color));
  box-shadow: 0 12px 22px rgba(187, 33, 37, 0.35);
}

.scan-btn.inside .scan-icon {
  fill: #fff;
}

.scanner-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 24, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  backdrop-filter: blur(6px);
}

.scanner-content {
  width: min(720px, 92vw);
  background: linear-gradient(160deg, rgba(2, 33, 71, 0.98), rgba(10, 19, 36, 0.92));
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 20px 50px rgba(2, 33, 71, 0.5);
  padding: 1rem;
}

.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.scanner-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-light);
}

.close-scanner {
  background: transparent;
  border: none;
  color: #ffb4b6;
  font-size: 2rem;
  cursor: pointer;
}

.scanner-viewport {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: rgba(10, 19, 36, 0.9);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
  position: relative;
}

.scanner-viewport video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.scanner-viewport::after {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  top: 38%;
  height: 24%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(187, 33, 37, 0.4), 0 0 22px rgba(187, 33, 37, 0.35);
  pointer-events: none;
  animation: scan-frame 2.4s ease-in-out infinite;
}

.scanner-viewport::before {
  content: '';
  position: absolute;
  left: 14%;
  right: 14%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
  box-shadow: 0 0 16px rgba(187, 33, 37, 0.6);
  pointer-events: none;
  animation: scan-line 2.2s ease-in-out infinite;
}

@keyframes scan-frame {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}

@keyframes scan-line {
  0% { transform: translateY(-35px); opacity: 0.6; }
  50% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(35px); opacity: 0.6; }
}

.scanner-status {
  margin-bottom: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: bold;
}

.scanner-actions {
  display: flex;
  justify-content: center;
  margin-top: 0.8rem;
}

#searchInput:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(187, 33, 37, 0.25);
  outline: none;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  box-sizing: border-box;
  overflow-x: hidden;
}

.student-card {
  background: var(--light-surface);
  border: 1px solid var(--light-border);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.08);
  padding: 1.5rem 1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow 0.2s, border 0.2s;
}

.student-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 16px rgba(187, 33, 37, 0.12);
}

.student-photo {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--primary-color);
  margin-bottom: 1rem;
  background: var(--dark-surface);
}

.student-info {
  width: 100%;
  text-align: center;
  margin-bottom: 1rem;
}

.student-info p {
  margin: 0.25rem 0;
  color: var(--text-light);
  font-size: 1rem;
}

.student-info .label {
  color: var(--text-muted);
  font-size: 0.95em;
  margin-left: 0.5em;
}

.card-actions {
  width: 100%;
  display: flex;
  justify-content: center;
}

.btn {
  background: var(--primary-color);
  color: var(--text-light);
  border: none;
  border-radius: 8px;
  padding: 0.6em 1.5em;
  font-size: 1.05em;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.btn:hover {
  background: var(--primary-hover);
}

@media (max-width: 900px) {
  .container {
    padding: 1.1rem 1rem 1.6rem;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.2rem;
  }

  .site-logo {
    width: 100vw;
    max-width: 100vw;
    height: auto;
  }
}

@media (max-width: 600px) {
  .search-row {
    margin-bottom: 1rem;
  }

  #searchInput {
    width: 100%;
    padding: 0.65rem 0.8rem;
    font-size: 1rem;
    margin-bottom: 1.1rem;
    box-sizing: border-box;
    min-height: 50px;
  }

  .container {
    padding: 0.9rem 1rem 1.4rem;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .student-card.simplified {
    padding: 0.3rem 0.01rem;
    border-radius: 8px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .student-card.simplified .student-photo {
    width: 42px;
    height: 42px;
    margin-bottom: 0.2rem;
  }

  .student-card.simplified .student-info p {
    font-size: 0.9rem;
  }

  .modal-content {
    padding: 0.3rem 0.01rem 0.3rem 0.01rem;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .modal-photo {
    width: 42px;
    height: 42px;
    margin-bottom: 0.2rem;
  }

  .modal-receipt {
    max-width: 95vw;
    width: auto;
    max-height: 28vh;
    margin-top: 0.2rem;
    object-fit: contain;
    display: block;
    box-sizing: border-box;
  }
}

.student-card .details-btn {
  background: linear-gradient(135deg, var(--primary-color), #d43135);
  color: var(--text-light);
  border: none;
  border-radius: 999px;
  padding: 0.7em 1em;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  margin-top: 0.7em;
  box-shadow: 0 10px 20px rgba(187, 33, 37, 0.25);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  letter-spacing: 0.03em;
}

.student-card .details-btn:hover {
  background: linear-gradient(135deg, var(--secondary-color), #0b5bd3);
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(30, 64, 175, 0.28);
}

.student-card.simplified {
  cursor: pointer;
  padding: 1.4rem 1rem 1.1rem;
  border-radius: 22px;
  background: linear-gradient(140deg, rgba(2, 33, 71, 0.95), rgba(10, 19, 36, 0.85));
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 12px 30px rgba(2, 33, 71, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow 0.25s, border 0.25s, transform 0.25s, background 0.25s;
  margin-bottom: 0.5rem;
  position: relative;
  overflow: hidden;
}

.student-card.simplified:hover {
  border-color: rgba(187, 33, 37, 0.7);
  box-shadow: 0 18px 40px rgba(2, 33, 71, 0.45);
  transform: translateY(-4px);
  background: linear-gradient(140deg, rgba(2, 33, 71, 0.95), rgba(187, 33, 37, 0.18));
}

.student-card.simplified .student-photo {
  width: 90px;
  height: 90px;
  margin-bottom: 0.9rem;
  border-radius: 50%;
  border: 3px solid rgba(187, 33, 37, 0.9);
  object-fit: cover;
  background: rgba(10, 19, 36, 0.9);
  box-shadow: 0 8px 18px rgba(2, 33, 71, 0.35);
}

.student-card.simplified .student-info {
  width: 100%;
  text-align: center;
}

.student-card.simplified .student-info p {
  margin: 0.25rem 0;
  color: var(--text-light);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.student-card.simplified .label {
  color: #ffd2d3;
  font-size: 1.08em;
  font-weight: 700;
}

@media (max-width: 600px) {
  .student-card.simplified {
    padding: 0.9rem 0.7rem;
    border-radius: 14px;
  }

  .student-card.simplified .student-photo {
    width: 68px;
    height: 68px;
    margin-bottom: 0.6rem;
  }

  .student-card.simplified .student-info p {
    font-size: 0.96rem;
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 12, 24, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.modal-content {
  background: linear-gradient(160deg, rgba(2, 33, 71, 0.98), rgba(10, 19, 36, 0.92));
  border-radius: 22px;
  box-shadow: 0 20px 50px rgba(2, 33, 71, 0.5);
  padding: 2.2rem 1.6rem 1.6rem 1.6rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  max-width: 420px;
  width: 90vw;
  color: var(--text-light);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 2rem;
  color: #ffb4b6;
  cursor: pointer;
  font-weight: bold;
  z-index: 10;
}

.modal-photo {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid rgba(187, 33, 37, 0.85);
  margin-bottom: 1.1rem;
  background: rgba(10, 19, 36, 0.9);
  box-shadow: 0 10px 20px rgba(2, 33, 71, 0.35);
}

.modal-info-grid {
  width: 100%;
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1.2rem;
}

.modal-info-grid .info-row {
  display: grid;
  grid-template-columns: 1.2rem 1fr 1.4fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(10, 19, 36, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-info-grid .icon {
  text-align: center;
  opacity: 0.85;
}

.modal-info-grid .label {
  color: var(--text-muted);
  font-weight: 600;
}

.modal-info-grid .value {
  color: var(--text-light);
  font-weight: 600;
  text-align: left;
}

.modal-info-grid .receipt-number {
  color: var(--primary-color);
  font-weight: 700;
}

.modal-info-grid .paid {
  color: var(--success-color);
  font-weight: bold;
}

.modal-receipt {
  width: 100%;
  max-width: 320px;
  border-radius: 12px;
  margin-top: 1.2rem;
  box-shadow: 0 12px 24px rgba(2, 33, 71, 0.35);
  background: rgba(10, 19, 36, 0.9);
  object-fit: contain;
  display: block;
  max-height: 40vh;
}

.modal-actions {
  width: 100%;
  display: flex;
  gap: 0.6rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.modal-action-btn {
  flex: 1 1 160px;
  padding: 0.6rem 1rem;
  border-radius: 999px;
}

.modal-media {
  width: 100%;
  margin-top: 0.9rem;
  display: flex;
  justify-content: center;
}

.modal-card,
.modal-receipt {
  width: 100%;
  max-width: 360px;
}

.modal-card {
  display: none;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(2, 33, 71, 0.35);
  background: rgba(10, 19, 36, 0.9);
  object-fit: contain;
  max-height: 45vh;
}

@media (max-width: 600px) {
  .modal-content {
    padding: 1rem 0.8rem 0.9rem 0.8rem;
    max-width: 92vw;
    width: 92vw;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .modal-photo {
    width: 72px;
    height: 72px;
    margin-bottom: 0.6rem;
  }

  .modal-receipt {
    max-width: 92vw;
    width: auto;
    max-height: 30vh;
    margin-top: 0.7rem;
    object-fit: contain;
    display: block;
  }

  .modal-info-grid .info-row {
    grid-template-columns: 1.1rem 1fr;
    grid-template-rows: auto auto;
    padding: 0.6rem 0.7rem;
  }

  .modal-info-grid .value {
    grid-column: 1 / -1;
    text-align: right;
  }

  .modal-actions {
    gap: 0.5rem;
  }
}

.site-header {
  width: 100vw;
  overflow: hidden;
}

.site-logo {
  width: 100vw;
  max-width: 100vw;
  min-width: 0;
  height: auto;
  display: block;
  object-fit: cover;
  margin: 0;
}

.print-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: -0.5rem auto 1.5rem auto;
  padding: 0.6rem 1.4rem;
  background: linear-gradient(135deg, var(--secondary-color), #0b5bd3);
  color: var(--text-light);
  border-radius: 999px;
  text-decoration: none;
  font-weight: bold;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.print-link:hover {
  background: linear-gradient(135deg, var(--secondary-hover), #0a4db3);
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(30, 64, 175, 0.32);
}

.hidden {
  display: none !important;
}
