/* ============================================================
   RM Advogados - Sistema de Documentos
   Identidade Visual: Navy + Gold + Cream
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --navy: #0b1f3a;
  --navy2: #142d52;
  --navy3: #1e3d6a;
  --gold: #c9a84c;
  --gold2: #e8c96a;
  --gold-dim: rgba(201,168,76,.15);
  --cream: #f4f0ea;
  --cream2: #e8e2d8;
  --cream3: #faf7f2;
  --text: #1a1a2e;
  --muted: #6b7280;
  --green: #16a34a;
  --green-light: rgba(22,163,74,.12);
  --red: #dc2626;
  --orange: #ea580c;
  --shadow: 0 2px 12px rgba(11,31,58,.1);
  --shadow-lg: 0 8px 32px rgba(11,31,58,.18);
  --radius: 10px;
}

html, body {
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

input, select, textarea, button { font-family: inherit; font-size: 15px; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0b1f3a 0%, #142d52 50%, #1e3d6a 100%);
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--cream3);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid #e8e0d5;
}

.login-logo { width: 100%; max-width: 240px; margin-bottom: 24px; }
.login-logo img { width: 100%; height: auto; display: block; }

.login-divider {
  width: 44px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0 auto 20px;
}

.login-title { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 4px; text-align: center; }
.login-subtitle { font-size: 12px; color: #a09690; margin-bottom: 24px; text-align: center; }

.login-group { width: 100%; margin-bottom: 16px; }
.login-group label {
  display: block; font-size: 10px; font-weight: 700;
  color: #8a7d72; letter-spacing: .08em;
  text-transform: uppercase; margin-bottom: 5px;
}
.login-group input {
  width: 100%; background: #fff;
  border: 1.5px solid #ddd6cc; border-radius: 8px;
  padding: 12px 14px; font-size: 14px; color: var(--navy);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.login-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.login-group input::placeholder { color: #c8c0b8; }

.login-btn {
  width: 100%; height: 48px;
  background: var(--navy); border: none; border-radius: 9px;
  color: #fff; font-size: 14px; font-weight: 700;
  letter-spacing: .05em; cursor: pointer;
  margin-top: 8px; transition: background .2s;
}
.login-btn:hover { background: var(--navy2); }

.login-error {
  color: var(--red); font-size: 12px;
  margin-top: 10px; text-align: center;
  display: none;
}
.login-error.show { display: block; }

.login-footer {
  margin-top: 24px; font-size: 11px;
  color: #c5bdb4; text-align: center;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
  background: var(--cream3);
  height: 70px; display: flex;
  align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--cream2), 0 2px 12px rgba(11,31,58,.06);
}

.nav-brand { display: flex; align-items: center; gap: 12px; }
.nav-brand img { height: 50px; object-fit: contain; max-width: 200px; border-radius: 4px; }
.nav-brand-text { font-size: 14px; font-weight: 700; color: var(--navy); }

.nav-right { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold); color: var(--navy);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.nav-user-name { color: var(--navy); font-size: 13px; font-weight: 500; }
.nav-user-role {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}

.btn-logout {
  background: rgba(0,0,0,.07); color: var(--navy);
  border: none; padding: 6px 14px; border-radius: 6px;
  font-size: 12px; cursor: pointer; font-weight: 600;
  transition: all .15s;
}
.btn-logout:hover { background: rgba(220,38,38,.1); color: var(--red); }

@media (max-width: 480px) {
  .nav-user-name, .nav-user-role { display: none; }
  .nav { padding: 0 12px; height: 60px; }
  .nav-brand img { height: 40px; }
}

/* ============================================================
   SIDEBAR (ADMIN)
   ============================================================ */
.layout-wrapper { display: flex; min-height: calc(100vh - 70px); }

.sidebar {
  width: 240px; background: var(--navy);
  color: white; padding: 20px 0;
  flex-shrink: 0;
  position: sticky; top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
}

.sidebar-menu { list-style: none; padding: 0; }
.sidebar-menu li { margin: 2px 8px; }
.sidebar-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 8px;
  color: rgba(255,255,255,.7); font-size: 13px;
  font-weight: 500; transition: all .15s;
  text-decoration: none;
}
.sidebar-menu a:hover { background: rgba(255,255,255,.1); color: white; }
.sidebar-menu a.active {
  background: var(--gold); color: var(--navy);
  font-weight: 700;
}
.sidebar-menu a .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-section {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(255,255,255,.4);
  padding: 16px 24px 6px; font-weight: 700;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .layout-wrapper { flex-direction: column; }
  .mobile-nav { display: flex !important; }
}

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--cream2);
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
  z-index: 100; justify-content: space-around;
}
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 12px; font-size: 10px;
  color: var(--muted); text-decoration: none;
  font-weight: 600;
}
.mobile-nav a.active { color: var(--navy); }
.mobile-nav a .icon { font-size: 20px; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content { flex: 1; padding: 24px; max-width: 1200px; }
.content-full { flex: 1; padding: 24px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -.3px; }
.page-subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 24px;
}
@media (max-width: 768px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: white; border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  border: 1px solid var(--cream2);
  border-left: 3px solid var(--gold);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card.navy { border-left-color: var(--navy); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.orange { border-left-color: var(--orange); }

.stat-label {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--muted); font-weight: 700;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); margin-top: 4px; }

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--cream2);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--cream2);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--navy); }
.card-body { padding: 20px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--muted); letter-spacing: 1.5px;
  text-transform: uppercase; margin-bottom: 7px;
}
.form-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--cream2); border-radius: 8px;
  font-size: 15px; background: var(--cream3);
  color: var(--text); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
select.form-input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px; cursor: pointer;
}
textarea.form-input { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }
.form-full { grid-column: 1 / -1; }

