/* =============================================
   IMPERION CRM — Design System
   Azul marinho + Dourado + Branco
   ============================================= */

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

:root {
  /* Imperion Palette */
  --navy:        #0f1f3d;
  --navy-mid:    #162848;
  --navy-light:  #1e3560;
  --navy-border: rgba(255,255,255,0.08);
  --gold:        #c9a84c;
  --gold-light:  #e5c97a;
  --gold-dim:    #a07830;
  --white:       #ffffff;
  --off-white:   #f4f2ee;
  --surface:     #fafaf8;
  --surface-2:   #f0ede8;
  --text-main:   #1a1a2e;
  --text-sec:    #4a4a6a;
  --text-muted:  #8888aa;
  --border:      #e2ddd8;
  --border-dark: #c8c3bc;
  --success:     #1a7a4a;
  --success-bg:  #e8f7ef;
  --warning:     #8a6000;
  --warning-bg:  #fff8e0;
  --danger:      #a32020;
  --danger-bg:   #fdeaea;
  --info:        #1a4fa0;
  --info-bg:     #e8f0fc;

  --sidebar-w: 220px;
  --header-h: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-main);
  background: var(--off-white);
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== LAYOUT ===== */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--navy-border);
  text-align: center;
}
.sidebar-brand .brand-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--white);
}
.sidebar-brand .brand-name span { color: var(--gold); }
.sidebar-brand .brand-sub {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: rgba(201,168,76,0.7);
  text-transform: uppercase;
  margin-top: 3px;
}

.nav-section {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 16px 18px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.nav-item.active {
  background: rgba(201,168,76,0.12);
  color: var(--gold-light);
  border-left-color: var(--gold);
  font-weight: 500;
}
.nav-item i { font-size: 16px; width: 18px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--navy-border);
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

/* ===== MAIN ===== */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 16px; font-weight: 600; color: var(--text-main); }
.breadcrumb { font-size: 12px; color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.content-area { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-dark);
  background: var(--white);
  color: var(--text-main);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-dark); }
.btn:active { transform: scale(0.98); }

.btn-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
  font-weight: 600;
}
.btn-gold:hover { background: var(--gold-light); border-color: var(--gold-light); }

.btn-navy {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}
.btn-navy:hover { background: var(--navy-mid); }

