/* =========================================
   GRUPO GESTOR — Cofre de Clientes
   Paleta inspirada no logo institucional
   ========================================= */

:root {
  /* Brand */
  --brand-teal: #14B8A6;
  --brand-teal-light: #2DD4BF;
  --brand-teal-dark: #0F9488;
  --brand-blue: #2563EB;
  --brand-blue-light: #3B82F6;
  --brand-blue-dark: #1D4ED8;
  --brand-gradient: linear-gradient(135deg, #2DD4BF 0%, #14B8A6 35%, #2563EB 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(45,212,191,0.08) 0%, rgba(37,99,235,0.08) 100%);

  /* Surfaces */
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  /* Text */
  --text: #0F172A;
  --text-2: #334155;
  --muted: #64748B;
  --muted-light: #94A3B8;

  /* Status */
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06);
  --shadow: 0 4px 12px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 20px 50px rgba(15,23,42,0.10), 0 8px 16px rgba(15,23,42,0.06);
}

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

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* =========================================
   LOGIN
   ========================================= */
#view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(45,212,191,0.18), transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, rgba(37,99,235,0.18), transparent 60%),
    var(--bg);
}
.login-box {
  background: var(--surface);
  padding: 44px 40px 36px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}
.login-brand img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin-bottom: 12px;
}
.login-brand .brand-name {
  font-size: 22px;
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.5px;
}
.login-brand .brand-sub {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}
.login-box h2 {
  font-size: 18px;
  text-align: center;
  margin-bottom: 6px;
  color: var(--text);
}
.login-box .login-sub {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 24px;
}
.login-box form { display: flex; flex-direction: column; gap: 12px; }

/* =========================================
   FORM CONTROLS
   ========================================= */
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-light); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(20,184,166,0.15);
}
textarea { resize: vertical; min-height: 80px; }

button {
  background: var(--brand-blue);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
}
button:hover { background: var(--brand-blue-dark); transform: translateY(-1px); }
button:active { transform: translateY(0); }

button.primary {
  background: var(--brand-gradient);
  box-shadow: 0 4px 12px rgba(37,99,235,0.25);
}
button.primary:hover { box-shadow: 0 6px 16px rgba(37,99,235,0.35); }

button.ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
button.ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); transform: none; }

button.danger { background: var(--danger); box-shadow: 0 4px 12px rgba(239,68,68,0.25); }
button.danger:hover { background: #DC2626; }

button.small { padding: 6px 12px; font-size: 12px; }
button.icon { padding: 6px 8px; }

.error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }

/* =========================================
   APP TOPBAR
   ========================================= */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.topbar-brand img { width: 40px; height: 40px; object-fit: contain; }
.topbar-brand .name {
  font-size: 15px;
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.3px;
  line-height: 1;
}
.topbar-brand .sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}
.topbar nav { display: flex; gap: 4px; flex: 1; margin-left: 16px; }
.tab {
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.tab:hover { background: var(--surface-2); color: var(--text); transform: none; }
.tab.active {
  background: var(--brand-gradient-soft);
  color: var(--brand-blue);
  position: relative;
}
.user-info { display: flex; align-items: center; gap: 12px; }
#user-display {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* =========================================
   CONTENT
   ========================================= */
.tab-content { display: none; padding: 28px; max-width: 1400px; margin: 0 auto; }
.tab-content.active { display: block; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.page-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar input[type="search"] {
  max-width: 360px;
  background: var(--surface);
}
.toolbar h3 { flex: 1; font-size: 16px; }

.grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.panel h3 {
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* =========================================
   LIST CLIENTS
   ========================================= */
.list { list-style: none; max-height: 70vh; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.list li {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
  transition: all 0.12s;
  background: var(--surface);
}
.list li:hover { background: var(--surface-2); }
.list li.selected {
  background: var(--brand-gradient-soft);
  border-color: var(--brand-teal);
}
.list li .name { font-weight: 600; color: var(--text); }
.list li .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }

.muted { color: var(--muted); }

/* =========================================
   CLIENT DETAIL
   ========================================= */
.client-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.client-header h3 { margin: 0; font-size: 20px; color: var(--text); text-transform: none; letter-spacing: 0; }
.client-header .actions { display: flex; gap: 8px; flex-shrink: 0; }
.client-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.field {
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.field label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.field .value { margin-top: 4px; color: var(--text); font-weight: 500; }

.notas-field {
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.notas-field label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.notas-field .value { margin-top: 4px; white-space: pre-wrap; color: var(--text-2); }

/* =========================================
   VAULT
   ========================================= */
.vault-section { margin-top: 28px; }
.vault-section h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}

.vault-entry {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.vault-entry:hover { border-color: var(--brand-teal); box-shadow: var(--shadow-sm); }
.vault-entry .top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 10px;
  gap: 12px;
}
.vault-entry .titulo { font-weight: 600; color: var(--text); }
.vault-entry .usuario { color: var(--muted); font-size: 13px; margin-top: 3px; }
.vault-entry .url { color: var(--brand-blue); font-size: 12px; margin-top: 4px; word-break: break-all; }
.vault-entry .url a { color: inherit; text-decoration: none; }
.vault-entry .url a:hover { text-decoration: underline; }
.vault-entry .password-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  border: 1px solid var(--border);
}
.vault-entry .password-row .pwd { flex: 1; color: var(--text); font-size: 13px; letter-spacing: 1px; }
.vault-entry .actions { display: flex; gap: 6px; flex-shrink: 0; }
.vault-entry .notas { color: var(--muted); font-size: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* =========================================
   USERS TABLE
   ========================================= */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
th, td {
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--surface-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
}
.badge.admin { background: rgba(239,68,68,0.10); color: var(--danger); }
.badge.editor { background: rgba(37,99,235,0.10); color: var(--brand-blue); }
.badge.leitor { background: rgba(100,116,139,0.10); color: var(--muted); }
.badge.active { background: rgba(16,185,129,0.12); color: var(--success); }
.badge.inactive { background: rgba(148,163,184,0.15); color: var(--muted); }

/* =========================================
   MODAL
   ========================================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-content h3 { margin-bottom: 18px; font-size: 18px; color: var(--text); }
#modal-body { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
#modal-body label { font-size: 12px; color: var(--muted); margin-bottom: 5px; display: block; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* =========================================
   TOAST
   ========================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: var(--radius);
  z-index: 200;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  color: var(--text);
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

/* =========================================
   FOOTER
   ========================================= */
.app-footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  background: var(--surface);
}
.app-footer strong {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-light); }
