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

:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --primary-pale: #DBEAFE;
  --secondary: #059669;
  --secondary-light: #10B981;
  --secondary-pale: #D1FAE5;
  --accent: #F59E0B;
  --accent-light: #FBBF24;
  --accent-pale: #FEF3C7;
  --danger: #EF4444;
  --danger-pale: #FEE2E2;
  --purple: #7C3AED;
  --purple-pale: #EDE9FE;
  --bg: #F0F4F8;
  --surface: #FFFFFF;
  --surface-hover: #F8FAFC;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--primary-pale);
  color: var(--primary);
}

/* Loading Screen */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Role Selection Screen */
.role-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary-pale) 0%, var(--bg) 50%, var(--secondary-pale) 100%);
}

.role-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.role-icon-main {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.role-card h1 {
  font-family: 'Nunito', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.role-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.role-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.role-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.role-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.teacher-btn:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
}

.parent-btn:hover {
  border-color: var(--secondary);
  background: var(--secondary-pale);
}

.role-emoji {
  font-size: 2rem;
  flex-shrink: 0;
}

.role-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  display: block;
  color: var(--text);
}

.role-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 0.15rem;
}

/* App Container */
.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  min-height: 100vh;
}

/* Header */
.app-header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-icon {
  font-size: 2rem;
}

