/* =====================================================================
   Mini CRM a Medida — Sexto Abismo · Ellipsis
   Estilos base de Fase 1
   ===================================================================== */

:root {
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-border: #e5e8ef;
    --color-border-strong: #cdd3df;
    --color-text: #1a1f2e;
    --color-text-muted: #5b667d;
    --color-text-soft: #8a93a6;
    --color-primary: #1f6feb;
    --color-primary-dark: #1857b8;
    --color-primary-soft: #e8f0fe;
    --color-accent: #0f172a;
    --color-success: #14794a;
    --color-success-bg: #e6f5ec;
    --color-danger: #b3261e;
    --color-danger-bg: #fce8e6;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3 { margin: 0 0 0.5rem; color: var(--color-text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.0rem; }
p  { margin: 0 0 0.75rem; line-height: 1.5; color: var(--color-text-muted); }

/* =====================================================================
   AUTH (login / forgot / reset)
   ===================================================================== */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 20% 10%, rgba(31, 111, 235, 0.10), transparent 45%),
        radial-gradient(circle at 80% 90%, rgba(15, 23, 42, 0.08), transparent 50%),
        var(--color-bg);
    padding: 2rem 1rem;
}

.auth-shell {
    width: 100%;
    max-width: 420px;
    display: grid;
    gap: 1.25rem;
}

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.75rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.auth-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--color-accent);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.auth-brand h1 {
    font-size: 1.15rem;
    margin: 0;
    line-height: 1.2;
}
.auth-subtitle {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: var(--color-text-soft);
}

.auth-form h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}
.auth-help {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}
.auth-secondary {
    text-align: center;
    margin: 1rem 0 0;
    font-size: 0.9rem;
}
.auth-footer {
    text-align: center;
    color: var(--color-text-soft);
    font-size: 0.8rem;
}

/* =====================================================================
   Fields & buttons
   ===================================================================== */
.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; }
.field__label { font-size: 0.85rem; color: var(--color-text); font-weight: 500; }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 0.95rem;
    color: var(--color-text);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.field input::placeholder,
.field textarea::placeholder {
    color: var(--color-text-soft);
    opacity: 0.7;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--color-text); border-color: var(--color-border-strong); }
.btn--ghost:hover { background: var(--color-surface); border-color: var(--color-text-muted); }
.btn--block { width: 100%; }
.btn--sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }

/* =====================================================================
   Alerts
   ===================================================================== */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert--error   { background: var(--color-danger-bg);  color: var(--color-danger);  border-color: rgba(179, 38, 30, 0.25); }
.alert--success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(20, 121, 74, 0.25); }

/* =====================================================================
   Dev panel — acceso rápido (solo development)
   ===================================================================== */
.dev-panel {
    margin-top: 1.25rem;
    padding: 0.9rem;
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: #fbfbfd;
}
.dev-panel__title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dev-panel__tag {
    background: #f59e0b;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
}
.dev-panel__buttons {
    display: grid;
    gap: 0.4rem;
}
.dev-panel__btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: border-color 120ms ease, background 120ms ease;
}
.dev-panel__btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}
.dev-panel__btn strong { font-size: 0.88rem; color: var(--color-text); }
.dev-panel__btn small  { font-size: 0.76rem; color: var(--color-text-soft); }
.dev-panel__hint {
    margin: 0.6rem 0 0;
    font-size: 0.75rem;
    color: var(--color-text-soft);
    text-align: center;
}

/* =====================================================================
   App layout (logged-in)
   ===================================================================== */
.app-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.app-header__brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}
.app-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--color-accent);
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}
.app-header__brand strong {
    display: block;
    line-height: 1.2;
    font-size: 0.95rem;
}
.app-header__brand small {
    display: block;
    color: var(--color-text-soft);
    font-size: 0.75rem;
}
.app-header__user {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.app-header__user-info {
    text-align: right;
    line-height: 1.2;
}
.app-header__user-name { font-weight: 500; display: block; font-size: 0.9rem; }
.app-header__user-meta { font-size: 0.75rem; color: var(--color-text-soft); display: block; }

/* Shell: sidebar + content */
.app-shell {
    flex: 1;
    display: flex;
    align-items: stretch;
}
.app-sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
}
.app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.app-nav__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}
.app-nav__item:hover { background: var(--color-bg); text-decoration: none; }
.app-nav__item--active {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-weight: 600;
}
.app-nav__item--active:hover { background: var(--color-primary-soft); }
.app-nav__item--disabled {
    color: var(--color-text-soft);
    cursor: default;
}
.app-nav__item--disabled:hover { background: transparent; }
.app-nav__soon {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-border);
    color: var(--color-text-soft);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}
