/* BNI Presentations App */
:root {
  --red: #c8102e;
  --red-dark: #9e0b24;
  --red-light: #f8e6e9;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-400: #a1a1aa;
  --gray-600: #52525b;
  --gray-800: #27272a;
  --white: #ffffff;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ─── */
header {
  background: var(--red);
  color: var(--white);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}
header .brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
header .brand span { opacity: 0.85; font-weight: 400; font-size: 14px; }
header .header-right { display: flex; align-items: center; gap: 12px; }
#session-info { font-size: 13px; opacity: 0.85; }
#logout-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
#logout-btn:hover { background: rgba(255,255,255,0.3); }

/* ─── Main layout ─── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* ─── Views ─── */
.view { display: none; }
.view.active { display: block; }

/* ─── Login ─── */
#view-login {
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
}
#view-login.active { display: flex; }

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: var(--red);
  border-radius: 50%;
  font-size: 28px;
  font-weight: 900;
  color: white;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p { color: var(--gray-600); font-size: 14px; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group select,
.form-group input[type="password"],
.form-group input[type="text"],
.form-group input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2352525b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-group select:focus,
.form-group input:focus { outline: none; border-color: var(--red); }
.form-group .hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--red); color: white; width: 100%; padding: 12px; font-size: 15px; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-400); color: white; }
.btn-ghost { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.btn-ghost:hover { background: var(--red-light); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 12px;
  display: none;
}
.error-msg.show { display: block; }

/* ─── Members List ─── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.view-header h2 { font-size: 22px; font-weight: 700; }
.view-header p { color: var(--gray-600); font-size: 14px; margin-top: 2px; }

.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.member-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 2px solid transparent;
}
.member-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--red);
}
.member-card .member-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}
.member-card .member-status {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* ─── Member Detail ─── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-600);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
  padding: 0;
  background: none;
  border: none;
  font-weight: 500;
}
.back-btn:hover { color: var(--red); }

.detail-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.detail-card-header {
  background: var(--red);
  color: white;
  padding: 20px 24px;
}
.detail-card-header h2 { font-size: 22px; font-weight: 700; }
.detail-card-header p { opacity: 0.8; font-size: 14px; margin-top: 4px; }
.detail-card-body { padding: 24px; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray-400);
  margin-bottom: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
}
.file-icon { font-size: 28px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

.links-list { display: flex; flex-direction: column; gap: 8px; }
.link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--gray-800);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.link-item:hover { background: var(--red-light); color: var(--red-dark); }
.link-icon { font-size: 18px; flex-shrink: 0; }

.divider { height: 1px; background: var(--gray-200); margin: 20px 0; }

.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 15px; }

/* ─── Upload form ─── */
.upload-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.upload-section-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.upload-section-header h3 { font-size: 16px; font-weight: 600; }
.upload-toggle { font-size: 20px; transition: transform 0.2s; }
.upload-toggle.open { transform: rotate(45deg); }
.upload-form-body { padding: 24px; display: none; }
.upload-form-body.open { display: block; }

.drop-zone {
  border: 2.5px dashed var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--red);
  background: var(--red-light);
}
.drop-zone input[type="file"] { display: none; }
.drop-zone-icon { font-size: 36px; margin-bottom: 8px; }
.drop-zone p { color: var(--gray-600); font-size: 14px; }
.drop-zone strong { color: var(--red); }
.drop-zone .selected-file { font-weight: 600; color: var(--gray-800); margin-top: 6px; font-size: 14px; }

.links-editor { margin-bottom: 16px; }
.link-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.link-row input { margin: 0; }
.add-link-btn { font-size: 13px; }

.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 20px;
  height: 8px;
  margin: 12px 0;
  overflow: hidden;
  display: none;
}
.progress-bar-wrap.show { display: block; }
.progress-bar {
  height: 100%;
  background: var(--red);
  border-radius: 20px;
  transition: width 0.3s;
  width: 0%;
}

.success-msg {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 12px;
  display: none;
}
.success-msg.show { display: block; }

/* ─── Admin Panel ─── */
.admin-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.admin-section h3 { font-size: 17px; font-weight: 700; margin-bottom: 16px; }

