/* ═══════════════════════════════════════════
   SOTTOLIVELLO — Admin Panel CSS
   ═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --verde: #23412F; --verde-l: #3B6650; --senape: #C68A33;
  --carta: #F7F1E2; --bordo: #E3D9BE; --grigio: #756F5E;
  --font-d: 'Playfair Display', Georgia, serif;
  --font-b: 'Source Sans 3', system-ui, sans-serif;
}
body { font-family: var(--font-b); background: #F0F4FA; color: #22271F; }
a { text-decoration: none; color: inherit; }

/* LOGIN */
.admin-login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--verde);
}
.login-box {
  background: #fff; border-radius: 12px;
  padding: 2.5rem 2rem; width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  text-align: center;
}
.login-logo { height: 60px; margin: 0 auto 1.2rem; }
.login-box h1 { font-family: var(--font-d); font-size: 1.4rem; color: var(--verde); margin-bottom: 1.5rem; }
.login-box label { display: block; text-align: left; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.login-box input {
  width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--bordo);
  border-radius: 6px; font-size: .95rem; margin-bottom: 1rem;
  transition: border-color .2s;
}
.login-box input:focus { outline: none; border-color: var(--verde); }
.login-back { display: block; margin-top: 1rem; font-size: .85rem; color: var(--grigio); }

/* LAYOUT */
.admin-body { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 220px; background: var(--verde); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.2rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-family: var(--font-d); font-size: 1rem; color: #fff;
}
.sidebar-logo img { filter: invert(1); }
.sidebar-nav { display: flex; flex-direction: column; padding: .8rem 0; flex: 1; }
.sidebar-nav a {
  padding: .65rem 1.3rem; font-size: .9rem;
  color: rgba(255,255,255,.75); transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; }
.sidebar-logout { margin-top: auto; color: rgba(255,100,100,.8) !important; }

.admin-main { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }
.admin-topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; border-bottom: 2px solid var(--bordo); padding-bottom: 1rem;
}
.admin-topbar h1 { font-family: var(--font-d); font-size: 1.5rem; color: var(--verde); }

/* BUTTONS */
.btn-primary {
  background: var(--verde); color: #fff; border: none; cursor: pointer;
  padding: .6rem 1.3rem; border-radius: 6px; font-size: .9rem; font-weight: 600;
  transition: background .2s; display: inline-block;
}
.btn-primary:hover { background: var(--verde-l); }
.btn-secondary {
  background: #fff; color: var(--verde); border: 1.5px solid var(--bordo);
  cursor: pointer; padding: .55rem 1.2rem; border-radius: 6px;
  font-size: .88rem; font-weight: 600; transition: background .2s; display: inline-block;
}
.btn-secondary:hover { background: var(--carta); }
.btn-full { width: 100%; text-align: center; }