.form-error { color: var(--red); font-size: 12px; margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 10px 20px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .18s; text-decoration: none;
  line-height: 1.4;
}
.btn-full { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 7px; }

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

.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold2); color: var(--navy); }

.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #15803d; color: white; }

.btn-red { background: var(--red); color: white; }
.btn-red:hover { background: #b91c1c; color: white; }

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1.5px solid var(--cream2);
}
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--cream2);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  background: var(--cream); color: var(--navy);
  font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; padding: 12px 16px;
  text-align: left; font-weight: 700;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--cream2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(201,168,76,.04); }

.table-empty {
  text-align: center; padding: 48px; color: var(--muted);
}
.table-empty .icon { font-size: 36px; margin-bottom: 8px; }

@media (max-width: 768px) {
  .hide-mobile { display: none; }
  td, th { padding: 10px 12px; font-size: 13px; }
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px;
  font-weight: 700; white-space: nowrap;
}
.badge-admin { background: var(--navy); color: white; }
.badge-gerente { background: #ca8a04; color: white; }
.badge-agente { background: var(--cream2); color: var(--text); }
.badge-ativo { background: var(--green-light); color: var(--green); }
.badge-inativo { background: rgba(220,38,38,.1); color: var(--red); }

.badge-prev { background: #1e40af; color: white; }
.badge-banc { background: #047857; color: white; }
.badge-cons { background: #9333ea; color: white; }
.badge-outro { background: var(--muted); color: white; }

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */
.search-bar {
  display: flex; gap: 10px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: center;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap .icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--muted);
  pointer-events: none; font-size: 16px;
}
.search-input-wrap .form-input { padding-left: 36px; }

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 7px 14px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--cream2); border-radius: 8px;
  background: var(--cream3); color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.filter-chip:hover, .filter-chip.active {
  border-color: var(--gold); color: var(--navy);
  background: var(--gold-dim);
}

/* ============================================================
   MODAL / OVERLAY
   ============================================================ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: white; border-radius: 16px;
  box-shadow: var(--shadow-lg); width: 100%;
  max-width: 560px; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--cream2);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--navy); }
.modal-close {
  background: rgba(0,0,0,.08); border: none;
  color: var(--navy); width: 32px; height: 32px;
  border-radius: 6px; cursor: pointer; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--cream2);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ============================================================
   FILE UPLOAD
   ============================================================ */
.upload-area {
  border: 2px dashed var(--cream2); border-radius: var(--radius);
  padding: 40px 24px; text-align: center;
  cursor: pointer; transition: all .2s;
  background: var(--cream3);
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--gold); background: var(--gold-dim);
}
.upload-area .icon { font-size: 40px; margin-bottom: 12px; color: var(--gold); }
.upload-area .text { font-size: 14px; color: var(--muted); }
.upload-area .hint { font-size: 11px; color: #b5a99e; margin-top: 6px; }

.file-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--cream3);
  border-radius: 8px; margin-top: 12px;
  border: 1px solid var(--cream2);
}
.file-preview .file-icon { font-size: 24px; }
.file-preview .file-info { flex: 1; }
.file-preview .file-name { font-size: 13px; font-weight: 600; color: var(--navy); }
.file-preview .file-size { font-size: 11px; color: var(--muted); }
.file-preview .file-remove {
  background: none; border: none; color: var(--red);
  cursor: pointer; font-size: 18px; padding: 4px;
}

/* ============================================================
   TOAST / ALERTS
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--navy); color: white;
  padding: 12px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 2000;
  transition: transform .3s ease;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.alert {
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
}
.alert-success { background: var(--green-light); color: #15803d; border: 1px solid rgba(22,163,74,.2); }
.alert-error { background: rgba(220,38,38,.08); color: var(--red); border: 1px solid rgba(220,38,38,.2); }
.alert-info { background: rgba(59,130,246,.08); color: #1d4ed8; border: 1px solid rgba(59,130,246,.2); }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-navy { color: var(--navy); }
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cream2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* ============================================================
   RESPONSIVE PADDING
   ============================================================ */
@media (max-width: 768px) {
  .content, .content-full { padding: 16px; }
  .page-title { font-size: 20px; }
  .stats-grid { gap: 8px; }
  .stat-value { font-size: 22px; }
  body { padding-bottom: 60px; }
}

/* ============================================================
   GOOGLE DRIVE STATUS
   ============================================================ */
.gdrive-status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
}
.gdrive-status.connected { background: var(--green-light); color: var(--green); }
.gdrive-status.disconnected { background: rgba(220,38,38,.08); color: var(--red); }

/* ============================================================
   USER LIST CARDS
   ============================================================ */
.user-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-bottom: 1px solid var(--cream2);
  transition: background .15s;
}
.user-card:last-child { border-bottom: none; }
.user-card:hover { background: rgba(201,168,76,.04); }
.user-card .user-info { flex: 1; min-width: 0; }
.user-card .user-name { font-weight: 700; color: var(--navy); font-size: 14px; }
.user-card .user-email { font-size: 12px; color: var(--muted); }
.user-card .user-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ============================================================
   DOCUMENT GRID VIEW
   ============================================================ */
.doc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.doc-card {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--cream2); padding: 18px;
  box-shadow: var(--shadow); transition: all .15s;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.doc-card .doc-icon { font-size: 28px; margin-bottom: 10px; }
.doc-card .doc-title { font-size: 14px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.doc-card .doc-meta { font-size: 12px; color: var(--muted); }
.doc-card .doc-actions { margin-top: 12px; display: flex; gap: 6px; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  .nav, .sidebar, .mobile-nav, .btn, .search-bar, .filter-chips { display: none !important; }
  .content { padding: 0; max-width: 100%; }
  .layout-wrapper { display: block; }
  body { background: white; }
}
