/**
 * Admin Portal Styles
 * Ward Clerk Admin PWA
 */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  --primary-color: #1a365d;
  --primary-hover: #2c5282;
  --secondary-color: #718096;
  --danger-color: #c53030;
  --danger-hover: #9b2c2c;
  --success-color: #2f855a;
  --warning-color: #d69e2e;
  --background: #f7fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --text-primary: #1a202c;
  --text-secondary: #718096;
  --text-muted: #a0aec0;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

/* ============================================================
   BASE STYLES
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}

.description {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 16px;
  flex: 1;
}

.form-group.full-width {
  flex-basis: 100%;
}

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

.error-message {
  color: var(--danger-color);
  font-size: 0.875rem;
  margin-top: 8px;
  margin-bottom: 16px;
}

/* Checkbox */
.checkbox-group {
  padding: 12px 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #cbd5e0;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-danger:disabled {
  background: #feb2b2;
  cursor: not-allowed;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn-logout {
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.5);
}

/* ============================================================
   ADMIN HEADER
   ============================================================ */
.admin-header {
  background: var(--primary-color);
  color: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* ============================================================
   TAB NAVIGATION
   ============================================================ */
.tab-navigation {
  display: flex;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border-color);
  padding: 0 24px;
}

.tab-button {
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab-button:hover {
  color: var(--primary-color);
}

.tab-button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  display: none;
  padding: 24px;
}

.tab-content.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   MISSIONARY LIST
   ============================================================ */
.missionary-list {
  display: grid;
  gap: 16px;
}

.missionary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.missionary-card.inactive {
  opacity: 0.6;
}

.missionary-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border-color);
  flex-shrink: 0;
}

.missionary-photo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.missionary-info {
  flex: 1;
  min-width: 0;
}

.missionary-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.missionary-mission {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.missionary-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.missionary-status.active {
  color: var(--success-color);
}

.missionary-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-text {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
}

/* ============================================================
   TEMPLE 365 GRID
   ============================================================ */
.stats-panel {
  display: flex;
  gap: 24px;
  justify-content: center;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.stat-item {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.grid-instructions {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.temple-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.temple-square {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border-color);
  background: #f0f4f8;
  color: var(--text-muted);
}

.temple-square.claimed {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.temple-square.claimed:hover {
  background: var(--danger-color);
  border-color: var(--danger-color);
  transform: scale(1.1);
}

.temple-square:not(.claimed) {
  cursor: default;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content.modal-small {
  max-width: 450px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.missionary-form {
  padding: 24px;
}

/* Photo Upload */
.photo-upload-zone {
  width: 120px;
  height: 120px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  position: relative;
}

.photo-upload-zone:hover {
  border-color: var(--primary-color);
  background: #f0f4f8;
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 8px;
}

.photo-icon {
  font-size: 2rem;
}

.photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview.hidden {
  display: none;
}

/* Token Display */
.token-display {
  padding: 24px;
}

.token-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.token-value {
  font-family: monospace;
  font-size: 0.875rem;
  background: #f0f4f8;
  padding: 12px;
  border-radius: var(--radius);
  word-break: break-all;
  margin-bottom: 16px;
}

.token-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.token-url-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.token-url {
  font-family: monospace;
  font-size: 0.75rem;
  background: #f0f4f8;
  padding: 12px;
  border-radius: var(--radius);
  word-break: break-all;
  margin-bottom: 16px;
}

.token-info {
  font-size: 0.875rem;
  color: var(--success-color);
}

.token-info p {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-info p::before {
  content: '✓';
}

/* Uncheck/Reset Modals */
.uncheck-info,
.reset-stats {
  padding: 24px;
  padding-bottom: 0;
}

.uncheck-info p,
.reset-stats p {
  margin-bottom: 8px;
}

.reset-stats ul {
  list-style: disc;
  margin-left: 24px;
}

.warning-box {
  background: #fef3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 24px;
  font-size: 0.875rem;
  color: #856404;
}

.warning-box.warning-danger {
  background: #f8d7da;
  border-color: var(--danger-color);
  color: #721c24;
}

.warning-box ul {
  list-style: disc;
  margin-left: 20px;
  margin-top: 8px;
}

/* Archive Modal */
.archive-info {
  padding: 24px;
  padding-bottom: 0;
}

.archive-info ul {
  list-style: disc;
  margin-left: 24px;
  margin-top: 8px;
}

.archive-total {
  font-weight: 600;
  margin-top: 16px;
}

.archive-progress {
  padding: 0 24px;
  margin-bottom: 16px;
}

.archive-progress.hidden {
  display: none;
}

.progress-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
  }

  .missionary-card {
    flex-wrap: wrap;
  }

  .missionary-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 8px;
  }

  .stats-panel {
    flex-direction: column;
    gap: 16px;
  }

  .temple-grid {
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 2px;
  }

  .temple-square {
    font-size: 0.65rem;
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-16 {
  margin-top: 16px;
}

.mb-16 {
  margin-bottom: 16px;
}
