/*
 * PsicoAdmin — CSS compartido
 * Paleta unificada para sitio público + panel admin
 * Responsive: 1024 / 768 / 480
 */

/* ── Variables de diseño ─────────────────────────────────────── */
:root {
    /* Paleta sage (gama unificada) */
    --sage-100: #f1f4f0;
    --sage-200: #d7e2d9;
    --sage-300: #b5cab8;
    --sage-400: #8fab92;
    --sage-500: #7c9082;   /* color principal */
    --sage-600: #637368;   /* hover */
    --sage-700: #4a5d4e;   /* texto/fondo oscuro */
    --sage-800: #344040;
    --sage-900: #202e23;

    /* Tonos de acento cálido (no rompe la gama) */
    --warm-100: #faf6f1;
    --warm-300: #e8d9c5;
    --warm-500: #c4956a;

    /* Neutros */
    --white:    #ffffff;
    --gray-50:  #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-800: #1f2937;

    /* Semánticos */
    --color-success:  #2d7a4f;
    --color-warning:  #9a6c00;
    --color-danger:   #991b1b;
    --color-info:     #1e4d8c;

    --color-success-bg: #d1f0e0;
    --color-warning-bg: #fef3c7;
    --color-danger-bg:  #fee2e2;
    --color-info-bg:    #dbeafe;

    /* Tipografía */
    --font-serif: 'Cormorant Garamond', 'Playfair Display', Georgia, serif;
    --font-sans:  'DM Sans', 'Inter', system-ui, sans-serif;

    /* Espacios */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  20px;

    /* Sombras */
    --shadow-sm:  0 1px 4px rgba(0,0,0,.06);
    --shadow-md:  0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:  0 12px 36px rgba(0,0,0,.12);
    --shadow-xl:  0 24px 60px rgba(0,0,0,.18);
}

/* ── Reset mínimo ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    color: var(--gray-800);
    background: var(--white);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
button { font-family: var(--font-sans); cursor: pointer; }
input, textarea, select { font-family: var(--font-sans); }

/* ── Utilidades compartidas ─────────────────────────────────── */
.serif        { font-family: var(--font-serif); }
.text-sage    { color: var(--sage-500); }
.text-muted   { color: var(--gray-400); }
.text-sm      { font-size: 0.85rem; }
.text-xs      { font-size: 0.75rem; }

/* Badges de estado */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.25rem 0.75rem; border-radius: 50px;
    font-size: 0.72rem; font-weight: 500; letter-spacing: 0.02em;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger);  }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info);    }
.badge-sage    { background: var(--sage-200);         color: var(--sage-700);      }

/* Botones base */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.7rem 1.5rem; border-radius: var(--radius-md);
    font-size: 0.85rem; font-weight: 500; border: none;
    transition: all 0.2s ease; white-space: nowrap; cursor: pointer;
}
.btn-sage-primary {
    background: var(--sage-500); color: var(--white);
}
.btn-sage-primary:hover { background: var(--sage-600); }

.btn-sage-dark {
    background: var(--sage-700); color: var(--white);
}
.btn-sage-dark:hover { background: var(--sage-800); }

.btn-outline-sage {
    background: transparent; color: var(--sage-700);
    border: 1.5px solid var(--sage-300);
}
.btn-outline-sage:hover { background: var(--sage-100); }

.btn-ghost {
    background: transparent; color: var(--sage-700);
    border: none; padding: 0.4rem 0.75rem;
}
.btn-ghost:hover { background: var(--sage-100); }

.btn-danger {
    background: var(--color-danger-bg); color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger); color: white; }

