/* ============================================================
   styles.css — matching the React app design tokens
   ============================================================ */

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

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

:root {
  --font-inter: 'Inter', sans-serif;
  --background: hsl(220,30%,96%);
  --foreground: hsl(222,47%,11%);
  --card: hsl(220,30%,98%);
  --card-foreground: hsl(222,47%,11%);
  --primary: hsl(217,91%,60%);
  --primary-fg: hsl(0,0%,100%);
  --secondary: hsl(220,20%,92%);
  --secondary-fg: hsl(222,47%,11%);
  --muted: hsl(220,20%,94%);
  --muted-fg: hsl(220,9%,46%);
  --accent: hsl(220,20%,90%);
  --border: hsl(220,13%,88%);
  --input: hsl(220,13%,88%);
  --destructive: hsl(0,84%,60%);
  --destructive-fg: #fff;
  --ring: hsl(217,91%,60%);
  --sidebar-bg: hsl(220,30%,97%);
  --sidebar-border: hsl(220,13%,88%);
  --radius: 0.625rem;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

/* ─── Dark mode ──────────────────────────────────────────── */
.dark {
  --background: hsl(222,47%,7%);
  --foreground: hsl(213,31%,91%);
  --card: hsl(217,33%,10%);
  --card-foreground: hsl(213,31%,91%);
  --primary: hsl(217,91%,60%);
  --primary-fg: hsl(0,0%,100%);
  --secondary: hsl(217,33%,14%);
  --secondary-fg: hsl(213,31%,91%);
  --muted: hsl(217,33%,14%);
  --muted-fg: hsl(215,20%,55%);
  --accent: hsl(217,33%,17%);
  --border: hsl(217,33%,17%);
  --input: hsl(217,33%,17%);
  --sidebar-bg: hsl(222,47%,8%);
  --sidebar-border: hsl(217,33%,17%);
}

body { font-family: var(--font-inter); background: var(--background); color: var(--foreground); min-height: 100vh; transition: background .2s, color .2s; }

/* ─── Layout ─────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
#sidebar {
  width: 256px; min-width: 256px; background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column;
  overflow-y: auto; z-index: 40; transition: transform .2s, background .2s;
}
#sidebar .sidebar-logo {
  padding: 1.25rem 1.25rem .75rem; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: .5rem; color: var(--primary);
}
#sidebar .sidebar-logo svg { width: 22px !important; height: 22px !important; }
.nav-section { padding: .75rem .75rem .25rem; font-size: .7rem; font-weight: 600; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .05em; }
.nav-item {
  display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; margin: .1rem .5rem;
  border-radius: var(--radius); cursor: pointer; font-size: .875rem; color: var(--foreground);
  transition: background .15s; text-decoration: none;
}
.nav-item:hover { background: var(--accent); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.nav-item svg { width: 16px !important; height: 16px !important; flex-shrink: 0; }

/* Main content */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; flex-shrink: 0;
  transition: background .2s;
}
#topbar h1 { font-size: 1rem; font-weight: 600; }
#page-content { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; transition: background .2s;
}
.card-header { padding: 1.25rem 1.5rem .75rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-title svg { width: 16px !important; height: 16px !important; flex-shrink: 0; color: var(--primary); }
.card-description { font-size: .8rem; color: var(--muted-fg); margin-top: .2rem; }
.card-content { padding: 1.25rem 1.5rem; }

/* ─── Stat cards ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-label { font-size: .75rem; font-weight: 500; color: var(--muted-fg); text-transform: uppercase; letter-spacing:.04em; }
.stat-value { font-size: 1.75rem; font-weight: 700; margin-top:.25rem; }
.stat-sub { font-size: .75rem; color: var(--muted-fg); margin-top:.25rem; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .45rem 1rem; border-radius: calc(var(--radius) - 2px); font-size: .875rem;
  font-weight: 500; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap; line-height: 1;
}
.btn svg { width: 15px !important; height: 15px !important; flex-shrink: 0; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { opacity: .9; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--foreground); padding: .35rem .5rem; }
.btn-ghost:hover { background: var(--accent); }
.btn-destructive { background: var(--destructive); color: var(--destructive-fg); }
.btn-destructive:hover { opacity: .9; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { padding: .35rem; width: 32px; height: 32px; }
.btn-icon svg { width: 14px !important; height: 14px !important; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── Inputs ──────────────────────────────────────────────── */
.input, .textarea, .select {
  display: block; width: 100%; padding: .4rem .7rem; border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px); background: transparent; font-size: .875rem;
  color: var(--foreground); font-family: var(--font-inter); outline: none; transition: border-color .15s, background .2s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--muted-fg); }
.textarea { resize: vertical; min-height: 100px; }
.label { display: block; font-size: .8rem; font-weight: 500; margin-bottom: .3rem; }
.form-group { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:640px) { .form-grid { grid-template-columns: 1fr; } }