/* TABLE */
.admin-table-wrap { background: #fff; border-radius: 8px; border: 1px solid var(--bordo); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th {
  background: var(--carta); padding: .75rem 1rem; text-align: left;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--grigio); border-bottom: 1px solid var(--bordo);
}
.admin-table td { padding: .8rem 1rem; border-bottom: 1px solid #f0eee8; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fafaf8; }
.td-titolo { max-width: 320px; }
.td-empty { text-align: center; color: var(--grigio); padding: 2rem !important; }
.td-actions { white-space: nowrap; }
.td-actions > * { display: inline-block !important; margin-right: .35rem; vertical-align: middle; }

.badge { font-size: .74rem; font-weight: 700; padding: .2rem .55rem; border-radius: 20px; }
.badge-pub   { background: #d4edda; color: #155724; }
.badge-bozza { background: #fff3cd; color: #856404; }

.btn-sm {
  font-size: .78rem; font-weight: 600; padding: .3rem .7rem;
  border-radius: 5px; border: none; cursor: pointer; transition: opacity .2s;
}
.btn-sm:hover { opacity: .8; }
.btn-view      { background: #e8f0fe; color: #1a56db; }
.btn-edit      { background: #e8f4fd; color: #0c638c; }
.btn-del       { background: #fde8e8; color: #9b1c1c; }
.btn-copy-link { background: #2471a3; color: #fff; }

/* Checkbox condiviso */
.td-condiviso { text-align: center; width: 80px; }
.chk-condiviso-wrap { cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
.chk-condiviso { width: 16px; height: 16px; accent-color: #1a7a4a; cursor: pointer; }
.chk-condiviso-label { font-size: .85rem; min-width: 20px; }
.btn-copy-link:hover { background: #1a5276; opacity: 1; }
.btn-copy-link.copied { background: #1a7a4a; }

/* EDITOR FORM */
.editor-form { }
.editor-layout {
  display: grid; grid-template-columns: 1fr 300px;
  gap: 1.5rem; align-items: start;
}
.editor-main { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.editor-sidebar { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }

.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--grigio); }
.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field input[type="url"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%; padding: .6rem .85rem;
  border: 1.5px solid var(--bordo); border-radius: 6px;
  font-size: .95rem; font-family: var(--font-b);
  background: #fff; transition: border-color .2s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--verde);
}
.field textarea { resize: vertical; }
.field small { display: block; font-size: .78rem; color: var(--grigio); margin-top: .25rem; }

.field-box {
  background: #fff; border: 1px solid var(--bordo);
  border-radius: 8px; padding: 1.1rem;
}
.field-box h3 { font-family: var(--font-d); font-size: .95rem; color: var(--verde); margin-bottom: .8rem; border-bottom: 1px solid var(--bordo); padding-bottom: .4rem; }
.field-box .field { margin-bottom: .8rem; }
.field-box .field:last-child { margin-bottom: 0; }
.field-box select { width: 100%; }
.field-box small { font-size: .78rem; color: var(--grigio); display: block; margin-top: .3rem; }

.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; margin-bottom: .8rem; }
.checkbox-label input { width: auto; }

.file-label {
  display: inline-block; padding: .5rem 1rem; border-radius: 6px;
  background: var(--carta); border: 1.5px dashed var(--bordo);
  cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--verde);
  transition: background .2s; margin-bottom: .5rem;
}
.file-label:hover { background: #eee8da; }
.file-label input { display: none; }

.current-img { margin-bottom: .6rem; }
.current-img img { border-radius: 5px; max-height: 100px; object-fit: cover; border: 1px solid var(--bordo); }
.current-img small { font-size: .75rem; color: var(--grigio); }

.img-preview img { max-width: 100%; border-radius: 5px; margin-top: .4rem; border: 1px solid var(--bordo); }

/* Quill override */
.ql-container { min-height: 360px; font-family: var(--font-b); font-size: 1rem; }
.ql-toolbar { border-color: var(--bordo) !important; }
.ql-container { border-color: var(--bordo) !important; }
.ql-toolbar.ql-snow { display: flex; flex-wrap: wrap; }
.ql-toolbar.ql-snow .ql-formats { margin-right: 8px !important; }
body { overflow-x: hidden; }

/* SETTINGS */
.settings-form { max-width: 680px; }
.settings-section { background: #fff; border: 1px solid var(--bordo); border-radius: 8px; padding: 1.4rem; margin-bottom: 1.4rem; }
.settings-section h2 { font-family: var(--font-d); font-size: 1.05rem; color: var(--verde); margin-bottom: 1rem; border-bottom: 1px solid var(--bordo); padding-bottom: .4rem; }
.settings-section .field { margin-bottom: .9rem; }
.settings-hint { font-size: .82rem; color: var(--grigio); margin-bottom: .8rem; }

/* FLASH */
.flash { padding: .7rem 1.1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.flash-success { background: #d4edda; color: #155724; }
.flash-error   { background: #f8d7da; color: #721c24; }
.flash-info    { background: #d1ecf1; color: #0c5460; }

/* MENU (Admin → Menu) */
.menu-hint { max-width: 680px; }
.menu-section-title {
  font-family: var(--font-d); font-size: 1.15rem; color: var(--verde);
  max-width: 680px; margin-top: 1rem; padding-top: 1.4rem;
  border-top: 1px solid var(--bordo);
}
.menu-descrizioni-form { max-width: 680px; display: flex; flex-direction: column; gap: 1rem; }
.menu-descrizioni-form .field-box { margin-bottom: 0; }
.menu-descrizioni-form textarea { width: 100%; }
.menu-list { display: flex; flex-direction: column; gap: 1rem; max-width: 680px; margin-bottom: 2rem; }
.menu-item-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .8rem; padding-bottom: .6rem; border-bottom: 1px solid var(--bordo);
}
.menu-item-tipo { font-size: .8rem; font-weight: 700; color: var(--grigio); text-transform: uppercase; letter-spacing: .04em; }
.menu-item-order { display: flex; gap: .4rem; }
.inline-form { display: inline-block; }
.menu-item-order .btn-sm:disabled { opacity: .35; cursor: not-allowed; }
.menu-item-form .field:last-of-type { margin-bottom: .8rem; }

.menu-add-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; max-width: 680px;
}

@media (max-width: 640px) {
  .menu-add-grid { grid-template-columns: 1fr; }
}

.admin-mobile-toggle { display: none; }
.admin-sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .editor-layout { grid-template-columns: 1fr; }
  .admin-main { padding: 1rem; }

  .admin-mobile-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0; margin-right: .8rem;
    background: var(--verde); color: #fff; border: none; border-radius: 8px;
    font-size: 1.3rem; cursor: pointer;
  }
  .admin-topbar { flex-wrap: wrap; row-gap: .8rem; }

  .admin-sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .admin-sidebar.open { transform: translateX(0); }

  .admin-sidebar-backdrop.open {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 90;
  }
}
