/* ============================================================
   Adozioni Libri — Gestione Admin — style.css
   ============================================================ */

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

:root {
  --sb-bg: #1a1f36;
  --sb-hover: #252d4a;
  --sb-active: #4361ee;
  --sb-active-bg: rgba(67,97,238,.15);
  --sb-text: #a3aed0;
  --sb-text-active: #fff;
  --sb-section: #4a5568;
  --sb-width: 240px;
  --header-h: 56px;
  --color-primary: #4361ee;
  --color-primary-dark: #3451c7;
  --color-danger: #e53e3e;
  --color-success: #38a169;
  --color-warning: #d69e2e;
  --color-bg: #f0f4f8;
  --color-surface: #fff;
  --color-border: #e2e8f0;
  --color-text: #1a202c;
  --color-text-muted: #718096;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1);
  --shadow: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--color-bg); min-height: 100vh; }

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sb-width);
  min-height: 100vh;
  background: var(--sb-bg);
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--sb-active);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon .material-symbols-outlined { color: #fff; font-size: 20px; }
.sidebar-logo .logo-text {
  font-size: 14px; font-weight: 700;
  color: #fff; line-height: 1.2;
}
.sidebar-logo .logo-sub { font-size: 11px; color: var(--sb-text); }

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-section {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sb-section);
}
.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item a:hover {
  background: var(--sb-hover);
  color: #fff;
  text-decoration: none;
}
.nav-item a.active {
  background: var(--sb-active-bg);
  color: var(--sb-text-active);
  border-left-color: var(--sb-active);
  font-weight: 600;
}
.nav-item a .material-symbols-outlined {
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  color: var(--sb-section);
  text-align: center;
  flex-shrink: 0;
}

/* --- MAIN CONTENT --- */
.main-wrap {
  margin-left: var(--sb-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.top-bar {
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.top-bar-left { display: flex; align-items: center; gap: 8px; }
.breadcrumb-custom {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--color-text-muted);
}
.breadcrumb-custom a { color: var(--color-primary); text-decoration: none; }
.breadcrumb-custom a:hover { text-decoration: underline; }
.breadcrumb-custom .sep { opacity: .4; }
.breadcrumb-custom .current { color: var(--color-text); font-weight: 500; }
.top-bar-right { display: flex; align-items: center; gap: 16px; }
.user-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--color-text-muted);
}
.user-badge .material-symbols-outlined { font-size: 18px; }
.btn-logout {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn-logout:hover { background: #fff0f0; color: var(--color-danger); border-color: var(--color-danger); text-decoration: none; }
.btn-logout .material-symbols-outlined { font-size: 15px; }

.content-area { padding: 24px; flex: 1; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title-text { font-size: 20px; font-weight: 700; color: var(--color-text); }
.page-title-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

/* --- FILTER BAR --- */
.filter-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
}
.filter-card .filter-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.filter-card .form-control,
.filter-card input[type="text"],
.filter-card input[type="number"],
.filter-card select {
  height: 34px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--color-text);
  background: #fff;
  transition: border .15s;
  width: 100%;
}
.filter-card input:focus,
.filter-card select:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

/* --- TABLE CARD --- */
.table-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.table-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: #fafafa;
}
.table-card-title { font-size: 14px; font-weight: 600; color: var(--color-text); }
.record-count { font-size: 12px; color: var(--color-text-muted); }