.app-sidebar__note {
    margin: auto 0 0;
    padding: 0.75rem 0.75rem 0;
    font-size: 0.72rem;
    color: var(--color-text-soft);
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 1.5rem;
}
.app-footer {
    text-align: center;
    padding: 1rem;
    color: var(--color-text-soft);
    font-size: 0.78rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

@media (max-width: 720px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .app-nav { flex-flow: row wrap; }
    .app-sidebar__note { display: none; }
}

/* =====================================================================
   Page & cards
   ===================================================================== */
.page__header { margin-bottom: 1.5rem; }
.page__subtitle { color: var(--color-text-muted); font-size: 0.95rem; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow-sm);
}
.card h3 {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-soft);
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
}
.card__big {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0 0 0.3rem;
    color: var(--color-text);
}
.card__meta { font-size: 0.8rem; color: var(--color-text-soft); margin: 0; }
.card__list { margin: 0; padding-left: 1.1rem; color: var(--color-text); font-size: 0.92rem; }
.card__list li { margin-bottom: 0.2rem; }
.card__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0.25rem 0;
    font-size: 0.88rem;
}
.card__row span { color: var(--color-text-soft); }
.card__row strong { color: var(--color-text); font-weight: 500; }

.placeholder {
    background: var(--color-surface);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    color: var(--color-text-muted);
}
.placeholder h2 { color: var(--color-text); }

.page--narrow { max-width: 620px; }
.page__header--row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

/* =====================================================================
   Tablas
   ===================================================================== */
.table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table thead th {
    text-align: left;
    padding: 0.7rem 0.9rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-soft);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.table tbody td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfd; }
.table__actions-col { text-align: right; }
.table__actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
    align-items: center;
}

/* =====================================================================
   Badges
   ===================================================================== */
.badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.5;
}
.badge--ok   { background: var(--color-success-bg); color: var(--color-success); }
.badge--off  { background: #f1f0ee; color: var(--color-text-soft); }
.badge--soft { background: var(--color-primary-soft); color: var(--color-primary-dark); }

/* =====================================================================
   Botón de peligro
   ===================================================================== */
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { background: #8f1e17; text-decoration: none; }

/* =====================================================================
   Formularios (form-card)
   ===================================================================== */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: var(--shadow-sm);
}
.field__label small { color: var(--color-text-soft); font-weight: 400; }
.field select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 0.95rem;
    color: var(--color-text);
}
.field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.field__error {
    color: var(--color-danger);
    font-size: 0.8rem;
}
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}
.field--check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}
.field--check input { width: 16px; height: 16px; }
.field--check span { font-size: 0.9rem; }
.form-card__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr; }
    .page__header--row { flex-direction: column; }
}

/* =====================================================================
   Logo de marca (configurable)
   ===================================================================== */
.brand-logo {
    height: 34px;
    width: auto;
    max-width: 150px;
    border-radius: 6px;
    object-fit: contain;
    display: block;
}
.brand-logo--auth {
    height: 48px;
    max-width: 180px;
    border-radius: 8px;
}

/* =====================================================================
   Configuración (settings)
   ===================================================================== */
.settings-section {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 1.5rem 0 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border);
}
.settings-section:first-of-type { margin-top: 0; }
.settings-note {
    font-size: 0.82rem;
    color: var(--color-text-soft);
    margin: -0.4rem 0 0.9rem;
}

.field textarea {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    resize: vertical;
}
.field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.field__color {
    width: 100%;
    height: 42px;
    padding: 0.2rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
}

/* Campo de logo: preview + control de archivo */
.logo-field {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.logo-field__preview {
    width: 84px;
    height: 84px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    display: grid;
    place-items: center;
    overflow: hidden;
}
.logo-field__preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
/* Placeholder = el ícono por defecto real (igual que en la app) */
.logo-field__default {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: var(--color-accent);
    color: #fff;
    font-size: 2.4rem;
    font-weight: 700;
}
.logo-field__controls { flex: 1; min-width: 0; }
.logo-field__controls input[type="file"] { font-size: 0.85rem; max-width: 100%; }
.logo-field__state { margin: 0 0 0.5rem; }
.logo-field__hint {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    color: var(--color-text-soft);
}

.btn--danger-text { color: var(--color-danger); margin-right: auto; }
.btn--danger-text:hover { background: var(--color-danger-bg); border-color: var(--color-danger); }
