/* ── Variables ─────────────────────────────────────── */
:root {
  color-scheme: light;
  --sidebar-width: 226px;
  --sidebar-width-collapsed: 64px;
  --topbar-height: 56px;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #4f46e5;
  --radius: 10px;
  --border-subtle: #e7eaf0;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: #f8fafc; color: #1e293b; }

/* ── Textareas que crescem com o conteúdo (ver main.js) ── */
textarea.form-control { overflow-y: hidden; }

/* ── Layout ─────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-width);
  height: 100vh; background: var(--sidebar-bg); display: flex;
  flex-direction: column; z-index: 1000; transition: width .2s ease, transform .3s ease;
  overflow-y: auto; overflow-x: hidden;
}
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .2s ease;
}
.topbar {
  min-height: var(--topbar-height); background: #fff; border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; position: sticky; top: 0; z-index: 100; gap: 12px;
}
.content-wrapper { flex: 1; padding: 22px 24px; }
.min-w-0 { min-width: 0; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px; color: #fff; font-size: 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08); min-height: var(--topbar-height);
}
.sidebar-logo-img { max-height: 30px; max-width: 130px; object-fit: contain; flex-shrink: 0; }
.sidebar-logo-icon { font-size: 1.1rem; }
.sidebar-collapse-btn {
  background: transparent; border: none; color: var(--sidebar-text);
  width: 26px; height: 26px; border-radius: 6px; align-items: center; justify-content: center;
  font-size: .75rem; flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav { flex: 1; padding: 10px 10px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  color: var(--sidebar-text); text-decoration: none; border-radius: 8px;
  font-size: .83rem; transition: background .15s ease, color .15s ease; margin-bottom: 1px;
  width: 100%; background: none; border: none; text-align: left; cursor: pointer;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-link i { font-size: .95rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-section {
  font-size: .66rem; font-weight: 700; letter-spacing: .07em; color: #6366f1;
  padding: 14px 12px 4px; text-transform: uppercase;
}
.sidebar-caret { font-size: .7rem !important; width: auto !important; transition: transform .15s ease; margin-left: auto; }
.sidebar-link--parent[aria-expanded="true"] .sidebar-caret { transform: rotate(180deg); }
.sidebar-submenu { padding-left: 8px; }
.sidebar-sublink { font-size: .78rem; padding-left: 22px; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer-toggle { padding: 6px 8px; }
.sidebar-footer-toggle .sidebar-caret { transform: none !important; }
.sidebar-footer-toggle[aria-expanded="true"] { background: rgba(255,255,255,.08); color: #fff; }
.avatar-sm { width: 30px; height: 30px; font-size: .8rem; flex-shrink: 0; }
.tiny { font-size: .7rem; }

/* ── Sidebar recolhido (só ícones, desktop) ───────────── */
@media (min-width: 992px) {
  html.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
  html.sidebar-collapsed .main-content { margin-left: var(--sidebar-width-collapsed); }
  html.sidebar-collapsed .sidebar-label { display: none; }
  html.sidebar-collapsed .sidebar-link,
  html.sidebar-collapsed .sidebar-link--parent,
  html.sidebar-collapsed .sidebar-footer-toggle { justify-content: center; padding: 10px 0; }
  html.sidebar-collapsed .sidebar-header { flex-direction: column; gap: 6px; justify-content: center; padding: 12px 6px; }
  html.sidebar-collapsed .sidebar-logo-img { max-width: 32px; }
  html.sidebar-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }
  /* Submenu vira um flyout flutuante ao lado do ícone quando recolhido, em vez de sumir. */
  html.sidebar-collapsed .sidebar-submenu.show {
    position: absolute; left: var(--sidebar-width-collapsed); top: auto;
    min-width: 200px; background: var(--sidebar-bg); border-radius: 0 8px 8px 0;
    box-shadow: 4px 0 12px rgba(0,0,0,.18); padding: 6px; z-index: 1001;
  }
  html.sidebar-collapsed .sidebar-submenu.show .sidebar-label { display: inline; }
  html.sidebar-collapsed .sidebar-submenu.show .sidebar-sublink { padding-left: 12px; justify-content: flex-start; }
}

/* ── Mobile sidebar ─────────────────────────────────── */
.sidebar-toggle {
  position: fixed; top: 12px; left: 12px; z-index: 1100;
  background: var(--sidebar-bg); color: #fff; border: none;
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}

/* ── Alternância sidebar / topbar ─────────────────────── */
html[data-layout="topbar"] .sidebar,
html[data-layout="topbar"] .sidebar-toggle,
html[data-layout="topbar"] .sidebar-overlay,
html[data-layout="topbar"] .sidebar-mobile-btn { display: none !important; }
html[data-layout="topbar"] .main-content { margin-left: 0 !important; }
html[data-layout="topbar"] .topbar { display: none !important; }
html:not([data-layout="topbar"]) .topbar-nav,
html:not([data-layout="topbar"]) .topbar-nav ~ .offcanvas { display: none !important; }

