/* ═══════════════════════════════════════════════════════════
   TUKU — Pre-personajes · Global styles
   ═══════════════════════════════════════════════════════════ */

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

:root {
    --sidebar-w: 220px;
    --sidebar-collapsed-w: 60px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: 0.18s ease;

    /* Neutros */
    --bg:        #F8F7F5;
    --surface:   #FFFFFF;
    --border:    #E8E5DF;
    --border-md: #D4D0C8;
    --text:      #1A1917;
    --text-2:    #6B6760;
    --text-3:    #A8A49E;

    /* Sidebar */
    --sb-bg:     #1A1917;
    --sb-text:   #C8C5BF;
    --sb-active: #FFFFFF;
    --sb-hover:  rgba(255,255,255,0.07);
    --sb-active-bg: rgba(255,255,255,0.12);

    /* ── 6 temas de arquetipo ── */
    /* amber — Biográfico */
    --amber-bg:     #FFFBF0;
    --amber-panel:  #FFF4D6;
    --amber-border: #F0D080;
    --amber-accent: #B8760A;
    --amber-badge:  #7A4F00;
    --amber-soft:   #FEF3C7;

    /* slate — Noir */
    --slate-bg:     #F5F6F8;
    --slate-panel:  #EAECF0;
    --slate-border: #C8CDD6;
    --slate-accent: #4A5568;
    --slate-badge:  #2D3748;
    --slate-soft:   #E2E8F0;

    /* rose — Adulto */
    --rose-bg:     #FFF5F7;
    --rose-panel:  #FFE8EE;
    --rose-border: #F9B8C8;
    --rose-accent: #C2185B;
    --rose-badge:  #880E4F;
    --rose-soft:   #FCE4EC;

    /* teal — Mecánica */
    --teal-bg:     #F0FBF8;
    --teal-panel:  #DCFAF2;
    --teal-border: #81D4C4;
    --teal-accent: #0F766E;
    --teal-badge:  #0D5C57;
    --teal-soft:   #CCFBF1;

    /* lavender — Relacional */
    --lavender-bg:     #F6F4FF;
    --lavender-panel:  #EDE8FF;
    --lavender-border: #C4B5FD;
    --lavender-accent: #6D4ACA;
    --lavender-badge:  #4C1D95;
    --lavender-soft:   #EDE9FE;

    /* coral — Actitudinal */
    --coral-bg:     #FFF5F0;
    --coral-panel:  #FFE8DC;
    --coral-border: #FDBA9A;
    --coral-accent: #C2501F;
    --coral-badge:  #7C2D12;
    --coral-soft:   #FFEDD5;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-logo {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: 60px;
}

.sidebar-logo .logo-mark {
    width: 28px; height: 28px;
    background: #fff;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: #1A1917;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.sidebar-logo .logo-text {
    font-size: 15px; font-weight: 600;
    color: #fff; white-space: nowrap;
    transition: opacity var(--transition);
}

.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--sb-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-item:hover  { background: var(--sb-hover); color: #fff; }
.nav-item.active { background: var(--sb-active-bg); color: var(--sb-active); font-weight: 500; }

.nav-item .nav-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.nav-item .nav-label {
    transition: opacity var(--transition);
}

.sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

.sidebar-toggle {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.toggle-btn {
    width: 100%;
    display: flex; align-items: center; justify-content: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: transparent; border: none;
    color: var(--sb-text);
    cursor: pointer;
    font-size: 18px;
    transition: background var(--transition), color var(--transition);
}
.toggle-btn:hover { background: var(--sb-hover); color: #fff; }

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════ */

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    transition: margin-left var(--transition);
    display: flex;
    flex-direction: column;
}

body.sb-collapsed .main { margin-left: var(--sidebar-collapsed-w); }

.page-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-title { font-size: 17px; font-weight: 600; }
.page-sub   { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════
   SPLIT PANEL (Personajes)
   ═══════════════════════════════════════════════════════════ */

.split-panel {
    display: grid;
    grid-template-columns: 260px 1fr;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 61px);
}

.panel-list {
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-list-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.panel-list-count {
    font-size: 12px;
    color: var(--text-3);
}

.list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.pj-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
}

.pj-item:hover   { background: var(--bg); }
.pj-item.active  { background: var(--bg); }

.pj-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
    flex-shrink: 0;
}

.pj-info { min-width: 0; }
.pj-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pj-meta { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel-detail {
    overflow-y: auto;
    padding: 0;
    transition: background var(--transition);
}

.panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-3);
    gap: 8px;
}

.panel-empty i { font-size: 36px; opacity: 0.4; }
.panel-empty p { font-size: 13px; }

/* ═══════════════════════════════════════════════════════════
   DETAIL CONTENT
   ═══════════════════════════════════════════════════════════ */