.members-admin-list { display: flex; flex-direction: column; gap: 8px; }
.member-admin-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  gap: 12px;
}
.member-admin-row .member-admin-name { flex: 1; font-weight: 500; }
.member-admin-actions { display: flex; gap: 6px; }

/* ─── Loading overlay ─── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-dark {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--red);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  main { padding: 20px 14px; }
  .login-card { padding: 28px 20px; }
  .members-grid { grid-template-columns: 1fr 1fr; }
  .link-row { grid-template-columns: 1fr; }
  .link-row .btn-sm { width: fit-content; }
}

/* ─── Dashboard (admin/leader split view) ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
  align-items: start;
}

.featured-panel {
  background: var(--red);
  color: white;
  border-radius: var(--radius);
  padding: 22px;
  position: sticky;
  top: 72px;
  box-shadow: var(--shadow-lg);
}

.featured-week-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 6px;
}

.featured-date {
  font-size: 12px;
  opacity: 0.72;
  margin-bottom: 5px;
}

.featured-name {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 14px;
}

.featured-none {
  font-size: 14px;
  opacity: 0.72;
  font-style: italic;
  padding: 8px 0 14px;
}

.featured-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 7px;
}

.featured-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-on-red {
  background: white;
  color: var(--red);
  border: none;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.btn-on-red:hover { background: var(--red-light); }

.featured-links-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 7px; }

.featured-link-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  text-decoration: none;
  color: white;
  font-size: 13px;
  transition: background 0.15s;
}

.featured-link-item:hover { background: rgba(255,255,255,0.28); }

.featured-divider {
  height: 1px;
  background: rgba(255,255,255,0.2);
  margin: 14px 0;
}

.featured-upcoming-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 8px;
}

.featured-upcoming-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.featured-upcoming-item:last-child { border-bottom: none; }

.featured-upcoming-date {
  font-size: 11px;
  opacity: 0.6;
  width: 50px;
  flex-shrink: 0;
}

.featured-upcoming-name { font-weight: 500; }
.featured-upcoming-skip { opacity: 0.5; font-style: italic; }

/* ─── Rotation Manager ─── */
.rotation-slot-row {
  display: grid;
  grid-template-columns: 28px 90px 1fr 32px;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  transition: border-color 0.12s, background 0.12s;
}

.rotation-slot-row.is-today {
  border-color: var(--red);
  background: var(--red-light);
}

.rotation-slot-row.drag-over {
  border-color: var(--red);
  background: #fff0f1;
}

.rotation-slot-row.dragging { opacity: 0.35; }

.drag-handle {
  cursor: grab;
  color: var(--gray-400);
  font-size: 17px;
  text-align: center;
  user-select: none;
}

.drag-handle:active { cursor: grabbing; }

.rotation-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  white-space: nowrap;
}

.rotation-date.today-label {
  color: var(--red);
  font-weight: 700;
}

.rotation-member-select {
  padding: 5px 28px 5px 9px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: white;
  color: var(--gray-800);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2352525b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.rotation-member-select:focus { outline: none; border-color: var(--red); }

.rotation-skip-slot { background: var(--gray-100); border-style: dashed; }

.skip-row-btn {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  width: 100%;
  text-align: center;
}

.skip-row-btn:hover { color: var(--red); background: var(--red-light); }

.rotation-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ─── Member Rotation Eligibility List ─── */
.member-rotation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  gap: 12px;
}

.member-rotation-left { flex: 1; min-width: 0; }
.member-rotation-name { font-weight: 500; font-size: 14px; }
.member-rotation-status { font-size: 12px; color: var(--gray-400); margin-top: 1px; }
.member-rotation-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 7px; }
.toggle-label { font-size: 12px; color: var(--gray-600); }

.toggle-switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--gray-200);
  border-radius: 21px;
  transition: background 0.2s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  height: 15px;
  width: 15px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--red); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(17px); }

/* ─── Fix detail-card-header for move-to flex layout ─── */
.detail-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

/* ─── Responsive ─── */
@media (max-width: 720px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .featured-panel { position: static; }
  .rotation-slot-row { grid-template-columns: 28px 72px 1fr 28px; gap: 5px; }
}