.btn-danger { background: var(--danger-bg); border-color: #f5c6c6; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 7px; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text-main); line-height: 1; font-family: 'Cormorant Garamond', serif; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-gold .stat-value { color: var(--gold-dim); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface); }
.td-muted { color: var(--text-muted); font-size: 12px; }
.td-mono { font-family: monospace; font-size: 12px; }
.td-bold { font-weight: 600; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-neutral { background: var(--surface-2);  color: var(--text-sec); }
.badge-gold    { background: #fdf6e4; color: var(--gold-dim); }
.badge-navy    { background: #e8ecf4; color: var(--navy-light); }

/* ===== FORMS ===== */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-full    { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-sec); }
.field input,
.field select,
.field textarea {
  padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-main);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.field .hint { font-size: 11px; color: var(--text-muted); }
.field-row { display: flex; gap: 8px; align-items: flex-end; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,15,30,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0;
  background: var(--white);
  z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
  position: sticky; bottom: 0;
}
.btn-close-modal { background: none; border: none; font-size: 20px; color: var(--text-muted); line-height: 1; padding: 2px; }
.btn-close-modal:hover { color: var(--text-main); }

/* ===== ALERTS ===== */
.alert { padding: 10px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #b8e8d0; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #f5c6c6; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #c0d4f4; }

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1;
  max-width: 360px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238888aa' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") 10px center no-repeat;
}
.search-bar input:focus { border-color: var(--gold); }

/* ===== TABS ===== */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab-item { padding: 9px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; }
.tab-item:hover { color: var(--text-main); }
.tab-item.active { color: var(--gold-dim); border-bottom-color: var(--gold); }

/* ===== CRM KANBAN ===== */
.kanban-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kanban-col { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 12px; }
.kanban-col-header { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-sec); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.kanban-count { background: var(--border); padding: 1px 7px; border-radius: 100px; font-size: 11px; color: var(--text-muted); }
.kanban-card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); padding: 11px 13px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.kanban-card:hover { border-color: var(--gold); box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.kanban-card-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; }
.avatar-xs { width: 22px; height: 22px; border-radius: 50%; background: var(--info-bg); color: var(--info); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }

/* ===== RENTABILIDADE ===== */
.rent-box { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px; margin-top: 16px; }
.rent-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 12px; }
.rent-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.rent-row:last-child { border-bottom: none; padding-bottom: 0; }
.rent-row.total { font-weight: 700; font-size: 14px; color: var(--text-main); border-top: 2px solid var(--border); margin-top: 4px; padding-top: 10px; }
.rent-row.green { color: var(--success); }
.rent-row.gold  { color: var(--gold-dim); font-weight: 700; }
.rent-pct { font-size: 11px; background: var(--success-bg); color: var(--success); padding: 2px 7px; border-radius: 100px; font-weight: 700; margin-left: 8px; }
.rent-pct.low { background: var(--danger-bg); color: var(--danger); }

/* ===== COTACAO ITEMS TABLE ===== */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.items-table th { background: var(--navy); color: rgba(255,255,255,0.85); font-size: 11px; font-weight: 600; padding: 8px 10px; text-align: left; }
.items-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.items-table tfoot td { background: var(--surface); font-weight: 700; border-top: 2px solid var(--border); }
.items-table input[type=text], .items-table input[type=number] {
  width: 100%; padding: 5px 8px; border: 1px solid var(--border-dark); border-radius: 5px; font-size: 12px;
}
.items-table input:focus { border-color: var(--gold); outline: none; }

/* ===== LOGIN ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-card { background: var(--white); border-radius: var(--radius-lg); padding: 40px 36px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand .name { font-family: 'Cormorant Garamond', serif; font-size: 32px; font-weight: 600; letter-spacing: 0.1em; color: var(--navy); }
.login-brand .name span { color: var(--gold); }
.login-brand .sub { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; }

/* ===== UTILS ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-right { text-align: right; }
.text-gold { color: var(--gold-dim); font-weight: 700; }
.text-navy { color: var(--navy); font-weight: 700; }
.fw-600 { font-weight: 600; }
.hidden { display: none; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.gold-line { width: 40px; height: 2px; background: var(--gold); margin: 6px 0 16px; border-radius: 2px; }

/* ===== PDF print styles ===== */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content-area { padding: 0 !important; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

  /* Esconde sidebar no mobile */
  .sidebar { display: none; position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000; width: 240px; display: none; }
  .sidebar.open { display: flex !important; }

  /* Overlay quando sidebar aberta */
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }
  .sidebar-overlay.open { display: block; }

  .app-layout { flex-direction: column; }
  .main-area { width: 100%; }

  /* Topbar mobile */
  .topbar { padding: 0 14px; height: 52px; }
  .topbar-left { gap: 10px; }
  .page-title { font-size: 14px; }
  .topbar-right { gap: 6px; }
  .topbar-right span { display: none; }

  /* Botão hamburguer */
  .btn-menu { display: flex !important; }

  /* Content */
  .content-area { padding: 14px; }

  /* Stats grid - 2 colunas no mobile */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 20px; }

  /* Cards com grid - vira coluna */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] { display: block !important; }
  div[style*="grid-template-columns:1fr 280px"],
  div[style*="grid-template-columns: 1fr 280px"] { display: block !important; }
  div[style*="grid-template-columns:1fr 300px"] { display: block !important; }
  div[style*="grid-template-columns:1fr 340px"] { display: block !important; }

  /* Cards margin */
  .card { margin-bottom: 14px; }

  /* Tabelas - scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; font-size: 12px; }
  thead th { padding: 8px 10px; font-size: 10px; }
  tbody td { padding: 8px 10px; }

  /* Forms */
  .form-grid-2, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr !important; }
  .col-span-2, .col-span-3, .col-full { grid-column: 1 !important; }

  /* Modal */
  .modal-box { max-width: 100% !important; margin: 10px; border-radius: 10px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: 16px 16px 0 0; max-height: 90vh; }

  /* Kanban - scroll horizontal */
  .kanban-board { display: flex !important; overflow-x: auto; gap: 12px; padding-bottom: 12px; }
  .kanban-col { min-width: 240px; flex-shrink: 0; }

  /* Buttons */
  .btn { font-size: 12px; padding: 7px 12px; }
  .btn-gold { font-size: 13px; }

  /* Search bar */
  .search-bar input { max-width: 100%; }
  .search-bar { flex-wrap: wrap; }

  /* Cotacao form lateral */
  .rent-box { margin-top: 0; }

  /* Topbar actions */
  .topbar-right .btn span { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 24px; }
}