.detail-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.detail-name  { font-size: 18px; font-weight: 600; }
.detail-base  { font-size: 12px; color: var(--text-2); margin-top: 3px; }

.detail-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.detail-field label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    margin-bottom: 4px;
}

.detail-field .field-val {
    font-size: 13px;
    color: var(--text);
}

.detail-frase {
    font-style: italic;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-left: 3px solid;
}

.dims-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.dim-box {
    border-radius: var(--radius-md);
    padding: 10px 12px;
    border: 1px solid;
}

.dim-val { font-size: 18px; font-weight: 600; }
.dim-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

/* Ancla */
.ancla-section { border-radius: var(--radius-md); border: 1px solid; overflow: hidden; }

.ancla-toggle {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    background: transparent; border: none; cursor: pointer;
    font-size: 13px; font-weight: 500;
    transition: background var(--transition);
}

.ancla-body { padding: 14px; border-top: 1px solid; display: none; }
.ancla-body.open { display: block; }

.ancla-text {
    width: 100%; min-height: 160px; max-height: 400px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-family: var(--font);
    font-size: 12px;
    line-height: 1.6;
    background: rgba(255,255,255,0.6);
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
}

.badge-tier-free      { background: #F1F0EE; color: #6B6760; }
.badge-tier-base      { background: #E8F5EE; color: #1D6E4A; }
.badge-tier-signature { background: #EDE8FF; color: #5B38B0; }

.badge-viral-alto  { background: #FEE2E2; color: #991B1B; }
.badge-viral-medio { background: #FEF3C7; color: #92400E; }
.badge-viral-bajo  { background: #F0FDF4; color: #166534; }

/* ═══════════════════════════════════════════════════════════
   BOTONES
   ═══════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
    cursor: pointer; border: none;
    transition: opacity var(--transition), transform var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-md);
    color: var(--text-2);
}
.btn-ghost:hover { background: var(--bg); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */

.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 15px; font-weight: 600; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ═══════════════════════════════════════════════════════════
   FORMULARIO
   ═══════════════════════════════════════════════════════════ */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full  { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-group label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-2);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 10px;
    border: 1px solid var(--border-md);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition);
    width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #888;
}

.form-group textarea { resize: vertical; min-height: 72px; line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════
   CRUD TABLE (Arquetipos, Categorías, Niveles)
   ═══════════════════════════════════════════════════════════ */

.crud-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 61px);
}

.crud-table-wrap {
    overflow-y: auto;
    padding: 20px;
    border-right: 1px solid var(--border);
}

.crud-form-wrap {
    overflow-y: auto;
    padding: 20px;
    background: var(--surface);
}

.data-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* ═══════════════════════════════════════════════════════════
   THEME DOTS
   ═══════════════════════════════════════════════════════════ */

.theme-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.theme-dot.amber    { background: #B8760A; }
.theme-dot.slate    { background: #4A5568; }
.theme-dot.rose     { background: #C2185B; }
.theme-dot.teal     { background: #0F766E; }
.theme-dot.lavender { background: #6D4ACA; }
.theme-dot.coral    { background: #C2501F; }

/* ═══════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════ */

.toast-wrap {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 999;
}

.toast {
    padding: 10px 16px;
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: 13px;
    animation: toast-in 0.2s ease;
    max-width: 280px;
}

.toast.success { background: #1D7A52; }
.toast.error   { background: #B91C1C; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE — bottom nav
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .sidebar {
        width: 100% !important;
        height: 60px;
        min-height: unset;
        top: unset; bottom: 0; left: 0;
        flex-direction: row;
        align-items: center;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .sidebar-logo, .sidebar-toggle { display: none; }

    .sidebar-nav {
        flex-direction: row;
        padding: 0;
        justify-content: space-around;
        width: 100%;
        gap: 0;
    }

    .nav-item {
        flex-direction: column;
        gap: 3px;
        padding: 8px 6px;
        font-size: 10px;
        border-radius: var(--radius-sm);
        justify-content: center;
        flex: 1;
    }

    .nav-item .nav-label { opacity: 1 !important; font-size: 10px; }
    .nav-item .nav-icon  { font-size: 20px; width: auto; }

    .main { margin-left: 0 !important; padding-bottom: 60px; }

    .split-panel {
        grid-template-columns: 1fr;
        height: auto;
    }

    .panel-list  { height: 40vh; min-height: 240px; }
    .panel-detail{ height: auto; }

    .detail-grid  { grid-template-columns: 1fr; }
    .crud-layout  { grid-template-columns: 1fr; height: auto; }
    .crud-form-wrap { border-top: 1px solid var(--border); }
    .form-grid    { grid-template-columns: 1fr; }
}
