/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.card-body {
  padding: 20px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.event-cover {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  margin: 0;
  background: #0b1220;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  min-height: 44px;
  -webkit-appearance: none;
  -webkit-user-select: none;
  user-select: none;
}

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

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

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--surface2);
}

.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 0.9rem;
  min-height: 40px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tiny-link {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0;
}

/* ============================================================
   Forms
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid #475569;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  min-height: 44px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="file"] {
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
}

.upload-preview {
  margin-top: 8px;
}

.upload-preview img {
  max-width: 100%;
  max-height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
}

.badge-admin {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary);
}

.badge-redeemed {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px 12px 0 0;
    padding: 16px;
  }

  .modal-title {
    font-size: 1.15rem;
  }

  .modal-actions {
    gap: 6px;
  }
}

/* ============================================================
   Detail Modal (Fullscreen)
   ============================================================ */

.detail-modal {
  width: min(1200px, 96vw);
  max-width: min(1200px, 96vw) !important;
  height: 92vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
}

.detail-modal .event-cover {
  height: 300px;
  flex-shrink: 0;
}

.detail-scroll {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-scroll::-webkit-scrollbar {
  width: 8px;
}

.detail-scroll::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 99px;
}

.detail-content {
  padding: 24px;
}

.detail-toggle {
  margin-top: 8px;
}

.detail-close-bar {
  display: none;
}

@media (max-width: 600px) {
  .modal-overlay:has(.detail-modal) {
    padding: 0;
  }

  .detail-modal {
    width: 100vw;
    max-width: 100vw !important;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }

  .detail-close-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--surface2);
    flex-shrink: 0;
    z-index: 2;
  }

  .detail-close-bar .btn-ghost {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 0.9rem;
  }

  .detail-close-bar .detail-title-sm {
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
  }

  .detail-modal .event-cover {
    height: 160px;
  }

  .detail-content {
    padding: 16px;
  }

  .detail-content .modal-title {
    font-size: 1.15rem;
  }

  .detail-modal .modal-actions {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--surface2);
    margin-top: 0;
    gap: 8px;
  }

  .detail-modal .modal-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .detail-scroll {
    overflow-y: auto;
  }

  .occurrence-item {
    padding: 12px;
  }

  .occurrence-item .occ-btn {
    padding: 8px 10px;
    font-size: 0.82rem;
    min-height: 38px;
  }

  .join-link {
    flex-direction: column;
    gap: 6px;
  }

  .join-link input {
    font-size: 13px;
  }

  .join-link .btn {
    width: 100%;
  }
}

/* ============================================================
   Avatars
   ============================================================ */

.avatar-stack {
  display: flex;
  align-items: center;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--surface);
  background: var(--surface2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-left: -6px;
}

.avatar:first-child {
  margin-left: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.accepted-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.accepted-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   Card Quick RSVP
   ============================================================ */

.card-rsvp {
  padding: 10px 20px 14px;
  border-top: 1px solid var(--surface2);
}

.rsvp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rsvp-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.rsvp-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.occ-btn.mini {
  padding: 6px 10px;
  font-size: 0.82rem;
  min-height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Occurrence Items
   ============================================================ */

.occurrence-group {
  margin-bottom: 16px;
}

.occurrence-group-title {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.occurrence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.occurrence-item {
  border: 1px solid var(--surface2);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.45);
  padding: 10px;
}

.occurrence-date {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.occ-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.occ-header .occurrence-date {
  margin-bottom: 0;
}

.occ-btns {
  display: flex;
  gap: 6px;
}

.occ-details {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--surface2);
  padding-top: 8px;
}

.occ-response-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.occ-response-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.occ-response-attend .occ-response-label { color: var(--success); }
.occ-response-maybe .occ-response-label { color: var(--warning); }
.occ-response-no .occ-response-label { color: var(--danger); }

.occ-attendee-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.occ-attendee {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface2);
  border-radius: 999px;
  padding: 2px 8px 2px 2px;
}

.occ-attendee .avatar {
  width: 22px;
  height: 22px;
  font-size: 0.6rem;
}

.occ-name {
  white-space: nowrap;
}

.history-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============================================================
   Response Buttons
   ============================================================ */

.occurrences {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.occ-btn {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface2);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  min-height: 40px;
  -webkit-appearance: none;
  -webkit-user-select: none;
  user-select: none;
}

.occ-btn.attend {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.occ-btn.maybe {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
  color: var(--warning);
}

.occ-btn.no {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================================
   Response Summary
   ============================================================ */

.response-summary {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.resp-count {
  font-size: 0.85rem;
}

.resp-count span {
  font-weight: 600;
}

/* ============================================================
   Utilities
   ============================================================ */

.join-link {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.join-link input {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   Spinner
   ============================================================ */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   Table
   ============================================================ */

table {
  width: 100%;
  border-collapse: collapse;
}

/* ============================================================
   Mobile Responsive
   ============================================================ */

@media (max-width: 600px) {
  .card {
    margin-bottom: 12px;
  }

  .card-body {
    padding: 14px;
  }

  .card-rsvp {
    padding: 8px 14px 12px;
  }

  .card-title {
    font-size: 1rem;
  }

  .card-meta {
    font-size: 0.8rem;
  }

  .event-cover {
    height: 140px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
    min-height: 44px;
  }

  .btn-sm {
    padding: 8px 12px;
    min-height: 40px;
  }

  .occurrence-date {
    font-size: 0.8rem;
  }

  .occurrence-item:active {
    background: rgba(15, 23, 42, 0.65);
  }

  .occ-btn {
    padding: 10px 12px;
    min-height: 44px;
    font-size: 0.9rem;
  }

  .occ-btn:active {
    opacity: 0.8;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }

  .avatar-fallback {
    font-size: 0.7rem;
  }

  table th,
  table td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }

  table th {
    background: var(--surface2);
    position: sticky;
    top: 0;
  }

  .user-menu-item {
    padding: 12px 12px;
    font-size: 0.9rem;
    min-height: 44px;
  }
}

