/* ============================================================
   Sistema DBS — Estilos
   Tema: dark executivo
   ============================================================ */

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --bg:           #0d0f14;
  --bg-2:         #151820;
  --bg-3:         #1c2030;
  --bg-4:         #242840;
  --border:       #2a2f45;
  --border-light: #363c5a;

  --text:         #e8eaf0;
  --text-muted:   #8892b0;
  --text-dim:     #55607a;

  --accent:       #4f7ef8;
  --accent-hover: #6b93ff;

  --green:        #22c55e;
  --green-bg:     #052e16;
  --red:          #ef4444;
  --red-bg:       #2d0a0a;
  --yellow:       #eab308;
  --yellow-bg:    #2d2100;
  --orange:       #f97316;
  --orange-bg:    #2d1200;
  --purple:       #a855f7;
  --purple-bg:    #1e0d33;

  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 2px 12px rgba(0,0,0,.45);

  --sidebar-w:    240px;
  --topbar-h:     60px;
  --transition:   .18s ease;
}

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

html { font-size: 14px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
select { font: inherit; }

/* ── Loading Overlay ───────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(13,15,20,.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  transition: opacity var(--transition);
}
.loading-overlay.hidden { display: none; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error Banner ──────────────────────────────────────────── */
.error-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--red-bg);
  border-bottom: 1px solid var(--red);
  color: var(--red);
  font-size: .9rem;
}
.error-banner.hidden { display: none; }
.error-icon { font-size: 1rem; }
.error-banner span:nth-child(2) { flex: 1; }
.error-close {
  color: var(--red); opacity: .7;
  padding: 2px 6px; border-radius: 4px;
  transition: opacity var(--transition);
}
.error-close:hover { opacity: 1; }

/* ── Layout ────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 1rem; letter-spacing: .05em; }
.brand-sub  { font-size: .7rem; color: var(--text-dim); margin-top: 1px; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex; flex-direction: column; gap: 2px;
}

.nav-group { display: flex; flex-direction: column; }

.nav-parent {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 9px 16px;
  color: var(--text);
  font-size: .85rem; font-weight: 500;
  border-radius: 0;
  text-align: left;
  transition: background var(--transition);
}
.nav-parent:hover { background: var(--bg-3); }

.nav-arrow { font-size: .7rem; color: var(--text-dim); width: 12px; flex-shrink: 0; }
.nav-icon  { font-size: .95rem; flex-shrink: 0; }

.nav-children {
  display: none;
  flex-direction: column;
  padding-left: 28px;
}
.nav-children.expanded { display: flex; }

.nav-child {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  color: var(--text-muted);
  font-size: .82rem;
  border-radius: var(--radius);
  margin: 1px 4px;
  text-align: left; width: calc(100% - 8px);
  transition: background var(--transition), color var(--transition);
}
.nav-child:hover  { background: var(--bg-3); color: var(--text); }
.nav-child.active { background: rgba(79,126,248,.15); color: var(--accent); font-weight: 600; }
.nav-child-dot { font-size: .55rem; flex-shrink: 0; }
.active-dot { color: var(--accent); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: var(--text-muted);
  font-size: .85rem;
}
.nav-disabled { opacity: .4; cursor: not-allowed; }

.badge-soon {
  margin-left: auto;
  font-size: .65rem; font-weight: 600;
  padding: 2px 6px;
  background: var(--bg-4); color: var(--text-dim);
  border-radius: 20px; letter-spacing: .03em;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.footer-label   { font-size: .65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.footer-space   { font-size: .78rem; font-weight: 600; color: var(--accent); }
.footer-updated { font-size: .7rem; color: var(--text-dim); margin-top: 2px; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; gap: 12px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.sidebar-toggle {
  display: none;
  padding: 6px 9px;
  color: var(--text-muted); font-size: 1.1rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-3); }

.page-title {
  font-size: .95rem; font-weight: 600;
  color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.topbar-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  flex-shrink: 0;
}

.filter-select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: .8rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  max-width: 170px;
}
.filter-select:hover  { border-color: var(--border-light); }
.filter-select:focus  { border-color: var(--accent); }
.filter-select option { background: var(--bg-3); }

/* Buttons */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: .82rem; font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }

.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

/* ── Dashboard ─────────────────────────────────────────────── */
.dashboard {
  flex: 1;
  padding: 24px 20px;
  display: flex; flex-direction: column; gap: 20px;
  max-width: 1600px;
}

