/* ============================================================
   Southern Park County Fire Protection District
   Admin Portal Stylesheet
   ============================================================ */

/* Inherits variables from style.css via HTML link order */
:root {
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --sidebar-bg:   #1a1a2e;
  --sidebar-text: #c8c8d8;
  --sidebar-act:  rgba(192,57,43,0.85);
  --admin-bg:     #f0f2f5;
  --card-bg:      #ffffff;
  --input-border: #d1d5db;
  --focus-ring:   rgba(192,57,43,0.2);
}

/* --- Page watermark (admin overrides) -------------------- */
/* Reposition to 20% right of the content-area centre,
   accounting for the fixed 240px sidebar on the left.
   Content area centre  = (vw - 240px) / 2 + 240px
   +20% of content width = + (vw - 240px) * 0.2
   Combined as a fixed offset from the left edge:
   ≈ 240px + (vw - 240px) * 0.7  — expressed with vw units */
body.admin-body #page-watermark {
  left: calc(var(--sidebar-w) + (100vw - var(--sidebar-w)) * 0.70);
  width: clamp(180px, 30vw, 460px);
  height: clamp(180px, 30vw, 460px);
  opacity: 0.055;
}
/* Keep admin chrome above watermark */
.admin-sidebar, .admin-main, .modal-overlay { position: relative; z-index: 1; }
@media (max-width: 768px) {
  body.admin-body #page-watermark {
    left: 70%;
    width: clamp(140px, 50vw, 260px);
    height: clamp(140px, 50vw, 260px);
  }
}

/* --- Reset for admin pages -------------------------------- */
body.admin-body {
  display: flex;
  min-height: 100vh;
  background: var(--admin-bg);
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  color: #1f2937;
  margin: 0;
}

/* --- Sidebar --------------------------------------------- */
.admin-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform 0.25s;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-decoration: none;
  color: #fff;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-logo {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.sidebar-district { font-size: 1rem; font-weight: 800; line-height: 1.2; }
.sidebar-sub      { font-size: 0.7rem; opacity: 0.6; letter-spacing: 0.5px; text-transform: uppercase; }

.admin-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.admin-nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }
.admin-nav-link.active { background: var(--red); color: #fff; font-weight: 700; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.admin-nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  padding: 12px 12px 4px;
  margin-top: 6px;
}

