/* ============================================================
   AutoGest Pro — Design System
   Mobile-first · Clean · High-performance
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;

  /* Neutrals */
  --n0:  #ffffff;
  --n50: #f8f9fa;
  --n100:#f1f3f5;
  --n200:#e9ecef;
  --n300:#dee2e6;
  --n400:#ced4da;
  --n500:#adb5bd;
  --n600:#868e96;
  --n700:#495057;
  --n800:#343a40;
  --n900:#212529;

  /* Brand */
  --blue:       #2563eb;
  --blue-light: #dbeafe;
  --blue-dark:  #1e40af;
  --green:      #16a34a;
  --green-light:#dcfce7;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --amber:      #d97706;
  --amber-light:#fef3c7;
  --purple:     #7c3aed;
  --purple-light:#ede9fe;
  --teal:       #0d9488;
  --teal-light: #ccfbf1;

  /* Sidebar */
  --sidebar-w: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #2563eb;

  /* Layout */
  --header-h: 56px;
  --radius:   8px;
  --radius-lg:12px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--n50);
  color: var(--n800);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font: inherit; }

/* ---------- Layout Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.logo-icon {
  width: 34px; height: 34px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
}
.logo-text { color: #f1f5f9; font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
.logo-sub  { color: var(--sidebar-text); font-size: 11px; }

.nav-section {
  font-size: 10px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase;
  color: #475569;
  padding: 16px 16px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  font-size: 13px;
  border-radius: 0;
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-item.active {
  background: rgba(37,99,235,.15);
  color: #93c5fd;
  border-left: 3px solid var(--blue);
  padding-left: 13px;
}
.nav-item .icon { font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.user-name  { font-size: 12px; color: #e2e8f0; font-weight: 500; }
.user-role  { font-size: 10px; color: var(--sidebar-text); }

/* ---------- Main ---------- */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--header-h);
  background: var(--n0);
  border-bottom: 1px solid var(--n200);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--n100);
  border: 1px solid var(--n200);
  border-radius: 20px;
  padding: 6px 14px;
}
.topbar-search input {
  background: none; border: none; outline: none;
  font-size: 13px; width: 180px; color: var(--n800);
}
.topbar-search input::placeholder { color: var(--n500); }
.btn-menu { display: none; background: none; border: none; cursor: pointer; font-size: 20px; padding: 4px; }

/* ---------- Content ---------- */
.content { padding: 20px; flex: 1; }

