/* ============================================================
   MPCS Soluciones · Portal de Gestión
   style.css
   ============================================================ */

:root {
  --navy:        #1B2B5E;
  --navy-dark:   #132044;
  --navy-mid:    #243672;
  --navy-light:  #EEF2FB;
  --accent:      #2E4DB0;
  --accent-soft: #DBEAFE;
  --text:        #1a1a2e;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;
  --border:      rgba(0,0,0,0.08);
  --border-md:   rgba(0,0,0,0.14);
  --bg:          #f4f6fb;
  --bg-card:     #ffffff;
  --white:       #ffffff;
  --success:     #059669;
  --success-bg:  #D1FAE5;
  --warning:     #D97706;
  --warning-bg:  #FEF3C7;
  --error:       #DC2626;
  --error-bg:    #FEE2E2;
  --info:        #2563EB;
  --info-bg:     #DBEAFE;
  --sidebar-w:   240px;
  --header-h:    56px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.10);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── LOGIN ── */
.page-login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 2rem 1rem;
  background: linear-gradient(135deg, #0f1729 0%, #1B2B5E 50%, #243672 100%);
}
.login-container { width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { display: inline-flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.login-logo .mpc  { font-size: 36px; font-weight: 800; color: #fff; letter-spacing: -2px; }
.login-logo .sol  { font-size: 16px; font-weight: 400; color: rgba(255,255,255,0.6); }
.login-tagline    { font-size: 13px; color: rgba(255,255,255,0.45); letter-spacing: 0.05em; text-transform: uppercase; }
.login-card {
  background: var(--white); border-radius: var(--radius-xl);
  padding: 2rem; box-shadow: 0 24px 48px rgba(0,0,0,0.3);
}
.login-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.login-card .sub { font-size: 13px; color: var(--text-muted); margin-bottom: 1.5rem; }
.login-footer { text-align: center; margin-top: 1.25rem; font-size: 12px; color: rgba(255,255,255,0.35); }

/* ── LAYOUT PORTAL ── */
.portal-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); background: var(--navy); position: fixed;
  top: 0; left: 0; height: 100vh; display: flex; flex-direction: column;
  z-index: 100; transition: transform 0.25s;
}
.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo { display: flex; align-items: baseline; gap: 6px; }
.sidebar-logo .mpc { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -1px; }
.sidebar-logo .sol { font-size: 12px; color: rgba(255,255,255,0.5); font-weight: 400; }
.sidebar-tagline { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 2px; letter-spacing: 0.04em; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section { padding: 0 0.75rem; margin-bottom: 0.5rem; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.3);
  padding: 0.5rem 0.5rem 0.25rem;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  color: rgba(255,255,255,0.65); font-size: 13px; font-weight: 400;
  text-decoration: none; cursor: pointer; transition: all 0.15s;
  margin-bottom: 2px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 20px;
  background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.8);
}
.nav-badge.alert { background: #DC2626; color: #fff; }

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  cursor: pointer; transition: background 0.15s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.08); }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.4); text-transform: capitalize; }
.sidebar-logout {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.4); padding: 4px; border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.sidebar-logout:hover { color: #fff; }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}
.page-header {
  background: var(--white); padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-header-left h1 { font-size: 18px; font-weight: 600; }
.page-header-left p  { font-size: 13px; color: var(--text-muted); margin-top: 1px; }
.page-header-right { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 1.75rem 2rem; flex: 1; }

/* ── STATS CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 1.75rem; }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon.blue   { background: var(--navy-light); color: var(--navy); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red    { background: var(--error-bg);   color: var(--error); }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-delta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--error); }

/* ── CARDS ── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 14px; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ── TABLA ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500; padding: 3px 8px;
  border-radius: 20px; white-space: nowrap;
}
.badge-blue    { background: var(--navy-light); color: var(--navy); }
.badge-green   { background: var(--success-bg); color: var(--success); }
.badge-yellow  { background: var(--warning-bg); color: var(--warning); }
.badge-red     { background: var(--error-bg);   color: var(--error); }
.badge-gray    { background: #F3F4F6; color: #6B7280; }
.badge-purple  { background: #EDE9FE; color: #6D28D9; }

/* ── BOTONES ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500; padding: 8px 16px;
  border-radius: var(--radius-md); cursor: pointer;
  border: 1px solid var(--border-md);
  background: var(--white); color: var(--text);
  transition: all 0.15s; text-decoration: none;
}
.btn:hover   { background: var(--bg); }
.btn:active  { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-sm { font-size: 12px; padding: 5px 12px; }
.btn-ghost { border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-full { width: 100%; justify-content: center; }

/* ── FORMULARIOS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.field { margin-bottom: 1rem; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .field textarea {
  width: 100%; font-size: 13px; padding: 8px 10px;
  border: 1px solid var(--border-md); border-radius: var(--radius-md);
  background: var(--white); color: var(--text); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,77,176,0.1);
}
.field textarea { resize: vertical; min-height: 80px; }
.req { color: var(--error); }

/* ── ALERTS ── */
.alert { font-size: 13px; padding: 10px 14px; border-radius: var(--radius-md); margin-bottom: 1rem; }
.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid rgba(220,38,38,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5,150,105,0.2); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid rgba(37,99,235,0.2); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--white); border-radius: var(--radius-xl);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--radius-sm);
  font-size: 18px; line-height: 1;
}
.modal-close:hover { color: var(--text); background: var(--bg); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── SEARCH ── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--white); border: 1px solid var(--border-md);
  border-radius: var(--radius-md); padding: 7px 12px; min-width: 220px;
}
.search-bar input {
  border: none; outline: none; font-size: 13px;
  background: transparent; color: var(--text); flex: 1;
}
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 15px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.empty-state p  { font-size: 13px; }

/* ── LOADING ── */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--text-muted); gap: 10px; font-size: 13px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 1rem; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