/* --- TABLE --- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table thead th:hover { background: #f1f5f9; color: var(--color-text); }
.data-table thead th.sorted { color: var(--color-primary); }
.data-table thead th .sort-arrow { font-size: 14px; vertical-align: middle; opacity: .5; }
.data-table thead th.sorted .sort-arrow { opacity: 1; }
.data-table tbody tr { border-bottom: 1px solid var(--color-border); transition: background .1s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody td { padding: 10px 12px; font-size: 13px; color: var(--color-text); }
.data-table tbody td.muted { color: var(--color-text-muted); font-size: 12px; }
.no-data td { text-align: center; padding: 40px; color: var(--color-text-muted); font-size: 14px; }

/* --- ACTION BUTTONS --- */
.btn-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; border-radius: 6px;
  cursor: pointer; transition: all .15s;
  font-size: 0;
}
.btn-action .material-symbols-outlined { font-size: 16px; }
.btn-edit { background: #eff6ff; color: #2563eb; }
.btn-edit:hover { background: #dbeafe; }
.btn-delete { background: #fff5f5; color: #e53e3e; margin-left: 4px; }
.btn-delete:hover { background: #fed7d7; }

/* --- PRIMARY BUTTON --- */
.btn-primary-custom {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary-custom:hover { background: var(--color-primary-dark); color: #fff; text-decoration: none; }
.btn-primary-custom .material-symbols-outlined { font-size: 16px; }
.btn-primary-custom:disabled { opacity: .7; cursor: not-allowed; }

.btn-secondary-custom {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn-secondary-custom:hover { background: #f8fafc; }
.btn-secondary-custom .material-symbols-outlined { font-size: 16px; }

/* --- EXPORT BUTTONS --- */
.btn-export {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: #fff;
  color: #2d7d46;
  border: 1.5px solid #2d7d46;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.btn-export:hover { background: #f0faf4; }
.btn-export .material-symbols-outlined { font-size: 16px; }
.btn-export-purged { color: #805900; border-color: #805900; }
.btn-export-purged:hover { background: #fdf8ed; }

/* --- PAGER --- */
.pager-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: #fafafa;
  flex-wrap: wrap;
  gap: 8px;
}
.page-size-box { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-muted); }
.page-size-box select {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  background: #fff;
  height: 28px;
}
.pagination-box { display: flex; gap: 4px; }
.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: var(--color-text);
  transition: all .15s;
  text-decoration: none;
}
.page-btn:hover, .page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); text-decoration: none; }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* --- MODAL --- */
.modal-content { border: none; border-radius: 12px; box-shadow: var(--shadow-lg); }
.modal-header {
  background: #fafafa;
  border-bottom: 1px solid var(--color-border);
  border-radius: 12px 12px 0 0;
  padding: 16px 20px;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--color-text); }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--color-border); padding: 12px 20px; }
.form-section {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.form-section-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 0; }
.form-col { flex: 1; min-width: 120px; }
.form-col.w2 { flex: 2; }
.form-col.w3 { flex: 3; }
label.field-label {
  display: block;
  font-size: 11px; font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
input.field-input, select.field-input, textarea.field-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  background: #fff;
  transition: border .15s;
  font-family: inherit;
}
input.field-input:focus, select.field-input:focus, textarea.field-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(67,97,238,.12);
}

/* --- CONFIRM DIALOG --- */
dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow-lg);
  min-width: 360px;
  max-width: 440px;
}
dialog::backdrop { background: rgba(0,0,0,.5); }
.dlg-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--color-border);
}
.dlg-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff5f5;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dlg-icon .material-symbols-outlined { color: var(--color-danger); font-size: 20px; }
.dlg-title { font-size: 15px; font-weight: 700; color: var(--color-text); }
.dlg-subtitle { font-size: 13px; color: var(--color-text-muted); }
.dlg-body { padding: 16px 20px 8px; font-size: 14px; color: var(--color-text-muted); }
.dlg-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px 16px;
}
.btn-dlg-cancel {
  padding: 7px 16px; border: 1px solid var(--color-border);
  border-radius: 7px; background: #fff; font-size: 13px;
  cursor: pointer; color: var(--color-text);
  font-family: inherit;
}
.btn-dlg-cancel:hover { background: #f8fafc; }
.btn-dlg-confirm {
  padding: 7px 16px; border: none;
  border-radius: 7px; background: var(--color-danger);
  color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-dlg-confirm:hover { background: #c53030; }

/* --- TOAST --- */
#appToast { position: fixed; bottom: 24px; right: 24px; z-index: 9999; }
@keyframes slideUp { from { opacity:0; transform:translateY(12px) } to { opacity:1; transform:none } }
.toast-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideUp .25s ease;
  min-width: 260px; max-width: 380px;
  color: #fff;
}
.toast-item .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }
.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-warning { background: var(--color-warning); }
.toast-info    { background: #4361ee; }

/* --- IMPORT PAGE --- */
.import-step {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.step-number {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.step-number.done { background: var(--color-success); }
.step-content h6 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.step-content p { font-size: 12px; color: var(--color-text-muted); margin: 0; }
.progress-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.progress-bar-track {
  height: 8px; background: #e2e8f0;
  border-radius: 4px; margin-bottom: 16px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--color-primary);
  border-radius: 4px; transition: width .3s;
}
.stat-row { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.stat-box {
  flex: 1; text-align: center;
  padding: 16px; border-radius: 8px;
  background: #f8fafc; border: 1px solid var(--color-border);
  min-width: 100px;
}
.stat-box .stat-num { font-size: 28px; font-weight: 700; }
.stat-box .stat-label { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.stat-box.ok .stat-num { color: var(--color-success); }
.stat-box.err .stat-num { color: var(--color-danger); }
.stat-box.tot .stat-num { color: var(--color-primary); }
.file-drop {
  border: 2px dashed var(--color-border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafafa;
}
.file-drop:hover, .file-drop.drag-over {
  border-color: var(--color-primary);
  background: rgba(67,97,238,.04);
}
.file-drop .material-symbols-outlined { font-size: 40px; color: var(--color-text-muted); margin-bottom: 8px; display: block; }
.file-drop h6 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.file-drop p { font-size: 12px; color: var(--color-text-muted); margin: 0; }

/* Bootstrap gap helpers */
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* Responsive */
@media(max-width:768px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrap { margin-left: 0; }
  .content-area { padding: 16px; }
}