.sidebar-user {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-username {
  font-size: 0.85rem;
  color: #e5e7eb;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  background: rgba(255,255,255,0.08);
  color: #aaa;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.btn-logout:hover { background: rgba(192,57,43,0.4); color: #fff; }

/* --- Main area ------------------------------------------- */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Top bar --------------------------------------------- */
.admin-topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}
.topbar-breadcrumb {
  font-size: 0.78rem;
  color: #9ca3af;
}
.topbar-breadcrumb a { color: var(--red); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #6b7280;
}
.topbar-avatar {
  width: 32px; height: 32px;
  background: var(--red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

/* --- Page content ---------------------------------------- */
.admin-content {
  flex: 1;
  padding: 28px;
}
.admin-page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: 4px;
}
.admin-page-sub {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 28px;
}

/* --- Cards ----------------------------------------------- */
.admin-card {
  background: var(--card-bg);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}
.admin-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Stat cards ------------------------------------------ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.red    { background: #fee2e2; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.purple { background: #ede9fe; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; color: #111827; }
.stat-label { font-size: 0.78rem; color: #6b7280; margin-top: 3px; }

/* --- Quick action cards ---------------------------------- */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.action-card {
  background: var(--card-bg);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  color: #111827;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
  border-color: var(--red);
  text-decoration: none;
  color: #111827;
}
.action-card .icon { font-size: 1.8rem; }
.action-card h4 { font-size: 0.95rem; font-weight: 700; margin: 0; }
.action-card p  { font-size: 0.8rem; color: #6b7280; margin: 0; line-height: 1.4; }

/* --- Forms ----------------------------------------------- */
.admin-form { display: flex; flex-direction: column; gap: 18px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 0.83rem;
  font-weight: 700;
  color: #374151;
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-input,
.form-select,
.form-textarea {
  padding: 9px 13px;
  border: 1.5px solid var(--input-border);
  border-radius: 7px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.form-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-select {
  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='%23888' 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;
  cursor: pointer;
}
.form-hint {
  font-size: 0.78rem;
  color: #9ca3af;
  line-height: 1.4;
}
.form-error {
  font-size: 0.8rem;
  color: #dc2626;
  display: none;
}
.form-error.show { display: block; }

.file-drop {
  border: 2px dashed var(--input-border);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #fafafa;
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--red);
  background: #fff5f5;
}
.file-drop .icon { font-size: 2rem; margin-bottom: 8px; }
.file-drop p { font-size: 0.85rem; color: #6b7280; margin: 0; }
.file-drop strong { color: var(--red); }
.file-drop input[type=file] { display: none; }

/* --- Buttons --------------------------------------------- */
.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
  text-decoration: none;
  color: inherit;
}
.admin-btn:hover { transform: translateY(-1px); text-decoration: none; }
.admin-btn-primary  { background: var(--red); color: #fff; }
.admin-btn-primary:hover  { background: var(--red-dark); color: #fff; }
.admin-btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.admin-btn-secondary:hover { background: #e5e7eb; color: #374151; }
.admin-btn-danger   { background: #fee2e2; color: #991b1b; }
.admin-btn-danger:hover   { background: #fecaca; }
.admin-btn-success  { background: #d1fae5; color: #065f46; }
.admin-btn-sm { padding: 6px 13px; font-size: 0.8rem; }

.btn-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- Alerts ---------------------------------------------- */
.admin-alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.admin-alert.info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.admin-alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.admin-alert.warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.admin-alert.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.admin-alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.admin-alert-body { flex: 1; line-height: 1.5; }
.admin-alert strong { display: block; margin-bottom: 2px; }

/* --- Tables ---------------------------------------------- */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table th {
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  white-space: nowrap;
}
.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: middle;
}
.admin-table tbody tr:hover { background: #fafafa; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.doc-title-cell { font-weight: 600; color: #111827; max-width: 280px; }
.doc-title-cell small { display: block; font-size: 0.75rem; font-weight: 400; color: #9ca3af; margin-top: 2px; }

/* --- Role badge ------------------------------------------ */
.role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* --- Status badge ---------------------------------------- */
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
}
.status-active   { background: #d1fae5; color: #065f46; }
.status-inactive { background: #fee2e2; color: #991b1b; }

/* --- Modal ----------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  transform: translateY(12px);
  transition: transform 0.2s;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 800; color: #111827; }
.modal-close {
  background: #f3f4f6;
  border: none;
  border-radius: 6px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #6b7280;
}
.modal-close:hover { background: #e5e7eb; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}

/* --- Login page ------------------------------------------ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #2d0a0a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .fire { font-size: 3rem; }
.login-logo h1 { font-size: 1.05rem; font-weight: 800; color: #111827; margin: 8px 0 2px; }
.login-logo p  { font-size: 0.78rem; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; }

.login-tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 24px;
  gap: 0;
}
.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #9ca3af;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.login-tab.active { color: var(--red); border-bottom-color: var(--red); }

.login-section { display: none; }
.login-section.active { display: block; }

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.78rem;
  color: #9ca3af;
  line-height: 1.6;
}
.login-footer a { color: var(--red); }

/* --- Permissions table ----------------------------------- */
.perm-table { width: 100%; font-size: 0.82rem; border-collapse: collapse; }
.perm-table th, .perm-table td { padding: 8px 10px; border: 1px solid #e5e7eb; text-align: center; }
.perm-table th { background: #f9fafb; font-weight: 700; }
.perm-table td:first-child { text-align: left; font-weight: 600; }
.perm-yes { color: #059669; font-weight: 700; }
.perm-no  { color: #d1d5db; }
.perm-partial { color: #d97706; font-weight: 700; }

/* --- Activity log ---------------------------------------- */
.activity-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.85rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-msg { flex: 1; color: #374151; line-height: 1.4; }
.activity-time { color: #9ca3af; font-size: 0.75rem; white-space: nowrap; flex-shrink: 0; }

/* --- Password strength ----------------------------------- */
.pw-strength { height: 4px; border-radius: 2px; margin-top: 6px; background: #e5e7eb; }
.pw-strength-bar { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; width: 0; }

/* --- Responsive ------------------------------------------ */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 300;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 38px; height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
