﻿/* Admin panel styles â€” reuses the storefront color palette (:root vars in style.css) */

/* [hidden] must always win over display:flex/grid set below (equal specificity + source order bug) */
[hidden] {
  display: none !important;
}

.admin-body {
  min-height: 100vh;
  background: var(--bg);
}

/* ---------------- Login screen ---------------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeSlideIn 0.35s ease;
}

.login-card.shake {
  animation: shake 0.4s ease;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.login-card__logo {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.login-card__logo span {
  color: var(--primary);
}

.login-card h1 {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 8px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--gray);
}

.login-card input {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.login-card input:focus {
  border-color: var(--primary);
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 6px;
}

.password-toggle:hover {
  color: var(--text);
}

.caps-warning {
  color: #f5c542;
  font-size: 0.78rem;
}

.login-error {
  color: var(--primary);
  font-size: 0.85rem;
  text-align: center;
}

.back-link {
  text-align: center;
  color: var(--gray);
  font-size: 0.85rem;
  margin-top: 4px;
}

.back-link:hover {
  color: var(--primary);
}

/* ---------------- Buttons ---------------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--primary-dark);
}

.btn--danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gray);
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn--danger:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ---------------- Layout ---------------- */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.sidebar__logo {
  font-weight: 800;
  font-size: 1.05rem;
}

.sidebar__logo span {
  color: var(--primary);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--gray);
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.nav-btn:hover {
  color: var(--text);
  background: var(--panel-alt);
}

.nav-btn.active {
  background: var(--primary);
  color: #fff;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gray);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.logout-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.admin-main {
  padding: 32px 40px;
  max-width: 1000px;
  min-width: 0;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.logs-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0 12px;
}

.logs-kpi {
  background: linear-gradient(180deg, rgba(255, 59, 59, 0.07), rgba(22, 12, 12, 0.6));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.logs-kpi__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray);
}

.logs-kpi strong {
  font-size: 1.4rem;
  color: var(--text);
}

.logs-table {
  font-size: 0.8rem;
}

.logs-table td,
.logs-table th {
  white-space: nowrap;
}

.logs-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.logs-pager__btn {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.logs-pager__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.logs-pager__meta {
  color: var(--gray);
  font-size: 0.8rem;
}

.panel-enter {
  animation: fadeSlideIn 0.3s ease;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.panel-note {
  color: var(--gray);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

/* ---------------- Stat cards ---------------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--gray);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-card__value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
}

.chart-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-box h2 {
  font-size: 1rem;
  margin: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-range {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-alt);
}

.stats-range__btn {
  border: 0;
  border-radius: 6px;
  padding: 6px 9px;
  background: transparent;
  color: var(--gray);
  font-size: 0.75rem;
  cursor: pointer;
}

.stats-range__btn.active {
  background: var(--primary);
  color: #fff;
}

.chart-note {
  color: var(--gray);
  font-size: 0.78rem;
  margin: 0 0 12px;
}

.stats-footer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.clear-stats-btn {
  padding: 11px 20px;
  font-size: 0.88rem;
  font-weight: 800;
  background: transparent;
  border-color: rgba(255, 59, 59, 0.55);
}

.clear-stats-btn:hover,
.clear-stats-btn:focus-visible {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
}

.confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 3, 3, 0.78);
  backdrop-filter: blur(4px);
}

.confirm-modal__dialog {
  position: relative;
  width: min(100%, 420px);
  padding: 24px;
  background: var(--panel);
  border: 1px solid rgba(255, 59, 59, 0.55);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.confirm-modal__dialog h2 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.confirm-modal__dialog p {
  color: var(--gray);
  font-size: 0.85rem;
  line-height: 1.5;
}

.confirm-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.online-chart-box {
  margin-top: 24px;
}

.line-chart-wrap {
  overflow-x: auto;
  padding-bottom: 2px;
}

.line-chart {
  display: block;
  width: 100%;
  min-width: 680px;
  height: 260px;
}

.line-chart__grid line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 6;
}

.line-chart__area {
  fill: url(#onlineArea);
}

.line-chart__path {
  fill: none;
  stroke: var(--primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 8px rgba(255, 59, 59, 0.28));
  animation: drawLine 0.8s ease both;
}

.line-chart__point {
  fill: var(--panel);
  stroke: var(--primary);
  stroke-width: 3;
  cursor: pointer;
  transition: r 0.2s ease, fill 0.2s ease;
}

.line-chart__point:hover,
.line-chart__point:focus-visible {
  r: 6;
  fill: var(--primary);
  outline: none;
  filter: drop-shadow(0 0 7px rgba(255, 59, 59, 0.9));
}

.country-flag {
  display: inline-block;
  min-width: 1.35em;
}

.line-chart__labels text,
.line-chart__max,
.line-chart__zero {
  fill: var(--gray);
  font-size: 12px;
}

@keyframes drawLine {
  from { stroke-dasharray: 0 1800; }
  to { stroke-dasharray: 1800 0; }
}

.btn--compact {
  padding: 7px 10px;
  font-size: 0.75rem;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 8px;
}

.chart-bar {
  width: 100%;
  max-width: 36px;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  min-height: 3px;
  transition: height 0.5s ease;
}

.chart-bar--animate {
  animation: growUp 0.5s ease;
}

@keyframes growUp {
  from { height: 0 !important; }
}

.chart-col__value {
  font-size: 0.75rem;
  color: var(--gray);
}

.chart-col__label {
  font-size: 0.7rem;
  color: var(--gray);
}

/* ---------------- Cards / tables ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 1.05rem;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  text-align: left;
  color: var(--gray);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.empty-row td {
  color: var(--gray);
  text-align: center;
  padding: 18px;
}

.form-mode {
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.inline-form input,
.inline-form select,
.inline-form textarea {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  font-family: inherit;
  resize: vertical;
}

.inline-form input:focus,
.inline-form select:focus,
.inline-form textarea:focus {
  border-color: var(--primary);
}

.file-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.85rem;
  color: var(--gray);
  cursor: pointer;
}

.file-input:hover {
  border-color: var(--primary);
  color: var(--text);
}

.file-input input[type="file"] {
  display: none;
}

.photo-preview {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.table-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.save-msg {
  color: #4ade80;
  font-size: 0.85rem;
  margin-top: 10px;
}

@media (max-width: 800px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
  }
  .sidebar__logo {
    flex: 1 0 100%;
  }
  .sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
  }
  .nav-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  .logout-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  .admin-main {
    padding: 24px 20px;
  }
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }
  .chart-actions {
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .chart {
    overflow-x: auto;
    gap: 8px;
  }
  .chart-col {
    min-width: 28px;
  }
  .online-chart-box {
    margin-top: 18px;
  }
  .line-chart {
    min-width: 720px;
    height: 230px;
  }
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-form input,
  .inline-form select,
  .inline-form .file-input {
    max-width: none !important;
  }
  .data-table {
    font-size: 0.82rem;
  }
  .data-table td .btn {
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 0.78rem;
  }
}

/* ---------------- Toast ---------------- */
.admin-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c8f4d;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 300;
  box-shadow: var(--shadow);
}

.admin-toast--error {
  background: var(--primary-dark);
}

.admin-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

