/**
 * TuAPI Chat — App styles (mobile-first)
 */

:root {
    --color-primary: #0d9488;
    --color-primary-dark: #0f766e;
    --color-accent: #7c3aed;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-muted: #f1f5f9;
    --color-text: #0f172a;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --header-h: 56px;

    /* Panel Clientes / historial — tokens compartidos con theme.css */
    --panel-bg: #f7f8fa;
    --panel-surface: #ffffff;
    --panel-surface-muted: #f5f6f6;
    --panel-hover: #f5f6f6;
    --panel-border-soft: #f0f2f5;
    --panel-text-strong: #111b21;
    --panel-text-secondary: #667781;
    --panel-sticky-day: #f0f2f5;
    --panel-warn: #b45309;
    --panel-badge-ro-bg: #e7f8f2;
    --panel-badge-ro-text: #008069;
    --panel-backdrop: rgba(15, 23, 42, 0.28);
    --panel-summary-bg: color-mix(in srgb, var(--color-primary) 8%, #fff);
    --panel-summary-border: color-mix(in srgb, var(--color-primary) 18%, var(--color-border));
    --panel-expiration-bg: #fffbeb;
    --panel-expiration-border: #fde68a;
    --panel-avatar-bg: color-mix(in srgb, var(--color-primary) 14%, #e8eef0);
    --panel-avatar-tuapi-bg: color-mix(in srgb, var(--color-primary) 22%, #fff);

    /* Composer + bottom nav móvil */
    --composer-bg: #f0f2f5;
    --composer-input-bg: #ffffff;
    --composer-border: rgba(15, 23, 42, 0.08);
    --bottom-nav-bg: #ffffff;
    --bottom-nav-border: rgba(15, 23, 42, 0.08);
    --bottom-nav-muted: #64748b;
    --bottom-nav-shadow: 0 -4px 18px rgba(15, 23, 42, 0.06);
}

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

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    --header-h: 52px;
    font-size: 16px;
    flex-shrink: 0;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
    min-height: 40px;
    flex: 0 0 auto;
}

.app-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff;
    font-size: 0.75rem;
    flex: 0 0 2rem;
}

.app-brand__mark-img {
    display: block;
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
}

.app-brand--tuapi .app-brand__mark-img {
    width: 2.15rem;
    height: 2.15rem;
    flex-basis: 2.15rem;
}

.app-brand__text {
    font-size: 1rem;
    white-space: nowrap;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.875rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    min-width: 0;
    flex: 1 1 auto;
    overflow: visible;
}

.app-nav__with-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 44px;
    min-width: 44px;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    line-height: 1.15;
    flex: 0 0 auto;
    box-sizing: border-box;
    white-space: nowrap;
    color: inherit;
    font: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    max-width: none;
}

.app-nav__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-nav__utility-group {
    display: inline-flex;
    align-items: center;
    gap: 0.12rem;
    flex: 0 0 auto;
}

.app-nav a,
.app-nav__current {
    color: var(--color-muted);
    text-decoration: none;
}

.app-nav a:hover { color: var(--color-primary); }

button.app-nav__with-icon {
    color: var(--color-muted);
}

.app-nav__with-icon .tuapi-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
}

.app-nav a.app-nav__with-icon:hover,
.app-nav a.app-nav__with-icon:focus-visible,
.app-nav button.app-nav__with-icon:hover,
.app-nav button.app-nav__with-icon:focus-visible {
    color: var(--color-primary);
    background: var(--color-surface-muted);
    border-color: var(--color-border);
    outline: none;
}

/* Chat + CRM workspace controls — visually paired */
.app-nav__workspace-group {
  display: inline-flex;
  align-items: center;
  gap: 0.14rem;
  flex: 0 0 auto;
  margin-left: 0.35rem;
  padding-left: 0.45rem;
  border-left: 1px solid var(--color-border);
}

