/* ================================================================
   Portilla Consultores — Portal de Clientes
   portal.css
   ================================================================ */

:root {
  --color-primary:    #1a3d6e;
  --color-primary-h:  #153060;
  --color-accent:     #c8952a;
  --color-success:    #1d7a44;
  --color-warn:       #c8952a;
  --color-danger:     #b91c1c;
  --color-info:       #1a5fa3;
  --color-bg:         #f4f6fa;
  --color-sidebar:    #1a3d6e;
  --color-sidebar-fg: #e8eef8;
  --color-card:       #ffffff;
  --color-border:     #dde3ed;
  --color-muted:      #6b7a99;
  --font:             'Segoe UI', Arial, sans-serif;
  --sidebar-w:        240px;
  --radius:           8px;
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: #1e2b40;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout con sidebar ─────────────────────────────────────────── */
.admin-layout, .cliente-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-sidebar);
  color: var(--color-sidebar-fg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.5rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo strong { display: block; font-size: 1rem; }
.sidebar-logo small  { font-size: .75rem; opacity: .7; }

.sidebar-nav {
  list-style: none;
  margin: .5rem 0;
  padding: 0;
  flex: 1;
}
.sidebar-nav li a {
  display: block;
  padding: .6rem 1.25rem;
  color: var(--color-sidebar-fg);
  text-decoration: none;
  font-size: .875rem;
  transition: background .15s;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.sidebar-nav li a.text-danger { color: #fca5a5; }
.sidebar-nav .sep {
  height: 1px;
  background: rgba(255,255,255,.1);
  margin: .4rem 1rem;
}

.sidebar-user {
  padding: .75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .75rem;
  opacity: .8;
}

.sidebar-cliente { background: #1a3d6e; }

.main-content {
  margin-left: var(--sidebar-w);
  padding: 1.5rem 2rem;
  flex: 1;
  max-width: 100%;
}

/* ── Login page ─────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-primary);
}
.login-wrap {
  background: #fff;
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo img  { max-height: 60px; margin-bottom: .5rem; }
.login-logo h1   { font-size: 1.2rem; margin: 0; color: var(--color-primary); }
.login-logo p    { margin: .25rem 0 0; color: var(--color-muted); font-size: .85rem; }
.login-footer    { text-align: center; margin-top: 1rem; font-size: .8rem; }
.login-footer a  { color: var(--color-muted); text-decoration: none; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.card-header {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h3, .card-header h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--color-primary);
}
.card-body { padding: 1.25rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }

/* ── Stats grid ─────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card.stat-ok   { border-left: 4px solid var(--color-success); }
.stat-card.stat-warn { border-left: 4px solid var(--color-warn); }
.stat-num   { font-size: 2.5rem; font-weight: 700; color: var(--color-primary); }
.stat-label { font-size: .8rem; color: var(--color-muted); margin-top: .25rem; }
.stat-sub   { font-size: .75rem; color: var(--color-muted); }
.stat-icon  { font-size: 1.8rem; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th {
  background: #f0f4fa;
  color: var(--color-primary);
  font-weight: 600;
  padding: .6rem .85rem;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
.table td {
  padding: .55rem .85rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafd; }
.table.table-sm th,
.table.table-sm td { padding: .4rem .65rem; }
.totals-row td { background: #f0f4fa; font-weight: 600; }

.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--color-muted); }
.text-warn   { color: var(--color-warn); }
.text-danger { color: var(--color-danger); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 99px;
  font-size: .73rem;
  font-weight: 600;
}
.badge-ok   { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef9c3; color: #854d0e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .45rem 1rem;
  border-radius: 5px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, background .15s;
  line-height: 1.4;
}
.btn:hover    { opacity: .88; }
.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-secondary{ background: #e8eef8; color: var(--color-primary); }
.btn-danger   { background: #fee2e2; color: var(--color-danger); }
.btn-sm       { padding: .25rem .65rem; font-size: .8rem; }
.btn-block    { display: block; width: 100%; text-align: center; }
.mt-1         { margin-top: .5rem; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-danger  { background: #fee2e2; color: #7f1d1d; border-left: 4px solid var(--color-danger); }
.alert-success { background: #dcfce7; color: #14532d; border-left: 4px solid var(--color-success); }
.alert-info    { background: #dbeafe; color: #1e3a8a; border-left: 4px solid var(--color-info); }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-weight: 500; font-size: .85rem; color: #374151; }
.form-control {
  padding: .45rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: .9rem;
  width: 100%;
  background: #fff;
  color: #1e2b40;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(26,61,110,.12); }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}
.form-row .form-group { flex: 1 1 180px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem 1rem;
}
.col-span-2 { grid-column: span 2; }
.align-end  { justify-content: flex-end; }

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h2 { margin: 0; color: var(--color-primary); }
.page-header p  { margin: .25rem 0 0; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
}
.tab {
  background: none;
  border: none;
  padding: .5rem 1.25rem;
  font-size: .9rem;
  cursor: pointer;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font);
  transition: color .15s;
}
.tab:hover  { color: var(--color-primary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

.tab-content         { display: none; }
.tab-content.active  { display: block; }

/* ── Search input ────────────────────────────────────────────────── */
.search-input { max-width: 260px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; height: auto; }
  .main-content { margin-left: 0; padding: 1rem; }
  .admin-layout, .cliente-layout { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .page-header { flex-direction: column; gap: .5rem; }
  .stats-grid { grid-template-columns: 1fr; }
}