/* ---------- Page Header ---------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap; gap: 12px;
}
.page-title  { font-size: 20px; font-weight: 600; color: var(--n900); }
.page-sub    { font-size: 13px; color: var(--n600); margin-top: 2px; }
.page-actions{ display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- KPI Cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--n0);
  border: 1px solid var(--n200);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.kpi-card .label { font-size: 11px; color: var(--n600); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.kpi-card .value { font-size: 24px; font-weight: 600; color: var(--n900); margin-bottom: 4px; }
.kpi-card .value.green  { color: var(--green); }
.kpi-card .value.red    { color: var(--red); }
.kpi-card .value.blue   { color: var(--blue); }
.kpi-card .value.amber  { color: var(--amber); }
.kpi-card .meta { font-size: 11px; color: var(--n500); display: flex; align-items: center; gap: 4px; }

/* ---------- Cards ---------- */
.card {
  background: var(--n0);
  border: 1px solid var(--n200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--n200);
}
.card-title  { font-size: 14px; font-weight: 600; }
.card-body   { padding: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary   { background: var(--blue);  color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-success   { background: var(--green); color: #fff; }
.btn-danger    { background: var(--red);   color: #fff; }
.btn-warning   { background: var(--amber); color: #fff; }
.btn-ghost     { background: transparent; color: var(--n700); border: 1px solid var(--n300); }
.btn-ghost:hover { background: var(--n100); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--n50);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--n600);
  border-bottom: 1px solid var(--n200);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--n100);
  color: var(--n800);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--n50); }
.td-actions { display: flex; gap: 4px; }

/* ---------- Status Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
}
.badge::before { content:''; width:5px; height:5px; border-radius:50%; background:currentColor; }
.badge-green  { background:var(--green-light);  color:#166534; }
.badge-red    { background:var(--red-light);    color:#991b1b; }
.badge-amber  { background:var(--amber-light);  color:#92400e; }
.badge-blue   { background:var(--blue-light);   color:#1e40af; }
.badge-purple { background:var(--purple-light); color:#4c1d95; }
.badge-gray   { background:var(--n200);         color:var(--n700); }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--n700); }
.form-label.required::after { content: ' *'; color: var(--red); }
.form-control {
  padding: 8px 12px;
  border: 1px solid var(--n300);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--n0);
  color: var(--n800);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control::placeholder { color: var(--n400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--n500); }
.form-error { font-size: 11px; color: var(--red); }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--n0);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--n200);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body  { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--n200);
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }

/* ---------- Tabs ---------- */
.tabs-bar {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--n200);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--n600);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s;
}
.tab-btn:hover { color: var(--n800); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------- Alerts ---------- */
.alert {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; display: flex; align-items: flex-start; gap: 8px;
  margin-bottom: 14px;
}
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #86efac; }
.alert-danger  { background: var(--red-light);   color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--amber-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: var(--blue-light);  color: #1e40af; border: 1px solid #93c5fd; }

/* ---------- Agenda / Calendar ---------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day-name {
  text-align: center; font-size: 11px; font-weight: 600;
  color: var(--n500); padding: 6px 0; text-transform: uppercase;
}
.cal-day {
  min-height: 80px;
  background: var(--n0);
  border: 1px solid var(--n200);
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  transition: background .1s;
}
.cal-day:hover { background: var(--n50); }
.cal-day.today { border-color: var(--blue); background: var(--blue-light); }
.cal-day.other-month { background: var(--n50); opacity: .5; }
.cal-day-num { font-size: 12px; font-weight: 500; color: var(--n700); margin-bottom: 2px; }
.cal-event {
  font-size: 10px; background: var(--blue); color: #fff;
  border-radius: 3px; padding: 1px 4px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.cal-event.green  { background: var(--green); }
.cal-event.amber  { background: var(--amber); }
.cal-event.red    { background: var(--red); }

/* ---------- Timeline OS ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 12px;
  padding: 10px 0;
  border-left: 2px solid var(--n200);
  padding-left: 16px;
  margin-left: 8px;
  position: relative;
}
.timeline-item::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%; background: var(--n400);
  border: 2px solid var(--n0);
  position: absolute; left: -6px; top: 14px;
}
.timeline-item.done::before { background: var(--green); }
.timeline-item.active::before { background: var(--blue); }

/* ---------- Misc Utilities ---------- */
.text-muted   { color: var(--n500); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.font-mono    { font-family: var(--mono); }
.fw-600       { font-weight: 600; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mb-16        { margin-bottom: 16px; }
.w-100        { width: 100%; }
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--n500);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--n100); border-radius: 20px;
  padding: 2px 8px; font-size: 11px; color: var(--n700);
}
.divider { border: none; border-top: 1px solid var(--n200); margin: 16px 0; }
.skeleton {
  background: linear-gradient(90deg, var(--n200) 25%, var(--n100) 50%, var(--n200) 75%);
  background-size: 200% 100%;
  animation: skeleton .8s infinite;
  border-radius: 4px;
}
@keyframes skeleton { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ---------- OS Kanban ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}
.kanban-col { background: var(--n100); border-radius: var(--radius-lg); padding: 10px; }
.kanban-head {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--n700);
  padding: 4px 6px 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-card {
  background: var(--n0);
  border: 1px solid var(--n200);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card .os-num { font-size: 11px; color: var(--n500); font-family: var(--mono); }
.kanban-card .car    { font-size: 13px; font-weight: 600; margin: 2px 0; }
.kanban-card .owner  { font-size: 12px; color: var(--n600); }
.kanban-card .footer { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }

  .main-wrap { margin-left: 0; }

  .btn-menu { display: flex; align-items: center; justify-content: center; }

  .topbar-search { display: none; }

  .content { padding: 12px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card .value { font-size: 20px; }

  .page-header { margin-bottom: 14px; }
  .page-title  { font-size: 17px; }

  .form-grid { grid-template-columns: 1fr; }

  .cal-grid { grid-template-columns: repeat(7, 1fr); }
  .cal-day  { min-height: 50px; }
  .cal-event { display: none; }
  .cal-day.has-event::after {
    content:''; display: block;
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--blue); margin: 0 auto;
  }

  .kanban { grid-template-columns: 1fr; }

  .data-table th:nth-child(n+5),
  .data-table td:nth-child(n+5) { display: none; }

  .modal { max-height: 95vh; }

  .tabs-bar { font-size: 12px; }
  .tab-btn  { padding: 8px 12px; }
}

/* Overlay para mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--n300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--n400); }