/* ── Stat cards ─────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius); padding: 14px 16px; color: #fff; height: 100%;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; position: relative; overflow: hidden;
}
.stat-card--primary { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.stat-card--success { background: linear-gradient(135deg, #059669, #10b981); }
.stat-card--warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.stat-card--info    { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.stat-card--danger  { background: linear-gradient(135deg, #dc2626, #ef4444); }
.stat-icon { font-size: 1.5rem; opacity: .75; line-height: 1; flex-shrink: 0; }
.stat-value { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; opacity: .88; line-height: 1.2; }

/* ── Cards ──────────────────────────────────────────── */
.card { border: 1px solid var(--border-subtle); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #f8fafc; border-bottom: 1px solid var(--border-subtle); padding: 12px 16px; font-size: .9rem; }
.shadow-sm { box-shadow: 0 1px 3px rgba(15,23,42,.06) !important; }

/* ── Tables ─────────────────────────────────────────── */
.table { font-size: .875rem; }
.table th { font-weight: 600; color: #64748b; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* ── Task cards ─────────────────────────────────────── */
.task-card { transition: box-shadow .15s; }
.task-card:hover { box-shadow: 0 4px 16px rgba(79,70,229,.12) !important; }

/* ── Color dots / swatches ──────────────────────────── */
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.color-swatch { width: 20px; height: 20px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.color-preview { width: 44px; height: 44px; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.1); margin: 0 auto 4px; }

/* ── Client logo ────────────────────────────────────── */
.client-logo-thumb { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc; }
.client-logo-placeholder { width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
.client-logo-main { max-width: 120px; max-height: 80px; object-fit: contain; }
.client-logo-placeholder-lg { width: 90px; height: 90px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 2rem; }

/* ── Reference image thumbnail ──────────────────────── */
.ref-image-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid #e2e8f0; }

/* ── Alerts floating ────────────────────────────────── */
.alert-floating { position: fixed; top: 16px; right: 16px; z-index: 9999; min-width: 280px; max-width: 400px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }

/* ── Login page ─────────────────────────────────────── */
.login-page { min-height: 100vh; background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 100%); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-container { width: 100%; max-width: 420px; }
.login-card { border: none; border-radius: 16px; background-color: #ffffff !important; color: #1e293b; }

/* ── Client portal ──────────────────────────────────── */
.client-portal { min-height: 100vh; }

/* ── Topbar nav (modo "menu superior") ────────────────── */
.topbar-nav { background: #fff; border-bottom: 1px solid var(--border-subtle); padding: 6px 0; }
.topbar-nav-logo-img { max-height: 28px; max-width: 130px; object-fit: contain; }
.topbar-nav .nav-link {
  display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 500;
  color: #475569; padding: 7px 12px; border-radius: 8px; transition: background .15s ease, color .15s ease;
}
.topbar-nav .nav-link:hover { background: #f1f5f9; color: #1e293b; }
.topbar-nav .nav-link.active,
.topbar-nav .nav-link.dropdown-toggle.active { background: var(--primary); color: #fff; }
.topbar-nav .dropdown-menu { border: 1px solid var(--border-subtle); box-shadow: 0 8px 24px rgba(15,23,42,.1); border-radius: 10px; padding: 6px; margin-top: 4px; }
.topbar-nav .dropdown-item { border-radius: 6px; font-size: .85rem; padding: 7px 10px; }
.topbar-nav .dropdown-item.active { background: var(--primary); color: #fff; }
html.nav-icons-only[data-layout="topbar"] .topbar-nav-text { display: none; }

/* Menu offcanvas mobile (usado no modo topbar e reaproveita as mesmas classes) */
.topbar-offcanvas-section {
  font-size: .66rem; font-weight: 700; letter-spacing: .07em; color: #6366f1;
  padding: 14px 8px 4px; text-transform: uppercase;
}
.topbar-offcanvas-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  color: #334155; text-decoration: none; border-radius: 8px; font-size: .88rem;
  width: 100%; background: none; border: none; text-align: left; cursor: pointer;
}
.topbar-offcanvas-link:hover { background: #f1f5f9; }
.topbar-offcanvas-link.active { background: var(--primary); color: #fff; }
.topbar-offcanvas-sublink { padding-left: 30px; font-size: .84rem; }

/* ── Grade de atalhos (tela Início) ───────────────────── */
.quick-access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.quick-access-card {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 12px 14px;
  text-decoration: none; color: #1e293b; background: #fff;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.quick-access-card:hover { box-shadow: 0 6px 16px rgba(15,23,42,.08); transform: translateY(-2px); border-color: #c7d2fe; color: #1e293b; }
.quick-access-icon {
  width: 32px; height: 32px; border-radius: 8px; background: #eef2ff; color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0;
}
.quick-access-title { font-size: .82rem; font-weight: 600; }

/* ── Buttons extra small ────────────────────────────── */
.btn-xs { padding: 2px 6px; font-size: .75rem; line-height: 1.4; border-radius: 4px; }

/* ── Badge subtle colors (BS5.3 fallback) ───────────── */
.bg-primary-subtle { background-color: #ede9fe !important; }
.bg-success-subtle { background-color: #dcfce7 !important; }
.bg-danger-subtle  { background-color: #fee2e2 !important; }
.bg-warning-subtle { background-color: #fef3c7 !important; }
.bg-info-subtle    { background-color: #dbeafe !important; }
.bg-secondary-subtle { background-color: #f1f5f9 !important; }
.text-primary  { color: var(--primary) !important; }
.text-success  { color: #16a34a !important; }
.text-danger   { color: #dc2626 !important; }
.text-warning  { color: #d97706 !important; }
.text-info     { color: #0284c7 !important; }
.text-secondary { color: #64748b !important; }

/* ── Responsive tweaks ──────────────────────────────── */
@media (max-width: 576px) {
  .content-wrapper { padding: 16px; }
  .stat-value { font-size: 1.25rem; }
  .alert-floating { left: 16px; right: 16px; max-width: none; }
}
