/* =============================================
   VALERIS LEGAL GROUP — ADMIN.CSS
   Panel de Administración
   ============================================= */

:root {
  --gold:        #C9A260;
  --gold-light:  #E2C27D;
  --gold-dark:   #A07840;
  --gold-faint:  rgba(201, 162, 96, 0.1);
  --gold-border: rgba(201, 162, 96, 0.25);

  --navy:        #060D1F;
  --navy-mid:    #0D1B3E;
  --navy-light:  #122248;

  --sidebar-w:   240px;
  --header-h:    64px;

  --bg:          #F0EDE8;
  --surface:     #FFFFFF;
  --border:      #E5E7EB;
  --text:        #111827;
  --text-2:      #6B7280;
  --text-3:      #9CA3AF;

  --radius:      10px;
  --shadow:      0 2px 12px rgba(0,0,0,0.07);
  --shadow-md:   0 6px 24px rgba(0,0,0,0.12);
  --transition:  all 0.25s cubic-bezier(0.4,0,0.2,1);
  --font:        'Montserrat', sans-serif;
  --font-d:      'Cormorant Garamond', serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); overflow-x: hidden; }
a  { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== LOGIN SCREEN ===== */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, var(--navy-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--gold-border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(20px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo { margin-bottom: 20px; display: flex; justify-content: center; }

.login-title {
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 4px;
  color: #fff;
  margin-bottom: 6px;
}

.login-sub {
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  margin-bottom: 36px;
}

.login-form { text-align: left; }

.login-field { margin-bottom: 20px; }

.login-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.pwd-wrap { position: relative; }

.pwd-wrap input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 13px 44px 13px 14px;
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 2px;
  outline: none;
  transition: var(--transition);
}

.pwd-wrap input:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.1);
}

.pwd-wrap input::placeholder { color: rgba(255,255,255,0.3); letter-spacing: 1px; }

.pwd-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  transition: var(--transition);
  padding: 4px;
}

.pwd-toggle:hover { color: var(--gold); }
.pwd-toggle svg { width: 18px; height: 18px; }

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #fca5a5;
  margin-bottom: 16px;
}

.login-error svg { width: 16px; height: 16px; flex-shrink: 0; }

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--navy);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 14px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  margin-bottom: 24px;
}

.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(201,162,96,0.4); }
.login-btn svg { width: 16px; height: 16px; }

.back-link {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.35);
  transition: var(--transition);
}

.back-link:hover { color: var(--gold); }

/* ===== ADMIN LAYOUT ===== */
.admin-panel {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  border-right: 1px solid rgba(201,162,96,0.15);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(201,162,96,0.12);
  margin-bottom: 12px;
}

.sidebar-brand span {
  display: block;
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 3px;
  color: #fff;
}

.sidebar-brand small {
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  color: var(--gold);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  transition: var(--transition);
  position: relative;
}

.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.sidebar-link.active {
  background: rgba(201,162,96,0.12);
  color: var(--gold);
  border: 1px solid rgba(201,162,96,0.2);
}

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.35);
  background: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  transition: var(--transition);
  width: 100%;
}

.sidebar-logout svg { width: 18px; height: 18px; }
.sidebar-logout:hover { color: #ef4444; }

/* ===== MAIN CONTENT ===== */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== ADMIN HEADER ===== */
.admin-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.header-left { display: flex; align-items: center; gap: 16px; }

.sidebar-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px;
  color: var(--text-2);
  transition: var(--transition);
  display: none;
}

.sidebar-toggle-btn:hover { border-color: var(--gold); color: var(--gold); }
.sidebar-toggle-btn svg { width: 18px; height: 18px; display: block; }

.page-title {
  font-family: var(--font-d);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 1px;
}

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

.refresh-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.refresh-btn:hover { border-color: var(--gold); color: var(--gold); }
.refresh-btn svg { width: 16px; height: 16px; }
.refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.last-update {
  font-size: 0.73rem;
  color: var(--text-3);
}

