/**
 * NearWeather Admin & Preferences Panel Styles
 * Uses the same design-token system from style.css
 */

/* ── Layout ─────────────────────────────────────────────── */
.content-admin,
.content-preferences {
  padding-bottom: var(--space-5);
}

/* ── Top Navigation Menu ────────────────────────────────── */
.content-menu {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.content-menu::-webkit-scrollbar { display: none; }

.page-menu {
  display: flex;
  gap: 0;
  padding: 0 var(--space-2);
}

.page-menu a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
  text-transform: capitalize;
}

.page-menu a:hover {
  color: var(--text-1);
  background: var(--surface-hover);
}

.page-menu a.menu-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  margin-bottom: var(--space-4);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-1);
  text-transform: capitalize;
}

/* ── Page Content Card ──────────────────────────────────── */
.page-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

/* ── Flash Messages (notification-box) ───────────────────── */
.notification-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-3);
  border-left: 4px solid;
}

.notification-box p {
  margin: 0;
  flex: 1;
}

.notification-close {
  width: 18px;
  height: 18px;
  cursor: pointer;
  opacity: 0.5;
  position: relative;
  flex-shrink: 0;
}

.notification-close::before,
.notification-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.notification-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.notification-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.notification-close:hover { opacity: 1; }

.notification-box-error {
  background: #fef2f2;
  border-left-color: var(--rose-500);
  color: #991b1b;
}
.dark .notification-box-error {
  background: rgba(244, 63, 94, 0.1);
  color: var(--rose-400);
}

.notification-box-success {
  background: #ecfdf5;
  border-left-color: var(--emerald-500);
  color: #065f46;
}
.dark .notification-box-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-400);
}

.notification-box-info {
  background: var(--blue-50);
  border-left-color: var(--blue-500);
  color: #1e40af;
}
.dark .notification-box-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--blue-400);
}

.notification-box-warning {
  background: #fffbeb;
  border-left-color: var(--amber-500);
  color: #92400e;
}
.dark .notification-box-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--amber-400);
}

/* ── Form Elements ──────────────────────────────────────── */
.page-content label,
.admin-login-card label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--space-1);
  margin-top: var(--space-3);
}

.page-content label:first-of-type,
.admin-login-card label:first-of-type {
  margin-top: 0;
}

.page-content input[type="text"],
.page-content input[type="password"],
.page-content input[type="email"],
.page-content input[type="number"],
.page-content input[type="url"],
.page-content input[type="file"],
.page-content select,
.page-content textarea,
.admin-login-card input[type="text"],
.admin-login-card input[type="password"],
.admin-login-card select {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-1);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.page-content input:focus,
.page-content select:focus,
.page-content textarea:focus,
.admin-login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.page-content textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-sans);
  line-height: 1.6;
}

.page-content input[type="file"] {
  padding: var(--space-2);
  cursor: pointer;
}

.page-content select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='%2394a3b8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  padding-right: calc(var(--space-3) + 24px);
}

/* ── Buttons ────────────────────────────────────────────── */
.page-content button[type="submit"],
.admin-login-card button[type="submit"],
.page-content .button,
button.btn-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: white;
  background: var(--primary);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
  margin-top: var(--space-4);
  text-decoration: none;
}

.page-content button[type="submit"]:hover,
.admin-login-card button[type="submit"]:hover,
.page-content .button:hover,
button.btn-admin:hover {
  background: var(--primary-h);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: white;
}

.button-create {
  background: var(--emerald-500) !important;
  margin-top: 0 !important;
  margin-bottom: var(--space-3);
}
.button-create:hover {
  background: #059669 !important;
}

.button-neutral {
  background: var(--slate-500) !important;
}
.button-neutral:hover {
  background: var(--slate-600) !important;
}

.button-delete {
  background: var(--rose-500) !important;
}
.button-delete:hover {
  background: #e11d48 !important;
}

.button-margin-left {
  margin-left: var(--space-2);
}

.float-left {
  float: left;
}

.page-content::after {
  content: '';
  display: table;
  clear: both;
}

/* ── List Container (Themes, Languages, Info Pages) ─────── */
.list-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.list-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.list-col-image {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

.list-col-image img {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  object-fit: cover;
}

.list-col-button {
  flex-shrink: 0;
}

.list-col-button button,
.list-col-button .button {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast);
  margin-top: 0;
  display: inline-flex;
  text-decoration: none;
}

.list-col-button button:hover,
.list-col-button .button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: none;
  box-shadow: none;
}

.list-col-button button:disabled {
  background: var(--emerald-500);
  color: white;
  border-color: var(--emerald-500);
  opacity: 0.7;
  cursor: default;
}

.list-col-content {
  flex: 1;
  min-width: 0;
}

.list-col-content div:first-child {
  font-size: var(--text-sm);
  color: var(--text-1);
}

.list-col-content div:first-child a {
  color: var(--primary);
}

