/* ==========================================================================
   LE DIMORE DEL SOLE - Pannello di Controllo Admin (admin.css)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --adm-primary: #7B243B;
  --adm-primary-dark: #561627;
  --adm-accent: #D49B38;
  --adm-bg: #F4F5F7;
  --adm-card: #FFFFFF;
  --adm-sidebar: #1B1518;
  --adm-text: #1D2026;
  --adm-muted: #646B78;
  --adm-border: #E3E6EC;
  --adm-danger: #D92D20;
  --adm-success: #0F7647;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--adm-bg);
  color: var(--adm-text);
  line-height: 1.55;
  min-height: 100vh;
}

button, input, select, textarea {
  font-family: inherit;
}

/* ==================== LOGIN SCREEN ==================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #93304B 0%, #3F101E 55%, #1A1215 100%);
}

.login-card {
  background: #fff;
  border-radius: 22px;
  max-width: 430px;
  width: 100%;
  padding: 40px 36px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.login-card img {
  height: 76px;
  margin: 0 auto 18px;
  object-fit: contain;
}

.login-card h1 {
  font-size: 1.45rem;
  margin-bottom: 6px;
}

.login-card p {
  font-size: 0.9rem;
  color: var(--adm-muted);
  margin-bottom: 24px;
}

/* ==================== ADMIN SHELL ==================== */
.admin-shell {
  display: none;
  min-height: 100vh;
}

.admin-shell.authenticated {
  display: grid;
  grid-template-columns: 272px 1fr;
}

.sidebar {
  background: var(--adm-sidebar);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand img {
  height: 44px;
  width: auto;
}

.sidebar-brand div strong {
  display: block;
  font-size: 0.96rem;
  color: #fff;
}

.sidebar-brand div span {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.55);
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.side-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.89rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.side-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.side-btn.active {
  background: var(--adm-primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(123, 36, 59, 0.4);
}

.side-badge {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.side-badge.unread {
  background: #F59E0B;
  color: #111;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==================== MAIN WORKSPACE ==================== */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.workspace-topbar {
  background: #fff;
  border-bottom: 1px solid var(--adm-border);
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.workspace-topbar h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-body {
  padding: 28px 30px 64px;
  max-width: 1220px;
  width: 100%;
}

.adm-tab {
  display: none;
}

.adm-tab.active {
  display: block;
}

/* ==================== CARDS, FORMS & BUTTONS ==================== */
.card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.03);
}

.card-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 0.86rem;
  color: var(--adm-muted);
  margin-bottom: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-box {
  background: #fff;
  border: 1px solid var(--adm-border);
  border-radius: 14px;
  padding: 20px;
}

.kpi-box .num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--adm-primary);
  line-height: 1.1;
}

.kpi-box .lbl {
  font-size: 0.84rem;
  color: var(--adm-muted);
  margin-top: 4px;
}

.field {
  margin-bottom: 15px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #344054;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field input[type="tel"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--adm-border);
  font-size: 0.92rem;
  background: #FAFBFC;
  color: var(--adm-text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--adm-primary);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--adm-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--adm-primary-dark);
}

.btn-success {
  background: var(--adm-success);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  border-color: var(--adm-border);
  color: var(--adm-text);
}

.btn-secondary:hover {
  background: #F4F5F7;
}

.btn-danger {
  background: #FEF3F2;
  border-color: #FECDCA;
  color: var(--adm-danger);
}

.btn-danger:hover {
  background: var(--adm-danger);
  color: #fff;
}

.btn-warning {
  background: #FFFBEB;
  border-color: #FDE68A;
  color: #B45309;
}

.btn-warning:hover {
  background: #F59E0B;
  border-color: #F59E0B;
  color: #111;
}

.btn-activate {
  background: #ECFDF3;
  border-color: #A6F4C5;
  color: #067647;
}

.btn-activate:hover {
  background: #0F7647;
  border-color: #0F7647;
  color: #fff;
}

/* ==================== ANALYTICS CHARTS & TABLES ==================== */
.live-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #12B76A;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.22);
  animation: pulseLive 1.8s infinite;
}

@keyframes pulseLive {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.75; }
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 170px;
  padding-top: 18px;
  border-bottom: 1px solid var(--adm-border);
}

.bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.bar-fill {
  width: 100%;
  max-width: 34px;
  background: linear-gradient(180deg, var(--adm-primary) 0%, var(--adm-primary-dark) 100%);
  border-radius: 6px 6px 0 0;
  min-height: 3px;
  transition: height 0.3s ease;
}

.bar-val {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--adm-text);
  margin-bottom: 4px;
}

.bar-lbl {
  font-size: 0.68rem;
  color: var(--adm-muted);
  margin-top: 6px;
  white-space: nowrap;
}

.stat-rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-rank-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-rank-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-rank-track {
  height: 7px;
  background: #EDF0F4;
  border-radius: 99px;
  overflow: hidden;
}

.stat-rank-bar {
  height: 100%;
  background: var(--adm-primary);
  border-radius: 99px;
}

.visitors-table-wrap {
  overflow-x: auto;
}

.visitors-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.visitors-table th {
  text-align: left;
  padding: 10px 12px;
  background: #F8F9FB;
  border-bottom: 1px solid var(--adm-border);
  color: var(--adm-muted);
  font-weight: 700;
  white-space: nowrap;
}

.visitors-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--adm-border);
  vertical-align: middle;
}

.item-row.suspended-row {
  background: #FAFAFB;
  border-style: dashed;
  opacity: 0.82;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* ==================== PRESET SWATCHES ==================== */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.preset-card {
  border: 2px solid var(--adm-border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  background: #fff;
  transition: all 0.2s ease;
}

.preset-card:hover {
  border-color: #999;
}

.preset-card.selected {
  border-color: var(--adm-primary);
  box-shadow: 0 0 0 3px rgba(123, 36, 59, 0.14);
}

.swatch-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.swatch-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
}

/* ==================== ITEM ROWS & LISTS ==================== */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--adm-border);
  border-radius: 12px;
}

.item-thumb {
  width: 76px;
  height: 58px;
  border-radius: 9px;
  object-fit: cover;
  background: #eee;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-info h4 {
  font-size: 0.98rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-info p {
  font-size: 0.82rem;
  color: var(--adm-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.upload-preview-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px dashed #C5CBD6;
  border-radius: 12px;
  background: #FAFBFC;
}

.upload-preview-box img {
  height: 68px;
  max-width: 150px;
  object-fit: contain;
  border-radius: 8px;
  background: #eee;
  padding: 4px;
}

/* ==================== MODAL EDITOR ==================== */
.adm-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(15, 20, 28, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.adm-modal-backdrop.open {
  display: flex;
}

.adm-modal {
  background: #fff;
  border-radius: 18px;
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
}

.adm-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--adm-border);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  padding: 14px 22px;
  border-radius: 12px;
  background: #1B1518;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.28s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: #0F7647;
}

.toast.error {
  background: #C92A2A;
}

.mob-sidebar-btn {
  display: none;
}

@media (max-width: 920px) {
  .admin-shell.authenticated {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: -285px;
    top: 0;
    bottom: 0;
    width: 272px;
    z-index: 1200;
    transition: left 0.25s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .mob-sidebar-btn {
    display: inline-flex;
  }
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
  .item-row {
    flex-wrap: wrap;
  }
}
