/* ═══════════════════════════════════════
   THOT — base.css
   Variables, reset, typography, utilities
═══════════════════════════════════════ */

:root {
  /* Palette — Carta e inchiostro */
  --bg:          #F5F2EC;
  --surface:     #FDFAF5;
  --surface-2:   #F8F5EF;
  --border:      #E2DDD4;
  --border-lt:   #EDE9E2;
  --text:        #2A2520;
  --text-2:      #4A4540;
  --muted:       #9A9088;
  --muted-lt:    #C0B8B0;
  --accent:      #3A7A8C;
  --accent-lt:   #EAF3F5;
  --accent-md:   #C8E2E8;
  --accent-dk:   #2A5A6A;

  /* Semantic */
  --success:     #2E7D45;
  --success-lt:  #EAF5EE;
  --success-bd:  #B8DFC3;
  --warn:        #8A6D20;
  --warn-lt:     #FFF8EA;
  --warn-bd:     #F0DFA0;
  --danger:      #C0533A;
  --danger-lt:   #FEE8E4;
  --danger-bd:   #F0C0B4;

  /* Priority colors */
  --prio-high-bg:  #FEE8E4;
  --prio-high-fg:  #C0533A;
  --prio-med-bg:   #FFF8EA;
  --prio-med-fg:   #8A6D20;
  --prio-low-bg:   #EAF3F5;
  --prio-low-fg:   #3A7A8C;

  /* Typography */
  --font-serif:  'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans:   'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:   'DM Mono', 'Courier New', monospace;

  /* Sizing */
  --sidebar-w:   264px;
  --header-h:    54px;
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   14px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(42,37,32,.06), 0 2px 8px rgba(42,37,32,.04);
  --shadow:      0 1px 4px rgba(42,37,32,.08), 0 4px 16px rgba(42,37,32,.05);
  --shadow-lg:   0 4px 12px rgba(42,37,32,.10), 0 12px 40px rgba(42,37,32,.08);
  --shadow-modal:0 8px 32px rgba(42,37,32,.16), 0 2px 8px rgba(42,37,32,.08);

  /* Transitions */
  --t-fast:   .12s ease;
  --t-base:   .18s ease;
  --t-slow:   .28s cubic-bezier(.4,0,.2,1);
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* ── TYPOGRAPHY ── */
.serif { font-family: var(--font-serif); }
.mono  { font-family: var(--font-mono); }

h1, h2, h3, h4 { line-height: 1.25; }

.page-title-input {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.15;
  color: var(--text);
  border: none;
  background: none;
  width: 100%;
  outline: none;
  resize: none;
  overflow: hidden;
  display: block;
}
.page-title-input::placeholder { color: var(--border); }

/* ── BUTTONS ── */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; }

.btn-icon-sm { width: 24px; height: 24px; }
.btn-icon-sm svg { width: 13px; height: 13px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-dk); }
.btn-primary:active { transform: scale(.98); }
.btn-primary svg { width: 15px; height: 15px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 400;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--muted-lt); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-lt); color: var(--danger); }

/* ── FORM ELEMENTS ── */
.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-lt);
}
.input::placeholder { color: var(--muted-lt); }

.input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

/* ── BADGES / PILLS ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--accent-lt);
  color: var(--accent);
  letter-spacing: .02em;
  cursor: default;
  transition: background var(--t-fast);
}
.tag:hover { background: var(--accent-md); }
.tag.removable { cursor: pointer; }
.tag svg { width: 10px; height: 10px; opacity: .6; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.status-pill::before {
  content: '●';
  font-size: 8px;
}
.status-pill[data-color="green"]  { background: var(--success-lt); color: var(--success); border-color: var(--success-bd); }
.status-pill[data-color="yellow"] { background: var(--warn-lt);    color: var(--warn);    border-color: var(--warn-bd); }
.status-pill[data-color="red"]    { background: var(--danger-lt);  color: var(--danger);  border-color: var(--danger-bd); }
.status-pill[data-color="blue"]   { background: var(--accent-lt);  color: var(--accent);  border-color: var(--accent-md); }

/* ── DIVIDERS ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-lt); }

/* ── TOAST NOTIFICATIONS ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 400;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn .2s ease forwards;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: #8A6D20; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(4px); }
}

/* ── MODAL ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42,37,32,.35);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn var(--t-fast);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  animation: modalIn var(--t-base);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-style: italic;
  font-weight: 400;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── DROPDOWN MENU ── */
.dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  min-width: 180px;
  padding: 4px;
  animation: fadeIn var(--t-fast);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-fast);
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item svg   { width: 15px; height: 15px; color: var(--muted); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger svg { color: var(--danger); }
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── UTILITIES ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.flex-1      { flex: 1; }
.min-w-0     { min-width: 0; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-sm     { font-size: 12.5px; }
.text-xs     { font-size: 11px; }
.font-medium { font-weight: 500; }
.mt-1        { margin-top: 4px; }
.mt-2        { margin-top: 8px; }
.mt-3        { margin-top: 12px; }
.mt-4        { margin-top: 16px; }
.mb-2        { margin-bottom: 8px; }
.mb-3        { margin-bottom: 12px; }
.w-full      { width: 100%; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── EMPTY STATES ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
  color: var(--muted);
}
.empty-state-icon { font-size: 40px; opacity: .5; }
.empty-state-title { font-size: 16px; font-weight: 500; color: var(--text-2); }
.empty-state-desc  { font-size: 13.5px; max-width: 300px; line-height: 1.6; }

/* ── LOADING ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--border-lt) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