.list-col-content div:last-child {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-col-content-full {
  flex: 1;
}

/* ── Dashboard Section Blocks ───────────────────────────── */
.content-admin .section {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
}

.content-admin .section strong {
  color: var(--text-2);
  min-width: 100px;
}

.content-admin .section a {
  color: var(--primary);
}

.content-admin .divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ── Remember Me Checkbox ───────────────────────────────── */
.remember-me {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.remember-me label {
  margin: 0 !important;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}

/* ── Admin Login Card ───────────────────────────────────── */
.admin-login-card {
  max-width: 400px;
  margin: var(--space-7) auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
}

.admin-login-header {
  text-align: center;
  margin-bottom: var(--space-4);
}

.admin-login-header h1 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: var(--space-1);
}

.admin-login-header p {
  font-size: var(--text-sm);
  color: var(--text-3);
}

.admin-login-card button[type="submit"] {
  width: 100%;
  justify-content: center;
  padding: var(--space-3);
  font-size: var(--text-base);
  border-radius: var(--r-full);
  margin-top: var(--space-4);
}

.admin-login-card .remember-me {
  margin-top: var(--space-3);
}

/* ── Admin Stats Grid (Dashboard) ───────────────────────── */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.admin-stat-card {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.admin-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.admin-stat-icon.blue { background: var(--blue-50); color: var(--blue-500); }
.admin-stat-icon.emerald { background: #ecfdf5; color: var(--emerald-500); }
.admin-stat-icon.violet { background: #f5f3ff; color: var(--violet-500); }
.admin-stat-icon.amber { background: #fffbeb; color: var(--amber-500); }
.dark .admin-stat-icon.blue { background: rgba(59,130,246,0.15); }
.dark .admin-stat-icon.emerald { background: rgba(16,185,129,0.15); }
.dark .admin-stat-icon.violet { background: rgba(139,92,246,0.15); }
.dark .admin-stat-icon.amber { background: rgba(245,158,11,0.15); }

.admin-stat-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  line-height: 1.2;
}

.admin-stat-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
}

/* ── Admin Data Table ───────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.admin-table thead th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-sunken);
  font-weight: 600;
  color: var(--text-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
}

.admin-table tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: var(--surface-hover);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table .actions {
  display: flex;
  gap: var(--space-1);
}

.admin-table .actions a,
.admin-table .actions button {
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur-fast);
  text-decoration: none;
  display: inline-flex;
  margin-top: 0;
}

.admin-table .actions a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.admin-table .actions .btn-danger:hover {
  background: var(--rose-500);
  border-color: var(--rose-500);
}

/* ── Status Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--r-full);
}

.badge-success {
  background: #ecfdf5;
  color: #065f46;
}
.dark .badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-400);
}

.badge-warning {
  background: #fffbeb;
  color: #92400e;
}
.dark .badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber-400);
}

.badge-neutral {
  background: var(--bg-sunken);
  color: var(--text-3);
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-3);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-2);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--space-1);
}

.empty-state-text {
  font-size: var(--text-sm);
}

/* ── Confirmation Dialog ────────────────────────────────── */
.confirm-box {
  background: #fef2f2;
  border: 1px solid var(--rose-400);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}
.dark .confirm-box {
  background: rgba(244, 63, 94, 0.08);
}

.confirm-box-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: var(--space-2);
}

.confirm-box-text {
  font-size: var(--text-sm);
  color: var(--text-2);
  margin-bottom: var(--space-3);
}

.confirm-box .button-delete,
.confirm-box .button-neutral {
  margin-top: 0 !important;
}

/* ── Form Groups ────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

@media (max-width: 639px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-help {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: var(--space-1);
}

/* ── Coordinates Table Extras ───────────────────────────── */
.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Responsive Adjustments ─────────────────────────────── */
@media (max-width: 639px) {
  .page-content {
    padding: var(--space-3);
  }

  .list-row {
    flex-wrap: wrap;
  }

  .list-col-content div:last-child {
    white-space: normal;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
  }

  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Info Pages Body Content ────────────────────────────── */
.content-info {
  padding-bottom: var(--space-5);
}

.info-page-body {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.8;
}

.info-page-body h1,
.info-page-body h2,
.info-page-body h3,
.info-page-body h4 {
  color: var(--text-1);
  margin: var(--space-4) 0 var(--space-2);
  line-height: 1.3;
}

.info-page-body h1 { font-size: var(--text-xl); font-weight: 800; }
.info-page-body h2 { font-size: var(--text-lg); font-weight: 700; }
.info-page-body h3 { font-size: var(--text-base); font-weight: 600; }
.info-page-body h4 { font-size: var(--text-sm); font-weight: 600; }

.info-page-body h1:first-child,
.info-page-body h2:first-child,
.info-page-body h3:first-child {
  margin-top: 0;
}

.info-page-body p {
  margin-bottom: var(--space-3);
}

.info-page-body a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.info-page-body a:hover {
  color: var(--primary-h);
}

.info-page-body ul,
.info-page-body ol {
  padding-left: 1.5em;
  margin-bottom: var(--space-3);
}

.info-page-body ul { list-style: disc; }
.info-page-body ol { list-style: decimal; }

.info-page-body li {
  margin-bottom: var(--space-1);
}

.info-page-body li::marker {
  color: var(--text-3);
}

.info-page-body strong {
  font-weight: 600;
  color: var(--text-1);
}

.info-page-body em {
  font-style: italic;
}

.info-page-body blockquote {
  border-left: 3px solid var(--primary);
  padding: var(--space-2) var(--space-4);
  margin: var(--space-3) 0;
  background: var(--bg-sunken);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text-2);
  font-style: italic;
}

.info-page-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
}

.info-page-body th,
.info-page-body td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  text-align: left;
}

.info-page-body th {
  background: var(--bg-sunken);
  font-weight: 600;
  color: var(--text-1);
}

.info-page-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-md);
  margin: var(--space-3) 0;
}

.info-page-body hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

.info-page-body code {
  background: var(--bg-sunken);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  color: var(--text-1);
}

.info-page-body pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-3);
  overflow-x: auto;
  margin: var(--space-3) 0;
}

.info-page-body pre code {
  background: none;
  padding: 0;
}