/* ─── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead tr { border-bottom: 1px solid var(--border); background: var(--muted); }
th { padding: .65rem 1rem; text-align: left; font-size: .75rem; font-weight: 600; color: var(--muted-fg); white-space: nowrap; }
td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--muted); }
td svg { width: 14px !important; height: 14px !important; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: .15rem .55rem;
  border-radius: 9999px; font-size: .72rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.badge-nuevo { background: hsl(210,100%,95%); color: hsl(210,100%,40%); border-color: hsl(210,100%,85%); }
.badge-proceso { background: hsl(38,100%,93%); color: hsl(38,90%,35%); border-color: hsl(38,100%,80%); }
.badge-espera { background: hsl(280,60%,94%); color: hsl(280,60%,40%); border-color: hsl(280,60%,82%); }
.badge-disponibilidad { background: hsl(175,60%,92%); color: hsl(175,80%,28%); border-color: hsl(175,60%,78%); }
.badge-cerrado { background: hsl(220,15%,92%); color: hsl(220,9%,40%); border-color: hsl(220,13%,82%); }
.badge-active { background: hsl(140,60%,92%); color: hsl(140,70%,28%); border-color: hsl(140,60%,78%); }
.badge-inactive { background: hsl(220,15%,92%); color: hsl(220,9%,40%); border-color: hsl(220,13%,82%); }
.dark .badge-nuevo { background: hsl(210,60%,20%); color: hsl(210,100%,75%); border-color: hsl(210,60%,30%); }
.dark .badge-proceso { background: hsl(38,60%,18%); color: hsl(38,90%,70%); border-color: hsl(38,60%,28%); }
.dark .badge-espera { background: hsl(280,40%,18%); color: hsl(280,60%,75%); border-color: hsl(280,40%,28%); }
.dark .badge-disponibilidad { background: hsl(175,40%,15%); color: hsl(175,60%,65%); border-color: hsl(175,40%,25%); }
.dark .badge-cerrado { background: hsl(220,20%,18%); color: hsl(220,15%,65%); border-color: hsl(220,20%,28%); }
.dark .badge-active { background: hsl(140,40%,15%); color: hsl(140,60%,60%); border-color: hsl(140,40%,25%); }
.dark .badge-inactive { background: hsl(220,20%,18%); color: hsl(220,15%,55%); border-color: hsl(220,20%,28%); }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; font-size: .8rem; }
.pagination-info { color: var(--muted-fg); margin-right: auto; }

/* ─── Filters ─────────────────────────────────────────────── */
.filters-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-wrap .icon { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted-fg); width: 14px !important; height: 14px !important; pointer-events: none; }
.search-wrap input { padding-left: 2rem; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; padding: 1.5rem; position: relative; transition: background .2s;
}
.modal-lg { max-width: 760px; }
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; display: flex; align-items: center; gap: .5rem; }
.modal-title svg { width: 16px !important; height: 16px !important; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.modal-close { position: absolute; top: 1rem; right: 1rem; }

/* ─── Switch ─────────────────────────────────────────────── */
.switch-wrap { display: flex; align-items: center; gap: .5rem; }
.switch {
  width: 40px; height: 22px; border-radius: 9999px; border: none; cursor: pointer;
  background: var(--muted-fg); position: relative; transition: background .2s; flex-shrink: 0;
}
.switch.on { background: var(--primary); }
.switch::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s;
}
.switch.on::after { transform: translateX(18px); }

/* ─── Charts ─────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.bar-chart { display: flex; flex-direction: column; gap: .5rem; }
.bar-row { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.bar-label { min-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 10px; background: var(--muted); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--primary); transition: width .4s; }
.bar-val { min-width: 28px; text-align: right; color: var(--muted-fg); }

/* ─── Detail section ─────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media(max-width:640px){ .detail-grid { grid-template-columns: 1fr; } }
.detail-field .detail-label { font-size: .72rem; color: var(--muted-fg); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.detail-field .detail-value { font-size: .9rem; font-weight: 500; }

/* ─── Comments ───────────────────────────────────────────── */
.comment { display: flex; gap: .75rem; margin-bottom: 1rem; }
.comment-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.comment-bubble { background: var(--muted); border-radius: var(--radius); padding: .65rem .9rem; flex: 1; }
.comment-meta { font-size: .72rem; color: var(--muted-fg); margin-bottom: .3rem; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--foreground); color: var(--card); padding: .75rem 1.25rem; border-radius: var(--radius);
  font-size: .875rem; box-shadow: 0 4px 12px rgba(0,0,0,.2); animation: slideIn .3s ease;
}
.toast.success { background: hsl(140,70%,28%); color: #fff; }
.toast.error { background: var(--destructive); color: #fff; }
@keyframes slideIn { from { transform: translateY(10px); opacity:0; } to { transform: translateY(0); opacity:1; } }

/* ─── Responsive sidebar ─────────────────────────────────── */
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
#mobile-menu-btn { display: none; }
@media(max-width:768px) {
  #sidebar { position: fixed; top:0; left:0; height:100vh; transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); z-index:40; }
  #sidebar-overlay.open { display: block; }
  #mobile-menu-btn { display: flex; }
}

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab { padding: .5rem 1rem; font-size: .875rem; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted-fg); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ─── Section header ─────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .5rem; }
.section-title { font-size: 1.15rem; font-weight: 700; }

/* ─── Print ──────────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #main { overflow: visible; }
  #page-content { padding: 0; }
}

/* ─── Drag handle ────────────────────────────────────────── */
.drag-handle { cursor: grab; color: var(--muted-fg); display: flex; align-items: center; }
.drag-handle svg { width: 16px !important; height: 16px !important; }
.dragging { opacity: .5; }

/* ─── Dark mode toggle ───────────────────────────────────── */
#dark-toggle { font-size: 1.1rem; line-height:1; background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: .3rem .6rem; cursor: pointer; color: var(--foreground); }
#dark-toggle:hover { background: var(--accent); }

/* ─── Text helpers ───────────────────────────────────────── */
.text-primary { color: var(--primary); }