.btn-sm { padding: 0.4rem 1rem; font-size: 0.78rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-pill { border-radius: 50px; }

/* Spinner de carga */
.spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: rgba(255,255,255,.9);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast / Notificación */
#toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
    background: var(--sage-700); color: var(--white);
    padding: 0.85rem 1.25rem; border-radius: var(--radius-lg);
    font-size: 0.85rem; box-shadow: var(--shadow-xl);
    display: none; align-items: center; gap: 0.5rem;
    max-width: 300px; line-height: 1.4;
}
#toast.show {
    display: flex;
    animation: toastIn .3s ease forwards;
}
#toast.toast-error { background: var(--color-danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Formularios base ────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; font-size: 0.75rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--gray-600); margin-bottom: 0.4rem;
}
.form-control {
    width: 100%; padding: 0.75rem 1rem;
    border: 1.5px solid var(--gray-200); border-radius: var(--radius-md);
    font-size: 0.92rem; color: var(--gray-800);
    background: var(--white); outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus {
    border-color: var(--sage-500);
    box-shadow: 0 0 0 3px rgba(124,144,130,.15);
}
.form-control::placeholder { color: var(--gray-400); }

.form-control-line {
    width: 100%; border: none; border-bottom: 1.5px solid var(--gray-200);
    padding: 0.75rem 0; font-size: 0.95rem; outline: none;
    background: transparent; color: var(--gray-800);
    transition: border-color .2s;
}
.form-control-line:focus { border-color: var(--sage-700); }
.form-control-line::placeholder { color: var(--gray-400); }

/* ── Tabla admin ─────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
    font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.12em; color: var(--gray-400);
    padding: 0.75rem 1rem; text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 600;
}
.admin-table td {
    padding: 0.9rem 1rem; border-bottom: 1px solid var(--gray-100);
    font-size: 0.88rem; vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr { transition: background .15s; }
.admin-table tbody tr:hover td { background: var(--sage-100); }

/* ── Card ────────────────────────────────────────────────────── */
.card {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm); padding: 1.75rem;
    border: 1px solid var(--gray-100);
}
.card-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 1.5rem;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }

/* ── ADMIN: Layout Sidebar ───────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 256px; flex-shrink: 0;
    background: var(--sage-800);
    display: flex; flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
}

.sidebar-brand {
    padding: 1.75rem 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-logo {
    font-family: var(--font-serif); font-size: 1.55rem; font-weight: 600;
    color: var(--white); line-height: 1.2;
}
.sidebar-brand .brand-logo span { color: var(--sage-300); }
.sidebar-brand .brand-sub {
    font-size: 0.68rem; color: rgba(255,255,255,.4);
    margin-top: 0.25rem; letter-spacing: 0.05em;
}

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }
.sidebar-section {
    font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.16em;
    color: rgba(255,255,255,.25); padding: 1.25rem 0.75rem 0.4rem;
    font-weight: 600;
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem; border-radius: var(--radius-md);
    color: rgba(255,255,255,.6); font-size: 0.87rem;
    transition: all .18s; margin-bottom: 0.15rem;
    cursor: pointer; border: none; background: none; width: 100%;
    text-align: left;
}
.sidebar-link:hover {
    background: rgba(255,255,255,.07);
    color: var(--white);
}
.sidebar-link.active {
    background: var(--sage-500);
    color: var(--white); font-weight: 500;
    box-shadow: 0 2px 8px rgba(124,144,130,.4);
}
.sidebar-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
    display: flex; align-items: center; gap: 0.75rem;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--sage-500); display: flex;
    align-items: center; justify-content: center;
    font-size: 0.78rem; font-weight: 600; color: var(--white);
    flex-shrink: 0;
}
.user-name { font-size: 0.85rem; color: var(--white); font-weight: 500; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,.4); }
.btn-logout-sidebar {
    margin-left: auto; background: none; border: none;
    color: rgba(255,255,255,.35); cursor: pointer;
    font-size: 1rem; padding: 0.3rem; border-radius: 6px;
    transition: all .2s;
}
.btn-logout-sidebar:hover { color: #fca5a5; background: rgba(239,68,68,.1); }

/* ── ADMIN: Main area ────────────────────────────────────────── */
.admin-main { flex: 1; background: var(--sage-100); overflow-y: auto; }
.admin-topbar {
    background: var(--white); padding: 1.25rem 2rem;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--gray-100);
    box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 10;
}
.admin-title {
    font-family: var(--font-serif); font-size: 1.6rem;
    font-weight: 600; color: var(--sage-700);
}
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.topbar-greeting { font-size: 0.83rem; color: var(--gray-400); }
.topbar-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--sage-500); display: flex;
    align-items: center; justify-content: center;
    font-size: 0.8rem; color: var(--white); font-weight: 600;
    cursor: pointer;
}
.admin-content { padding: 2rem; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; margin-bottom: 1.75rem; }
.stat-card {
    background: var(--white); border-radius: var(--radius-lg);
    padding: 1.5rem; border-left: 4px solid;
    box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card-sage    { border-color: var(--sage-500); }
.stat-card-warm    { border-color: var(--warm-500); }
.stat-card-dark    { border-color: var(--sage-700); }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gray-400); margin-bottom: 0.5rem; font-weight: 600; }
.stat-value { font-family: var(--font-serif); font-size: 2.8rem; font-weight: 600; line-height: 1; color: var(--sage-700); }
.stat-trend { font-size: 0.72rem; margin-top: 0.5rem; color: var(--color-success); }
.stat-trend.down { color: var(--color-warning); }

