/* redesia.net — tema claro, mobile-first, inspirado en IAcontac
   Móvil:   top header + contenido + bottom tab bar (5 tabs)
   Desktop: sidebar izq + top header + contenido (>= 900px)            */

:root {
  /* paleta */
  --bg:           #f7f8fc;
  --bg-elev:      #ffffff;
  --bg-soft:      #f3f4f8;
  --border:       #e5e7eb;
  --border-soft:  #eef0f4;
  --text:         #111827;
  --text-2:       #4b5563;
  --text-dim:     #9ca3af;

  --primary:      #2563eb;
  --primary-soft: #dbeafe;
  --primary-2:    #1e40af;

  --green:        #10b981;
  --green-soft:   #d1fae5;
  --blue:         #3b82f6;
  --blue-soft:    #dbeafe;
  --orange:       #f97316;
  --orange-soft:  #ffedd5;
  --pink:         #ec4899;
  --pink-soft:    #fce7f3;
  --cyan:         #06b6d4;
  --cyan-soft:    #cffafe;
  --yellow:       #eab308;
  --yellow-soft:  #fef9c3;
  --red:          #ef4444;
  --red-soft:     #fee2e2;

  --shadow-sm:    0 1px 2px rgba(15,23,42,.04);
  --shadow:       0 2px 8px rgba(15,23,42,.06);
  --radius:       12px;
  --radius-sm:    8px;

  --sidebar-w:    240px;
  --topbar-h:     56px;
  --bottomtab-h:  68px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text",
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .85rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

p  { margin: 0 0 1em; }
small { color: var(--text-2); }
code { background: var(--bg-soft); padding: .15em .4em; border-radius: 4px; font-size: .9em; }

/* ============ APP SHELL ============ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: var(--topbar-h) 1fr var(--bottomtab-h);
  grid-template-areas:
    "topbar"
    "main"
    "tabs";
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar main";
  }
}

/* ============ TOPBAR ============ */
.topbar {
  grid-area: topbar;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand {
  font-weight: 700; font-size: 1.05rem; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.topbar .brand .ia { color: var(--primary); }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .greet { color: var(--text-2); font-size: .9rem; display: none; }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.topbar .nav-logout {
  color: var(--text-2); font-size: .85rem;
  padding: 6px 12px; border-radius: 6px;
}
.topbar .nav-logout:hover { background: var(--bg-soft); text-decoration: none; }

@media (min-width: 540px) { .topbar .greet { display: inline; } }
@media (min-width: 900px) { .topbar { padding: 0 24px; } }

/* ============ SIDEBAR (desktop) ============ */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar .brand-block {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 12px;
}
.sidebar .brand-block .name {
  font-weight: 700; font-size: 1.15rem;
}
.sidebar .brand-block .name .ia { color: var(--primary); }
.sidebar .brand-block .tag {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: .65rem; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  margin-top: 4px;
  text-transform: uppercase;
}
.sidebar .group-label {
  padding: 14px 20px 6px;
  font-size: .7rem; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--text-2);
  font-size: .9rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.sidebar a.nav-item:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar a.nav-item.activo {
  background: var(--primary-soft);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.sidebar a.nav-item .ico { width: 20px; text-align: center; font-size: 1.05rem; }

@media (min-width: 900px) { .sidebar { display: flex; } }

/* ============ MAIN ============ */
.main {
  grid-area: main;
  padding: 16px;
  overflow-y: auto;
  padding-bottom: calc(var(--bottomtab-h) + 16px);
}
@media (min-width: 900px) {
  .main { padding: 24px 32px; padding-bottom: 24px; }
}
.main .container { max-width: 1200px; margin: 0 auto; }
.main .container.narrow { max-width: 460px; }

/* ============ PAGE HEADER ============ */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 1.45rem; }
.page-head .subtitle { color: var(--text-2); font-size: .9rem; margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ SECTIONS (grupos de cards) ============ */
.section {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.section .section-label {
  display: block;
  font-size: .7rem; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 12px;
  padding: 0 4px;
}
.section .stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 540px) { .section .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .section .stats-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .section .stats-grid { grid-template-columns: repeat(5, 1fr); } }

/* ============ STAT CARD ============ */
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: left;
}
.stat-card .label {
  display: block;
  font-size: .75rem;
  color: var(--text-2);
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}
.stat-card .unit { font-size: .8rem; color: var(--text-dim); font-weight: 500; margin-left: 2px; }
.stat-card.green   .value { color: var(--green); }
.stat-card.blue    .value { color: var(--blue); }
.stat-card.orange  .value { color: var(--orange); }
.stat-card.pink    .value { color: var(--pink); }
.stat-card.cyan    .value { color: var(--cyan); }
.stat-card.yellow  .value { color: var(--yellow); }
.stat-card.red     .value { color: var(--red); }
/* tono pastel sobre fondo (para destacar grupo) */
.stat-card.soft.yellow  { background: var(--yellow-soft);  border-color: transparent; }
.stat-card.soft.orange  { background: var(--orange-soft);  border-color: transparent; }
.stat-card.soft.pink    { background: var(--pink-soft);    border-color: transparent; }
.stat-card.soft.green   { background: var(--green-soft);   border-color: transparent; }

/* ============ TARJETAS DE CONTENIDO (no stats) ============ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card.accent { border-left: 4px solid var(--primary); }
.card h2 { margin-top: 0; }
.card .muted { color: var(--text-2); font-size: .9rem; }
.card .quote {
  border-left: 3px solid var(--primary);
  padding-left: 12px; margin: 12px 0;
  color: var(--text-2); font-style: italic;
  background: var(--primary-soft);
  padding: 10px 12px;
  border-radius: 6px;
}
.card .quote .author { display: block; font-style: normal; font-size: .8rem; margin-top: 4px; color: var(--text-dim); }
.card .highlight {
  background: var(--bg-soft);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin: 10px 0;
}
.card .highlight strong { color: var(--primary); }

/* ============ FORM ============ */
form label {
  display: block;
  margin-bottom: 12px;
  color: var(--text);
  font-size: .9rem;
  font-weight: 500;
}
form input, form textarea, form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}
form input:focus, form textarea:focus, form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
form textarea { min-height: 100px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.block { display: block; width: 100%; }
.btn.small { padding: 6px 12px; font-size: .85rem; }

/* ============ ALERTAS ============ */
.alert {
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px;
  border: 1px solid; font-size: .9rem;
}
.alert.error   { background: var(--red-soft);    border-color: #fecaca; color: #991b1b; }
.alert.success { background: var(--green-soft);  border-color: #a7f3d0; color: #065f46; }
.alert.info    { background: var(--blue-soft);   border-color: #bfdbfe; color: #1e40af; }

/* ============ BOTTOM TAB BAR (móvil) ============ */
.bottom-tabs {
  grid-area: tabs;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  position: sticky; bottom: 0; z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-tabs a {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-dim);
  font-size: .68rem;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 4px;
  border-top: 2px solid transparent;
  gap: 2px;
}
.bottom-tabs a .ico { font-size: 1.4rem; }
.bottom-tabs a.activo {
  color: var(--primary);
  border-top-color: var(--primary);
}
.bottom-tabs a:active { background: var(--bg-soft); }
@media (min-width: 900px) { .bottom-tabs { display: none; } }

/* ============ LOGIN / INSTALL (sin shell) ============ */
body.login, body.install {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
  background: linear-gradient(180deg, #f7f8fc 0%, #dbeafe 100%);
}
body.login .container, body.install .container {
  background: var(--bg-elev);
  padding: 28px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
}
body.login .brand-big, body.install .brand-big {
  text-align: center; margin-bottom: 8px;
  font-size: 1.6rem; font-weight: 700;
}
body.login .brand-big .ia, body.install .brand-big .ia { color: var(--primary); }
body.login .subtitle, body.install .subtitle {
  text-align: center; color: var(--text-2); font-size: .9rem; margin-bottom: 20px;
}

/* ============ misc ============ */
.muted { color: var(--text-2); }
.dim   { color: var(--text-dim); }
.center { text-align: center; }
.mt-0  { margin-top: 0; }
.mt-2  { margin-top: 8px; }
.mb-0  { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
