@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --primary: #2563eb;
  --primary-glow: rgba(37, 99, 235, 0.35);
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.35);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --card-bg: rgba(17, 24, 39, 0.6);
  --card-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(3, 7, 18, 0.5);
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --danger: #ef4444;
  --font-family: 'Plus Jakarta Sans', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(30, 58, 138, 0.2) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(17, 24, 39, 0.8) 0px, transparent 50%),
    radial-gradient(at 50% 0%, rgba(37, 99, 235, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1rem;
  overflow-x: hidden;
}

/* Container */
.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2.5rem;
  animation: fadeInDown 0.8s ease-out;
}

.school-logo {
  max-width: 95px;
  max-height: 95px;
  width: auto;
  height: auto;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.school-logo:hover {
  transform: scale(1.08);
}

.school-badge {
  background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
  width: 70px;
  height: 70px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 1rem;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.school-badge::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: rotate(45deg);
  animation: shine 4s infinite;
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #93c5fd, #ffffff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.25rem;
}

.sub-title {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Card */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  margin-bottom: 2rem;
  animation: fadeInUp 0.8s ease-out;
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 24px 24px 0 0;
}

/* Form Groups */
.form-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.75rem;
}

.form-section-title span {
  background: var(--primary-glow);
  color: var(--primary-light);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: 2fr 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-wrapper {
  position: relative;
}

.input-wrapper i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
  transition: var(--transition);
}

.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem 1rem 0.75rem 2.7rem;
  color: #fff;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control:focus + i {
  color: var(--primary);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* Subject Grid Selection */
.subject-info {
  background: rgba(37, 99, 235, 0.08);
  border: 1px dashed rgba(37, 99, 235, 0.3);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.subject-info-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.subject-info-text strong {
  color: #fff;
}

.subject-counter {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  box-shadow: 0 4px 10px var(--primary-glow);
  transition: var(--transition);
}

.subject-counter.completed {
  background: var(--success);
  box-shadow: 0 4px 10px var(--success-glow);
}

.subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 550px) {
  .subject-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.subject-card {
  background: rgba(3, 7, 18, 0.4);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  transition: var(--transition);
  user-select: none;
}

.subject-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(3, 7, 18, 0.6);
}

.subject-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: var(--transition);
  border: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.subject-details {
  flex-grow: 1;
}

.subject-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  transition: var(--transition);
}

.subject-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.subject-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: scale(0.6);
  transition: var(--transition);
}

/* Selected State */
.subject-card.selected {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.subject-card.selected .subject-icon {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 10px var(--primary-glow);
}

.subject-card.selected .subject-badge {
  opacity: 1;
  transform: scale(1);
}

/* Submit Button */
.btn-submit {
  width: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #1d4ed8 100%);
  border: none;
  border-radius: 12px;
  padding: 1rem;
  color: #fff;
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: var(--transition);
}

.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 15px 25px rgba(37, 99, 235, 0.45);
  background: linear-gradient(90deg, #1d4ed8 0%, #1e40af 100%);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Success View */
.success-view {
  text-align: center;
  padding: 2rem 0;
  display: none;
  animation: scaleUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-icon {
  width: 80px;
  height: 80px;
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid var(--success);
  color: var(--success);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px var(--success-glow);
}

.success-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.success-desc {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.receipt-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  text-align: left;
  margin-bottom: 2rem;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.receipt-row:last-child {
  border-bottom: none;
}

.receipt-label {
  color: var(--text-muted);
  font-weight: 500;
}

.receipt-value {
  font-weight: 700;
  color: #fff;
  text-align: right;
}

ol.receipt-list {
  padding-left: 1.25rem;
  text-align: left;
  color: #fff;
  font-weight: 600;
}

ol.receipt-list li {
  margin-bottom: 0.25rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: #fff;
  font-family: var(--font-family);
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: none;
}

/* Toast Message */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  background: var(--success);
}

.toast-danger .toast-icon {
  background: var(--danger);
}

/* Animations */
@keyframes shine {
  0% { left: -50%; top: -50%; }
  100% { left: 150%; top: 150%; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleUp {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Admin Specific UI */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-export {
  background: linear-gradient(90deg, var(--accent) 0%, #d97706 100%);
  color: #fff;
  font-family: var(--font-family);
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--accent-glow);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-export:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(245, 158, 11, 0.45);
  background: linear-gradient(90deg, #d97706 0%, #b45309 100%);
}

.btn-logout {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  font-family: var(--font-family);
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: var(--danger);
  color: #fff;
}

/* Stats Section */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 2fr;
  }
}

.stat-box {
  background: rgba(3, 7, 18, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.stat-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary-light);
  line-height: 1;
  margin: 0.5rem 0;
  text-shadow: 0 0 20px var(--primary-glow);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-container {
  background: rgba(3, 7, 18, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #fff;
}

.chart-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chart-subject-name {
  width: 180px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.chart-bar-wrapper {
  flex-grow: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 6px;
  width: 0%;
  transition: width 1s cubic-bezier(0.1, 1, 0.1, 1);
}

.chart-bar-value {
  width: 35px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  color: #fff;
}

/* Admin Table */
.search-wrapper {
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
}

.search-input {
  flex-grow: 1;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(3, 7, 18, 0.25);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th, td {
  padding: 1rem;
  border-bottom: 1px solid var(--card-border);
}

th {
  background: rgba(3, 7, 18, 0.5);
  color: #fff;
  font-weight: 700;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.student-nisn {
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.student-class {
  background: rgba(255, 255, 255, 0.07);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}

.student-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.choice-tag {
  background: rgba(37, 99, 235, 0.15);
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: var(--primary-light);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.btn-delete {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-delete:hover {
  background: var(--danger);
  color: #fff;
}

/* Login Panel */
.login-panel {
  max-width: 400px;
  margin: 4rem auto;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 1.5rem;
  color: #fff;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
}

.badge-order {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.7rem;
  font-weight: bold;
  margin-right: 4px;
}