.app-nav__workspace-group .app-nav__with-icon,
.app-nav__workspace-group .app-nav__current {
  margin: 0;
}

.app-nav__easy-read {
  flex-shrink: 0;
}

.app-nav__easy-read:not(.is-active) {
  opacity: 0.92;
}

.app-nav__dark-mode {
  flex-shrink: 0;
}

.app-nav__dark-mode:not(.is-active) {
  opacity: 0.92;
}

@media (max-width: 960px) {
  .app-nav__label--easy-read,
  .app-nav__label--dark-mode {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

@media (max-width: 840px) {
  .app-nav__clients .app-nav__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .app-brand__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

@media (max-width: 680px) {
  .app-nav__workspace-group .app-nav__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

@media (max-width: 720px) {
  .app-nav__label--easy-read,
  .app-nav__label--dark-mode {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.app-nav a.app-nav__with-icon:focus-visible,
.app-nav button.app-nav__with-icon:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.app-nav__current.is-active,
.app-nav__current.is-active.app-nav__with-icon {
    color: var(--color-primary-dark);
    font-weight: 600;
    background: #ede9fe;
    border-color: #ddd6fe;
}

.app-nav__pill-slot {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    flex: 0 1 auto;
    min-width: 0;
}

.app-header__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.55rem 1rem;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.app-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 2rem;
}

.app-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.hero { padding: 1rem 0 1.5rem; }
.hero--compact { padding-top: 0.5rem; }
.hero__badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: #ccfbf1;
    color: var(--color-primary-dark);
    font-size: 0.8rem;
    font-weight: 600;
}
.hero__title { margin: 0.5rem 0; font-size: clamp(1.6rem, 5vw, 2.2rem); }
.hero__tagline { margin: 0; font-size: 1.1rem; color: var(--color-primary-dark); font-weight: 600; }
.hero__desc { color: var(--color-muted); max-width: 36rem; }

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.25rem 0;
}

.home-hero {
    padding: 1.25rem 0 2rem;
    max-width: 40rem;
}
.home-hero__brand {
    margin: 0;
    font-size: clamp(1.75rem, 5vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--color-primary-dark, #0f766e);
}
.home-hero__title {
    margin: 0.65rem 0 0.5rem;
    font-size: clamp(1.25rem, 3.5vw, 1.65rem);
    font-weight: 700;
    line-height: 1.25;
}
.home-hero__lead,
.home-hero__sub {
    color: var(--color-muted);
    max-width: 36rem;
    line-height: 1.5;
}
.home-hero__sub { margin-top: 0.35rem; font-size: 0.95rem; }
.home-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 1.35rem 0 0;
}
.home-hero__alert {
    margin: 0.85rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
}
.home-hero__alert a {
    color: #9a3412;
    font-weight: 600;
    text-decoration: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.95rem;
    min-height: 44px;
    line-height: 1.2;
    box-sizing: border-box;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--secondary { background: #ede9fe; color: var(--color-accent); }
.btn--ghost { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn--danger { background: #b91c1c; color: #fff; border-color: #991b1b; }
.btn--sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    min-height: 40px;
}
.btn--icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}
.btn:disabled,
.btn[disabled],
.btn.is-loading {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.card__title { font-size: 0.8rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card__value { font-size: 1.25rem; font-weight: 700; margin-top: 0.25rem; }
.card__subtitle { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.25rem; }

.category-list { display: grid; gap: 1rem; }
.category-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
}
.category-card h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.muted { color: var(--color-muted); font-size: 0.9rem; }
.category-card__modules { font-size: 0.85rem; }

.action-list { list-style: none; padding: 0; }
.action-list li {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}
.action-list code { display: block; margin: 0.25rem 0; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    border: 0;
}

@media (min-width: 768px) {
    .app-main { padding: 1.5rem; }
}

.app-nav__bell {
  position: relative;
  min-width: 40px;
  justify-content: center;
}
.app-nav__bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