/* Mini barras de gráfico */
.mini-chart { display: flex; align-items: flex-end; gap: 5px; height: 56px; }
.chart-bar {
    flex: 1; background: linear-gradient(to top, var(--sage-500), var(--sage-300));
    border-radius: 3px 3px 0 0; transition: opacity .2s;
}
.chart-bar:hover { opacity: .75; }
.chart-labels { display: flex; gap: 5px; margin-top: 0.4rem; }
.chart-labels span { flex: 1; font-size: 0.6rem; text-align: center; color: var(--gray-400); }

/* ── MODAL (login) ───────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(32,46,35,.65); backdrop-filter: blur(5px);
    z-index: 900; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--white); border-radius: var(--radius-xl);
    padding: 2.5rem; width: 100%; max-width: 400px;
    box-shadow: var(--shadow-xl); position: relative;
    animation: modalIn .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn {
    from { opacity:0; transform: scale(.88) translateY(18px); }
    to   { opacity:1; transform: scale(1)  translateY(0); }
}
.modal-close {
    position: absolute; top: 1rem; right: 1rem;
    background: var(--sage-100); border: none;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: .85rem; color: var(--gray-600); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.modal-close:hover { background: var(--sage-200); }

/* Chips de seguridad */
.security-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.25rem; }
.sec-chip {
    display: flex; align-items: center; gap: 0.25rem;
    font-size: 0.62rem; background: var(--sage-100);
    color: var(--sage-700); padding: 0.2rem 0.6rem;
    border-radius: 50px; border: 1px solid var(--sage-200);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .admin-sidebar  { width: 220px; }
    .stats-grid     { grid-template-columns: 1fr 1fr; }
    .admin-content  { padding: 1.5rem; }
}

@media (max-width: 768px) {
    .admin-layout   { flex-direction: column; }
    .admin-sidebar  { width: 100%; flex-direction: row; flex-wrap: wrap; }
    .sidebar-brand  { padding: 1rem 1.5rem; }
    .sidebar-nav    { display: flex; flex-wrap: wrap; padding: 0.5rem; width: 100%; }
    .sidebar-section { display: none; }
    .sidebar-link   { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
    .sidebar-footer { display: none; }
    .stats-grid     { grid-template-columns: 1fr; }
    .admin-topbar   { padding: 1rem 1.25rem; }
    .admin-content  { padding: 1rem 1.25rem; }
}

@media (max-width: 480px) {
    .admin-title    { font-size: 1.3rem; }
    .stat-value     { font-size: 2.2rem; }
    .card           { padding: 1.25rem; }
    .admin-table th, .admin-table td { padding: 0.65rem 0.75rem; }
    .btn            { padding: 0.6rem 1.1rem; font-size: 0.82rem; }
}