/* ===== VIEWS ===== */
.view { display: none; padding: 28px; flex: 1; }
.view.active { display: block; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sc-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sc-icon svg { width: 20px; height: 20px; }
.sc-icon.total     { background: rgba(99,102,241,0.1); color: #6366f1; }
.sc-icon.pendiente { background: rgba(245,158,11,0.1); color: #f59e0b; }
.sc-icon.proceso   { background: rgba(59,130,246,0.1); color: #3b82f6; }
.sc-icon.resuelto  { background: rgba(34,197,94,0.1);  color: #22c55e; }
.sc-icon.semana    { background: rgba(201,162,96,0.12); color: var(--gold); }
.sc-icon.paises    { background: rgba(168,85,247,0.1); color: #a855f7; }

.sc-number {
  display: block;
  font-family: var(--font-d);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.sc-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-2);
  margin-top: 3px;
}

/* ===== PANEL CARD ===== */
.panel-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-card-header h3 {
  font-family: var(--font-d);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.link-btn {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold-dark);
  background: none;
  border: none;
  transition: var(--transition);
}

.link-btn:hover { color: var(--gold); }

/* ===== MINI TABLE ===== */
.mini-table-wrap { overflow-x: auto; }

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th {
  padding: 10px 16px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.mini-table td {
  padding: 12px 16px;
  font-size: 0.84rem;
  color: var(--text);
  border-bottom: 1px solid #F3F4F6;
  white-space: nowrap;
}

.mini-table tr:last-child td { border-bottom: none; }

.mini-table tr:hover td { background: #FAFAFA; }

/* ===== CHARTS ROW ===== */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-list {
  padding: 16px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-item { display: flex; flex-direction: column; gap: 4px; }

.chart-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-item-label { font-size: 0.82rem; font-weight: 500; color: var(--text); }
.chart-item-count { font-size: 0.78rem; font-weight: 700; color: var(--text-2); }

.chart-bar-bg {
  width: 100%;
  height: 6px;
  background: #F3F4F6;
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 4px;
  transition: width 0.8s ease;
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  min-width: 280px;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,162,96,0.1);
}

.search-box svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
}

.search-box input::placeholder { color: var(--text-3); }

.filter-select {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select:focus { border-color: var(--gold); }

.export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--navy);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-border);
  transition: var(--transition);
}

.export-btn:hover { background: var(--gold); color: var(--navy); }
.export-btn svg { width: 15px; height: 15px; }

.results-info {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ===== FULL TABLE ===== */
.table-card { overflow: hidden; }

.table-wrap { overflow-x: auto; }

.full-table {
  width: 100%;
  border-collapse: collapse;
}

.full-table th {
  padding: 11px 16px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.full-table th.sortable { cursor: pointer; }
.full-table th.sortable:hover { color: var(--gold-dark); }
.sort-icon { font-size: 0.7rem; opacity: 0.5; }
.full-table th.sort-asc .sort-icon::after  { content: '↑'; opacity: 1; }
.full-table th.sort-desc .sort-icon::after { content: '↓'; opacity: 1; }

.full-table td {
  padding: 13px 16px;
  font-size: 0.83rem;
  color: var(--text);
  border-bottom: 1px solid #F3F4F6;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.full-table tr:last-child td { border-bottom: none; }
.full-table tr:hover td { background: #FAFAFA; }

.table-empty {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--text-3);
  font-size: 0.88rem;
  white-space: normal !important;
}

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-pendiente   { background: rgba(245,158,11,0.12); color: #d97706; border: 1px solid rgba(245,158,11,0.3); }
.badge-en_proceso  { background: rgba(59,130,246,0.12);  color: #2563eb; border: 1px solid rgba(59,130,246,0.3); }
.badge-contactado  { background: rgba(168,85,247,0.12); color: #9333ea; border: 1px solid rgba(168,85,247,0.3); }
.badge-resuelto    { background: rgba(34,197,94,0.12);   color: #16a34a; border: 1px solid rgba(34,197,94,0.3); }
.badge-cerrado     { background: rgba(107,114,128,0.12); color: #6b7280; border: 1px solid rgba(107,114,128,0.3); }

.badge-baja    { background: rgba(107,114,128,0.1); color: #9ca3af; }
.badge-normal  { background: rgba(59,130,246,0.1);  color: #60a5fa; }
.badge-alta    { background: rgba(245,158,11,0.1);  color: #f59e0b; }
.badge-urgente { background: rgba(239,68,68,0.1);   color: #ef4444; }

/* ===== ACTION BUTTONS ===== */
.action-btns { display: flex; gap: 6px; }

.action-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: var(--transition);
}

.action-btn:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-faint); }
.action-btn svg { width: 14px; height: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: var(--font-d);
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: none;
  font-size: 1rem;
  color: var(--text-2);
  transition: var(--transition);
}

.modal-close:hover { border-color: #ef4444; color: #ef4444; }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #F9FAFB;
}

.modal-cancel {
  padding: 9px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: none;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-2);
  transition: var(--transition);
}

.modal-cancel:hover { border-color: var(--text-2); color: var(--text); }

.modal-save {
  padding: 9px 22px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--navy-mid), var(--navy-light));
  color: var(--gold);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid var(--gold-border);
  transition: var(--transition);
}

.modal-save:hover { background: linear-gradient(135deg, var(--gold-dark), var(--gold)); color: var(--navy); }

/* Modal fields */
.modal-field-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-field { margin-bottom: 0; }

.modal-field label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 5px;
}

.modal-field .field-value {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.modal-field select,
.modal-field textarea,
.modal-field input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  color: var(--text);
  background: #F9FAFB;
  outline: none;
  transition: var(--transition);
  resize: vertical;
}

.modal-field select:focus,
.modal-field textarea:focus,
.modal-field input[type="text"]:focus {
  border-color: var(--gold);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(201,162,96,0.1);
}

.modal-mensaje {
  background: #F9FAFB;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.87rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 16px;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  background: var(--navy);
  color: var(--gold);
  border: 1px solid var(--gold-border);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  animation: toast-in 0.3s ease;
  max-width: 320px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast.success { border-color: rgba(34,197,94,0.3); color: #22c55e; }
.toast.error   { border-color: rgba(239,68,68,0.3); color: #ef4444; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.3);
  }

  .admin-main { margin-left: 0; }

  .sidebar-toggle-btn { display: flex; }

  .charts-row { grid-template-columns: 1fr; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .search-box { min-width: 0; flex: 1; }

  .modal-field-group { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .view { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 14px; }
  .sc-number { font-size: 1.5rem; }
}
