/* ═══════════════════════════════════════════════════
   VISTORIA APP — PORTAL WEB — style.css
═══════════════════════════════════════════════════ */

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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --bg: #0f0f1a;
  --surface: #16162a;
  --surface2: #1e1e35;
  --surface3: #252540;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);

  --text: #f1f1ff;
  --text-muted: #8888aa;
  --text-dim: #5555770;

  --sidebar-w: 240px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ─── SCREENS ─── */
.screen { position: fixed; inset: 0; transition: opacity 0.4s, transform 0.4s; }
.screen:not(.active) { opacity: 0; pointer-events: none; transform: translateY(8px); }
.screen.active { opacity: 1; transform: translateY(0); }

/* ─── LOGIN ─── */
.login-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.12) 0%, transparent 50%),
              radial-gradient(ellipse at 60% 80%, rgba(16,185,129,0.08) 0%, transparent 40%);
}
.login-orb {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.4; animation: float 8s ease-in-out infinite;
}
.orb1 { width: 400px; height: 400px; top: -100px; left: -100px; background: #6366f1; animation-delay: 0s; }
.orb2 { width: 300px; height: 300px; bottom: -80px; right: -80px; background: #8b5cf6; animation-delay: -3s; }
.orb3 { width: 200px; height: 200px; top: 50%; left: 60%; background: #10b981; animation-delay: -6s; }
@keyframes float {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(20px,-15px) scale(1.05); }
  66% { transform: translate(-10px,10px) scale(0.97); }
}

.login-card {
  position: relative; z-index: 10;
  width: 420px; max-width: calc(100vw - 32px);
  margin: auto; top: 50%; transform: translateY(-50%);
  background: rgba(22, 22, 42, 0.85);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 40px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.08);
}

.login-logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 20px; font-weight: 700; margin-bottom: 28px;
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.login-card h1 { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

.field-group { margin-bottom: 18px; }
.field-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; }

.input-wrap { position: relative; }
.input-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.input-wrap input {
  width: 100%; padding: 12px 14px 12px 42px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.input-wrap input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.input-wrap input::placeholder { color: var(--text-muted); }

.error-msg {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; border: none; border-radius: var(--radius-sm);
  padding: 13px 20px; font-size: 15px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: opacity 0.2s, transform 0.1s; font-family: inherit;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-full { width: 100%; }

/* ─── APP LAYOUT ─── */
#app-screen {
  display: flex; overflow: hidden;
  background: var(--bg);
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 12px;
  transition: transform 0.3s;
  height: 100vh;
  position: relative; z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; padding: 8px 12px 24px;
  background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.sidebar-logo svg { flex-shrink: 0; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text-muted);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; text-align: left; width: 100%;
  font-family: inherit; position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: rgba(99,102,241,0.15); color: var(--primary-light);
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav-item.active svg { color: var(--primary); }

.nav-badge {
  margin-left: auto; background: var(--primary);
  color: white; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; min-width: 20px; text-align: center;
}
.nav-badge:empty { display: none; }

.sidebar-footer {
  border-top: 1px solid var(--border); padding-top: 16px;
  display: flex; align-items: center; gap: 10px;
}
.user-info { flex: 1; min-width: 0; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.btn-logout {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.btn-logout svg { width: 14px; height: 14px; }
.btn-logout:hover { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: var(--danger); }

/* ─── MAIN ─── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.hamburger { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; }
.hamburger svg { width: 20px; height: 20px; }
.page-title { font-size: 18px; font-weight: 700; }

.sync-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
  background: var(--surface2); padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* ─── PAGE CONTAINER ─── */
.page-container { flex: 1; overflow-y: auto; padding: 28px; }
.page { display: none; animation: fadeIn 0.3s; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ─── STATS GRID ─── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── DASHBOARD GRID ─── */
.dashboard-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ─── CARDS ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.btn-link { background: none; border: none; color: var(--primary-light); font-size: 13px; cursor: pointer; font-family: inherit; }
.btn-link:hover { color: var(--primary); }

.list-container { padding: 8px 0; }

/* ─── LIST ITEMS ─── */
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; transition: background 0.15s; cursor: pointer;
}
.list-item:hover { background: var(--surface2); }
.list-avatar {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.list-info { flex: 1; min-width: 0; }
.list-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-badge { flex-shrink: 0; }

/* ─── PAGE TOOLBAR ─── */
.page-toolbar { margin-bottom: 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; max-width: 380px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.search-wrap input {
  width: 100%; padding: 10px 14px 10px 38px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
  font-family: inherit; outline: none; transition: border-color 0.2s;
}
.search-wrap input:focus { border-color: var(--primary); }
.search-wrap input::placeholder { color: var(--text-muted); }

/* ─── FILTER CHIPS ─── */
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.chip:hover { border-color: var(--primary); color: var(--primary-light); }
.chip.active { background: rgba(99,102,241,0.2); border-color: var(--primary); color: var(--primary-light); }

/* ─── DATA GRID (clientes) ─── */
.data-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.cliente-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.cliente-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.cliente-card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cliente-avatar-lg {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.cliente-name { font-size: 15px; font-weight: 700; }
.cliente-tipo { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cliente-details { display: flex; flex-direction: column; gap: 6px; }
.cliente-detail { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.cliente-detail svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ─── DATA LIST (vistorias / contratos) ─── */
.data-list { display: flex; flex-direction: column; gap: 10px; }
.vistoria-row, .contrato-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px;
  display: flex; align-items: center; gap: 16px; cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.vistoria-row:hover, .contrato-row:hover { transform: translateX(4px); border-color: var(--border-strong); }
.row-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.row-icon svg { width: 20px; height: 20px; }
.row-info { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-agendada { background: rgba(59,130,246,0.15); color: #93c5fd; }
.badge-em_andamento { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge-concluida { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.badge-cancelada { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-ativo { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.badge-pendente { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge-expirado { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-inativo { background: rgba(100,100,120,0.2); color: #9999bb; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 32px; max-width: 560px; width: 100%;
  max-height: 85vh; overflow-y: auto; position: relative;
  box-shadow: var(--shadow);
  transform: scale(0.95); transition: transform 0.25s;
}
.modal-overlay.open .modal-card { transform: scale(1); }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { background: var(--surface3); color: var(--text); }

.modal-header { margin-bottom: 24px; }
.modal-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.modal-sub { font-size: 14px; color: var(--text-muted); }
.modal-section { margin-bottom: 20px; }
.modal-section-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.modal-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-field { }
.modal-field-label { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.modal-field-value { font-size: 14px; font-weight: 500; }

/* ─── EMPTY / LOADING ─── */
.loading-state, .empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-muted); gap: 14px; text-align: center;
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; }
.empty-state p { font-size: 15px; }
.empty-state span { font-size: 13px; opacity: 0.7; }

/* ─── SKELETON ─── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius);
  min-height: 110px;
}
.skeleton-list {
  height: 200px; background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── SPINNERS ─── */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite;
}
.spinner-lg {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── PAGINATION ─── */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.page-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  cursor: pointer; font-size: 14px; font-family: inherit; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary-light); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ─── UTILS ─── */
.hidden { display: none !important; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: flex; }
  .page-container { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .data-grid { grid-template-columns: 1fr; }
  .modal-fields { grid-template-columns: 1fr; }
}