.header-left h1 {
  font-family: 'Nunito', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.header-badge {
  display: inline-block;
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  margin-top: 0.15rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-tag {
  background: var(--border-light);
  padding: 0.35rem 0.75rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--border-light);
}

.class-details {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.teacher-name {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-light);
  font-style: italic;
}

/* Class Picker */
.class-picker {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.class-chip {
  flex-shrink: 0;
  padding: 0.4rem 1rem;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}

.class-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.class-chip:hover:not(.active) {
  border-color: var(--primary-light);
  color: var(--primary);
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-family: 'Nunito', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.needed-stat .stat-num { color: var(--primary); }
.claimed-stat .stat-num { color: var(--accent); }
.completed-stat .stat-num { color: var(--secondary); }

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: max-content;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
  background: var(--border-light);
  color: var(--text);
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-family: 'Nunito', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.section-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.supply-section h2 {
  font-family: 'Nunito', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* Add Button */
.add-btn {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.add-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Supply List */
.supply-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Animation for items */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.anim-item {
  animation: fadeSlideIn 0.35s ease-out both;
  animation-delay: calc(var(--anim-index, 0) * 0.04s);
}

/* Supply Card */
.supply-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--border);
  transition: all 0.2s;
}

.supply-card:hover {
  box-shadow: var(--shadow-md);
}

.supply-card.status-needed {
  border-left-color: var(--primary);
}

.supply-card.status-claimed {
  border-left-color: var(--accent);
  background: #FFFCF5;
}

.supply-card.status-completed {
  border-left-color: var(--secondary);
  background: #F7FDF9;
}

.supply-card.priority-high.status-needed {
  border-left-color: var(--danger);
  background: #FFFBFB;
}

.supply-card-top {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.category-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.supply-info {
  flex: 1;
  min-width: 0;
}

.supply-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

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

.supply-name.strikethrough {
  text-decoration: line-through;
  color: var(--text-light);
}

.priority-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.priority-badge.high {
  background: var(--danger-pale);
  color: var(--danger);
}

.priority-badge.low {
  background: var(--border-light);
  color: var(--text-light);
}

.suggested-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  background: var(--purple-pale);
  color: var(--purple);
}

.supply-meta {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.qty-badge,
.cat-badge,
.claimed-by-badge,
.completed-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  background: var(--border-light);
  color: var(--text-secondary);
}

.claimed-by-badge {
  background: var(--accent-pale);
  color: var(--accent);
}

.completed-badge {
  background: var(--secondary-pale);
  color: var(--secondary);
}

.supply-notes {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Supply Actions */
.supply-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.claim-btn {
  background: var(--primary);
  color: #fff;
}

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

.unclaim-btn {
  background: var(--border-light);
  color: var(--text-secondary);
}

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

.complete-btn {
  background: var(--secondary);
  color: #fff;
}

.complete-btn:hover {
  background: var(--secondary-light);
}

.reset-btn {
  background: var(--border-light);
  color: var(--text-secondary);
}

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

.remove-btn {
  background: var(--danger-pale);
  color: var(--danger);
  margin-left: auto;
}

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

/* Empty States */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 320px;
  margin: 0 auto;
}

.empty-state-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
  padding: 2rem;
}

.empty-icon-large {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.empty-state-full h2 {
  font-family: 'Nunito', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.empty-state-full p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 300px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

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

.modal h2 {
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.4;
}

/* Form Elements */
.form-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
  background: var(--surface);
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

.form-textarea {
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: 'DM Sans', sans-serif;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
  background: var(--surface);
  width: 100%;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row .form-label {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.submit-btn {
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.submit-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.cancel-btn {
  padding: 0.6rem 1.25rem;
  background: var(--border-light);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Responsive */
@media (max-width: 480px) {
  .app-header {
    padding: 1rem 0;
  }

  .header-left h1 {
    font-size: 1.15rem;
  }

  .stats-bar {
    gap: 0.5rem;
  }

  .stat {
    padding: 0.6rem 0.25rem;
  }

  .stat-num {
    font-size: 1.25rem;
  }

  .tab-nav {
    gap: 0.15rem;
    padding: 0.2rem;
  }

  .tab-btn {
    padding: 0.5rem 0.5rem;
    font-size: 0.75rem;
  }

  .supply-card {
    padding: 0.85rem;
  }

  .supply-actions {
    flex-direction: column;
  }

  .supply-actions .action-btn {
    width: 100%;
    text-align: center;
  }

  .remove-btn {
    margin-left: 0;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .modal {
    padding: 1.25rem;
    margin: 0.5rem;
  }

  .role-card {
    padding: 2rem 1.25rem;
  }
}

@media (min-width: 640px) {
  .app-container {
    padding: 0 2rem 2rem;
  }

  .supply-card {
    padding: 1.15rem 1.5rem;
  }
}

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

.modal-header h2 {
  margin-bottom: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.15rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--border-light);
  color: var(--text);
}

.no-class-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--accent-pale);
  border: 1.5px solid var(--accent-light);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.no-class-banner-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.no-class-banner-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.no-class-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.no-class-banner-text strong {
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.no-class-banner-text span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.setup-class-btn {
  flex-shrink: 0;
  padding: 0.55rem 1.15rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.setup-class-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 480px) {
  .no-class-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .no-class-banner-content {
    flex-direction: column;
    align-items: center;
  }

  .setup-class-btn {
    width: 100%;
    text-align: center;
  }
}

/* Edit button for supply cards */
.edit-btn {
  background: var(--primary-pale);
  color: var(--primary);
}

.edit-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* Quantity progress bar */
.qty-progress-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.qty-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border-light);
  border-radius: 99px;
  overflow: hidden;
  max-width: 120px;
}

.qty-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}

.qty-progress-fill.fill-needed {
  background: var(--primary);
}

.qty-progress-fill.fill-partial {
  background: var(--accent);
}

.qty-progress-fill.fill-complete {
  background: var(--secondary);
}

.qty-progress-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Claim quantity selector */
.claim-qty-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.claim-qty-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.claim-qty-input {
  width: 60px;
  padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  text-align: center;
  color: var(--text);
  background: var(--surface);
}

.claim-qty-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

.claim-qty-available {
  font-size: 0.72rem;
  color: var(--text-light);
}

/* Claims list in teacher view */
.claims-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.claim-chip {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  background: var(--accent-pale);
  color: var(--accent);
}

.supply-description {
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  font-style: italic;
}

.qty-remaining-hint {
  margin-top: 0.3rem;
}

.qty-remaining-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--secondary);
  background: var(--secondary-pale);
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
}

.claim-qty-fixed {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  padding: 0.3rem 0.6rem;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  min-width: 36px;
  text-align: center;
  display: inline-block;
}
