/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy: #1a3a5c;
  --navy-dark: #0f2540;
  --navy-light: #2a5a8c;
  --sky: #4aabde;
  --sky-light: #7ec8eb;
  --green: #8db83a;
  --green-dark: #6d9a1f;
  --bg: #f4f7fa;
  --card-bg: #ffffff;
  --text: #1a2a3a;
  --text-light: #5a6a7a;
  --border: #dce4ec;
  --danger: #d32f2f;
  --danger-light: #ffebee;
  --success: #2e7d32;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(26, 58, 92, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
header {
  background: var(--navy);
  color: white;
  padding: 16px 0;
  box-shadow: 0 2px 12px rgba(15, 37, 64, 0.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
}

.brand h1 {
  font-size: 1.4rem;
  margin: 0;
  line-height: 1.2;
}

.brand .subtitle {
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 0;
}

nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: rgba(74, 171, 222, 0.3);
  border-color: var(--sky);
}

.nav-btn.active {
  background: var(--sky);
  color: white;
  border-color: var(--sky);
  font-weight: 600;
}

/* Main */
main {
  flex: 1;
  padding: 30px 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  color: var(--navy);
}

.section-desc {
  color: var(--text-light);
  margin-bottom: 24px;
}

/* Appointments List (User View) */
.appointments-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.appointment-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 4px solid var(--sky);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.appointment-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26, 58, 92, 0.12);
}

.appointment-card h3 {
  color: var(--navy);
  font-size: 1.15rem;
}

.appointment-card .ap-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-light);
}

.appointment-card .ap-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.appointment-card .ap-description {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.appointment-card .ap-spots {
  font-size: 0.85rem;
  font-weight: 600;
}

.ap-spots.available {
  color: var(--green-dark);
}

.ap-spots.full {
  color: var(--danger);
}

.appointment-card .btn {
  align-self: flex-start;
  margin-top: auto;
}

/* Admin Layout */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.admin-form-card,
.admin-list-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.admin-form-card h3,
.admin-list-card h3 {
  color: var(--navy);
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.admin-appointment-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.admin-appointment-item .item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.admin-appointment-item .item-info h4 {
  font-size: 0.95rem;
  color: var(--navy);
}

.admin-appointment-item .item-info p {
  font-size: 0.8rem;
  color: var(--text-light);
}

.admin-appointment-item .item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Attendees */
.attendees {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.attendees-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.attendees-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.attendees-table th,
.attendees-table td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}

.attendees-table th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.no-attendees {
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 8px;
}

/* Add participant row */
.add-participant {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.add-participant-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.input-sm {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  flex: 1;
  min-width: 100px;
}

.input-sm:focus {
  outline: none;
  border-color: var(--sky);
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.75rem;
  line-height: 1;
}

/* Logout button */
.btn-logout {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(211, 47, 47, 0.2);
  border-color: var(--danger);
  color: white;
}

.btn-logout.hidden {
  display: none;
}

/* Form error */
.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.form-error.hidden {
  display: none;
}

/* Wide modal */
.modal-wide {
  max-width: 560px;
}

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 0.88rem;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group textarea {
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(74, 171, 222, 0.15);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: var(--sky);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-light);
}

.btn-primary:disabled {
  background: #bdbdbd;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--navy);
  color: white;
}

.btn-secondary:hover {
  background: var(--navy-dark);
}

.btn-success {
  background: var(--green);
  color: white;
}

.btn-success:hover {
  background: var(--green-dark);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: #b71c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 37, 64, 0.6);
}

.modal-content {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-content h3 {
  color: var(--navy);
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.modal-details {
  color: var(--text-light);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 14px 24px;
  border-radius: var(--radius);
  color: white;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 2000;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.toast.success {
  background: var(--green-dark);
}

.toast.error {
  background: var(--danger);
}

/* Footer */
footer {
  background: var(--navy-dark);
  color: rgba(255,255,255,0.7);
  padding: 16px 0;
  text-align: center;
  font-size: 0.85rem;
}

/* Hint */
.hint {
  color: var(--text-light);
  font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

@media (max-width: 500px) {
  .brand h1 {
    font-size: 1.1rem;
  }

  .logo {
    width: 44px;
    height: 44px;
  }

  .appointments-list {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: 24px;
  }
}