/* ── No-data state ─────────────────────────────────────────── */
.no-data {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.no-data.hidden { display: none; }
.no-data-icon { font-size: 3rem; opacity: .3; }
.no-data h2   { font-size: 1.1rem; color: var(--text); }
.no-data p    { font-size: .85rem; max-width: 400px; }

/* ── Metric Cards ──────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.metric-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  transition: border-color var(--transition);
}
.metric-card:hover { border-color: var(--border-light); }

.metric-label {
  font-size: .73rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 8px;
}
.metric-value { font-size: 2rem; font-weight: 700; color: var(--text); }

.metric-green  { border-left: 3px solid var(--green);  }
.metric-green .metric-value { color: var(--green); }
.metric-red    { border-left: 3px solid var(--red);    }
.metric-red .metric-value   { color: var(--red);   }
.metric-yellow { border-left: 3px solid var(--yellow); }
.metric-yellow .metric-value { color: var(--yellow); }
.metric-orange { border-left: 3px solid var(--orange); }
.metric-orange .metric-value { color: var(--orange); }
.metric-purple { border-left: 3px solid var(--purple); }
.metric-purple .metric-value { color: var(--purple); }

/* ── Cards genéricos ───────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-red-border    { border-left: 3px solid var(--red);    }
.card-yellow-border { border-left: 3px solid var(--yellow); }
.card-purple-border { border-left: 3px solid var(--purple); }

.section-title {
  font-size: .88rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); margin-bottom: 14px;
}

/* ── Layouts 2 e 3 colunas ─────────────────────────────────── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }

/* ── Chart Bars ────────────────────────────────────────────── */
.chart-area { display: flex; flex-direction: column; gap: 10px; }

.bar-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  align-items: center;
}
.bar-label {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--text);
  grid-column: 1; grid-row: 1;
  min-width: 0; overflow: hidden;
}
.bar-label span:last-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-count {
  font-size: .8rem; font-weight: 700;
  color: var(--text-muted);
  grid-column: 2; grid-row: 1 / 3;
  text-align: right;
}
.bar-track {
  grid-column: 1; grid-row: 2;
  background: var(--bg-4);
  border-radius: 20px; height: 6px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 20px;
  transition: width .4s ease;
  min-width: 2px;
}
.bar-fill--blue { background: var(--accent) !important; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.avatar-small {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; color: #fff;
}
.badge-overdue {
  font-size: .65rem; font-weight: 600; padding: 1px 6px;
  background: var(--red-bg); color: var(--red);
  border-radius: 20px; white-space: nowrap;
}

/* ── Task Lists ────────────────────────────────────────────── */
.task-list { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow-y: auto; }
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-track { background: transparent; }
.task-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.task-item {
  display: block;
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
}
.task-item:hover { border-color: var(--border-light); background: var(--bg-4); }

.task-header {
  display: flex; align-items: flex-start; gap: 7px;
  margin-bottom: 5px;
}
.task-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.task-name {
  flex: 1; font-size: .82rem; font-weight: 500; line-height: 1.4;
  color: var(--text);
}
.task-priority {
  font-size: .65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; flex-shrink: 0;
  text-transform: uppercase;
}
.task-priority--urgent, .task-priority--urgente { background: var(--red-bg);    color: var(--red);    }
.task-priority--high,   .task-priority--alta    { background: var(--orange-bg); color: var(--orange); }
.task-priority--normal                           { background: var(--bg-4);      color: var(--text-muted); }
.task-priority--low                              { background: var(--bg-4);      color: var(--text-dim);   }

.task-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: .72rem; color: var(--text-muted);
  padding-left: 15px;
}
.task-area       { color: var(--accent); }
.task-due        { color: var(--text-muted); }
.task-due--overdue { color: var(--red); font-weight: 600; }
.task-no-assignee { color: var(--orange); font-style: italic; }

.empty-state {
  text-align: center; padding: 20px;
  color: var(--text-dim); font-size: .82rem;
}

/* ── Areas Operation ───────────────────────────────────────── */
.areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.area-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color var(--transition);
}
.area-card:hover { border-color: var(--border-light); }
.area-name {
  font-size: .82rem; font-weight: 600;
  color: var(--text); margin-bottom: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.area-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; }
.area-stat  { display: flex; flex-direction: column; align-items: center; }
.area-stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.area-stat-label { font-size: .6rem; color: var(--text-dim); text-transform: uppercase; }
.area-stat--red   .area-stat-value { color: var(--red);   }
.area-stat--green .area-stat-value { color: var(--green); }

/* ── Weekly Summary ────────────────────────────────────────── */
.summary-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px;
}
.summary-block-title {
  font-size: .8rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px;
}
.summary-list { display: flex; flex-direction: column; gap: 4px; }
.summary-task {
  display: block; font-size: .8rem; color: var(--text-muted);
  padding: 5px 8px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}
.summary-task:hover { background: var(--bg-3); color: var(--text); }
.summary-more { font-size: .72rem; color: var(--text-dim); padding: 4px 8px; }
.bottleneck-item {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 0;
  font-size: .82rem;
}

/* ── Tech Footer ───────────────────────────────────────────── */
.tech-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 20px; flex-wrap: wrap;
  font-size: .72rem; color: var(--text-dim);
  background: var(--bg-2); flex-shrink: 0;
}
.tech-footer strong { color: var(--text-muted); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .two-col   { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
}

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

  .sidebar {
    width: 240px;
    transform: translateX(-100%);
  }
  .sidebar.sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.5);
  }

  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: flex; }

  .topbar-filters { gap: 6px; }
  .filter-select  { max-width: 120px; }

  .cards-grid { grid-template-columns: repeat(2,1fr); }
  .areas-grid { grid-template-columns: 1fr 1fr; }

  .dashboard { padding: 14px 12px; gap: 14px; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .topbar-filters { display: none; } /* simplificado em mobile muito pequeno */
}
