/* =====================================================
   GT BUILDING — Design System V3
   Clean, professional, mobile-first
   ===================================================== */

/* CSS Custom Properties — cor primária injetada via JS */
:root {
  --primary:      #1e40af;
  --primary-light: #3b5bdb;
  --primary-bg:   #eff4ff;
  --primary-10:   rgba(30,64,175,.10);

  --bg:        #f5f6fa;
  --surface:   #ffffff;
  --surface2:  #f8f9fc;
  --border:    #e8eaf0;
  --border2:   #d1d5e0;

  --text:      #0f172a;
  --text2:     #334155;
  --muted:     #64748b;
  --subtle:    #94a3b8;

  --success:   #16a34a;
  --success-bg:#f0fdf4;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --warn:      #d97706;
  --warn-bg:   #fffbeb;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);

  --font:      'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --sidebar-w: 240px;
  --header-h:  60px;
  --transition: all .18s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
img  { max-width: 100%; display: block; }
a    { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }

/* ---- Typography ---- */
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.4px; line-height: 1.2; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }
p  { color: var(--text2); }

/* ---- Form Elements ---- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; color: var(--text);
  background: var(--surface); transition: var(--transition);
  outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-10); }
.input::placeholder { color: var(--subtle); }
.input.error  { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 90px; }
select.input   { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 36px; }

.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.field-hint  { font-size: 12px; color: var(--muted);  margin-top: 4px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 10px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; border: none; cursor: pointer;
  transition: var(--transition); white-space: nowrap; line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }

.btn-secondary { background: var(--surface); color: var(--text2); border: 1.5px solid var(--border2); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled)  { opacity: .88; }

.btn-ghost   { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled)   { color: var(--text); border-color: var(--border2); }

.btn-sm  { padding: 6px 14px; font-size: 13px; }
.btn-xs  { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg  { padding: 13px 28px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: transparent; border: none; cursor: pointer; color: var(--muted); transition: var(--transition); }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon svg { width: 17px; height: 17px; }
.btn-block { width: 100%; }

/* ---- Cards ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.card-sm { padding: 16px; border-radius: var(--radius); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-header h3 { font-size: 15px; font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-red    { background: var(--danger-bg);  color: var(--danger); }
.badge-blue   { background: var(--primary-bg); color: var(--primary); }
.badge-gray   { background: var(--surface2);   color: var(--muted); border: 1px solid var(--border); }

/* ---- Table ---- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th { background: var(--surface2); padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-wrap td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text2); vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: var(--surface2); }
.table-scroll { overflow-x: auto; }

/* ---- Modal ---- */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 200; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-xl); padding: 28px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 680px; }
@keyframes modalIn { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: var(--radius-sm); transition: var(--transition); }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ---- Sidebar Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; transition: transform .25s ease; }
.sidebar-brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-brand img { height: 32px; width: auto; object-fit: contain; }
.sidebar-brand-text { font-size: 15px; font-weight: 800; color: var(--primary); letter-spacing: -.3px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section-title { font-size: 10px; font-weight: 700; color: var(--subtle); text-transform: uppercase; letter-spacing: .8px; padding: 8px 10px 4px; margin-top: 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); cursor: pointer; color: var(--muted); transition: var(--transition); margin-bottom: 1px; font-size: 13.5px; font-weight: 500; border: none; background: none; width: 100%; text-align: left; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text2); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); }

.content-wrap { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 40; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 13px; font-weight: 600; }
.page { padding: 28px; max-width: 1280px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; position: relative; overflow: hidden; }
.stat-card::after { content:''; position: absolute; top:0; left:0; right:0; height:3px; background: var(--primary); border-radius: 2px 2px 0 0; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; line-height: 1; color: var(--text); margin-bottom: 4px; }
.stat-card .stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-card .stat-icon  { position: absolute; right: 16px; top: 18px; color: var(--border2); }
.stat-card .stat-icon svg { width: 28px; height: 28px; }

/* Filters bar */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search-input-wrap { position: relative; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--subtle); width: 15px; height: 15px; pointer-events: none; }
.search-input-wrap .input { padding-left: 34px; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; max-width: 320px; }
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
.toast.warn    { background: #92400e; }
@keyframes toastIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Upload Zone */
.upload-zone { border: 2px dashed var(--border2); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; transition: var(--transition); background: var(--surface2); }
.upload-zone:hover { border-color: var(--primary); background: var(--primary-bg); }
.upload-zone p { color: var(--muted); font-size: 13px; margin-top: 8px; }
.upload-preview { width: 80px; height: 80px; object-fit: contain; border-radius: var(--radius); border: 1px solid var(--border); margin: 0 auto 8px; }

/* Empty state */
.empty-state { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--border2); }
.empty-state h4 { color: var(--text2); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.page-btn { width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); color: var(--text2); font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-info { font-size: 12px; color: var(--muted); }

/* Mobile overlay */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 49; }

/* Hamburger */
.hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--text2); padding: 4px; }
.hamburger svg { width: 22px; height: 22px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.open { display: block; }
  .content-wrap { margin-left: 0; }
  .hamburger { display: flex; }
  .page { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 22px; }
  .modal { padding: 20px; border-radius: var(--radius-lg); }
  h1 { font-size: 20px; }
}

/* Misc utils */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.w-full { width: 100%; }
.loading { opacity: .6; pointer-events: none; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
