/* Josie AI — panel. CSS a mano, sin framework ni build. */

:root {
    --fondo: #0A0D1A;
    --fondo-2: #0E1226;
    --tarjeta: rgba(255, 255, 255, .045);
    --tarjeta-2: rgba(255, 255, 255, .028);
    --borde: rgba(255, 255, 255, .10);
    --texto: #EEF1FB;
    --texto-suave: #A8B0CC;
    --texto-tenue: #6F779A;
    --acento: #6D7CFF;
    --acento-2: #A45CFF;
    --ok: #34D399;
    --aviso: #FBBF24;
    --error: #FB7185;
    --radio: 16px;
    --radio-s: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--fondo);
    color: var(--texto);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1 {
    font-size: 1.55rem;
    letter-spacing: -.02em;
    margin: 0 0 1.4rem;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 .8rem;
}

/* --- marca --------------------------------------------------------------- */

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--acento), var(--acento-2));
    font-size: .82rem;
    font-weight: 800;
    color: #fff;
}

.brand-lg { font-size: 1.25rem; justify-content: center; }
.brand-lg .brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 1rem; }

/* --- estructura ---------------------------------------------------------- */

.app {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--fondo-2);
    border-right: 1px solid var(--borde);
    padding: 1.4rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.logout {
    font-size: .8rem;
    color: var(--texto-tenue);
    text-decoration: none;
}
.logout:hover { color: var(--texto); }

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem .75rem;
    border-radius: var(--radio-s);
    color: var(--texto-suave);
    text-decoration: none;
    font-size: .92rem;
    transition: background .15s, color .15s;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, .05);
    color: var(--texto);
}

.sidebar nav a.active {
    background: linear-gradient(135deg, rgba(109, 124, 255, .22), rgba(164, 92, 255, .16));
    color: #fff;
}

.sidebar nav svg,
.sheet-link svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
}

.content {
    padding: 2rem 2.2rem 4rem;
    max-width: 1100px;
    width: 100%;
}

/* --- tarjetas ------------------------------------------------------------ */

.card {
    background: var(--tarjeta);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 1.2rem 1.3rem;
    margin-bottom: 1.1rem;
}

.card-sub {
    background: var(--tarjeta-2);
}

.card-title {
    font-weight: 650;
    margin-bottom: .8rem;
}

.hint {
    color: var(--texto-suave);
    font-size: .88rem;
    margin: 0;
}

.empty {
    color: var(--texto-tenue);
    text-align: center;
    padding: 1.6rem 0;
    margin: 0;
}

.page-back {
    color: var(--texto-tenue);
    text-decoration: none;
    font-size: .86rem;
}
.page-back:hover { color: var(--texto); }

/* --- rejillas ------------------------------------------------------------ */

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    margin-bottom: 1.1rem;
}

.stat {
    background: var(--tarjeta);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 1.1rem 1.2rem;
}

.stat-label {
    color: var(--texto-tenue);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin-top: .25rem;
}

.stat-error { color: var(--error); font-size: .86rem; }

/* --- formularios --------------------------------------------------------- */

.field {
    display: block;
    margin-bottom: .95rem;
}

.field-label {
    display: block;
    font-size: .84rem;
    color: var(--texto-suave);
    margin-bottom: .35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: .62rem .75rem;
    border-radius: var(--radio-s);
    border: 1px solid var(--borde);
    background: rgba(0, 0, 0, .28);
    color: var(--texto);
    font: inherit;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--acento);
}

textarea {
    resize: vertical;
    min-height: 90px;
}

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .9rem;
    margin-bottom: .95rem;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    color: var(--texto-suave);
}

/* --- botones ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .6rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--borde);
    background: rgba(255, 255, 255, .06);
    color: var(--texto);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, background .15s;
}

.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--acento), var(--acento-2));
    border-color: transparent;
    color: #fff;
}

.btn-danger { color: var(--error); }

.btn-sm { padding: .38rem .8rem; font-size: .85rem; }

.btn-block { width: 100%; }

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

/* --- avisos -------------------------------------------------------------- */

.alerta,
.aviso-ok {
    border-radius: var(--radio-s);
    padding: .65rem .85rem;
    font-size: .88rem;
    margin: 0 0 .9rem;
}

.alerta {
    background: rgba(251, 113, 133, .12);
    border: 1px solid rgba(251, 113, 133, .35);
    color: #FFD9DF;
}

.aviso-ok {
    background: rgba(52, 211, 153, .12);
    border: 1px solid rgba(52, 211, 153, .35);
    color: #C9F7E5;
}

.badge {
    display: inline-block;
    padding: .16rem .6rem;
    border-radius: 999px;
    border: 1px solid var(--borde);
    background: rgba(255, 255, 255, .06);
    color: var(--texto-suave);
    font-size: .76rem;
    font-weight: 600;
}

.badge-ok { background: rgba(52, 211, 153, .16); border-color: rgba(52, 211, 153, .4); color: #A7F3D0; }
.badge-espera { background: rgba(251, 191, 36, .14); border-color: rgba(251, 191, 36, .38); color: #FDE68A; }
.badge-error { background: rgba(251, 113, 133, .14); border-color: rgba(251, 113, 133, .38); color: #FECDD3; }

/* --- tablas y listas ----------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th, td {
    text-align: left;
    padding: .6rem .5rem;
    border-bottom: 1px solid var(--borde);
    vertical-align: top;
}

th {
    color: var(--texto-tenue);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* --- vídeo y avatares ---------------------------------------------------- */

.video-preview {
    width: 100%;
    max-width: 260px;
    border-radius: var(--radio-s);
    background: #000;
    display: block;
}

.avatar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
    margin: .6rem 0 .2rem;
}

.avatar-opcion {
    position: relative;
    width: 86px;
    border-radius: var(--radio-s);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    background: rgba(0, 0, 0, .3);
    padding: 0;
}

.avatar-opcion img {
    width: 100%;
    height: 106px;
    object-fit: cover;
    display: block;
}

.avatar-opcion.sel { border-color: var(--acento); }

.avatar-estado {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    font-size: .66rem;
    padding: .12rem 0;
    text-align: center;
    background: rgba(0, 0, 0, .65);
    color: var(--texto-suave);
}

/* --- chat ---------------------------------------------------------------- */

.chat {
    display: flex;
    flex-direction: column;
    gap: .7rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: .3rem;
    margin-bottom: 1rem;
}

.msg {
    padding: .6rem .85rem;
    border-radius: 14px;
    max-width: 82%;
    white-space: pre-wrap;
    font-size: .92rem;
}

.msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--acento), var(--acento-2));
    color: #fff;
}

.msg-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--borde);
}

.guion-box {
    background: rgba(0, 0, 0, .3);
    border: 1px dashed var(--borde);
    border-radius: var(--radio-s);
    padding: .8rem .9rem;
    margin-bottom: .9rem;
}

.guion-texto {
    font-size: 1rem;
    line-height: 1.5;
}

.guion-meta {
    color: var(--texto-tenue);
    font-size: .8rem;
    margin-top: .4rem;
}

/* --- login --------------------------------------------------------------- */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.bg-blobs {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .5;
}

.blob-1 { width: 420px; height: 420px; background: #4C5BFF; top: -120px; left: -100px; }
.blob-2 { width: 380px; height: 380px; background: #A45CFF; bottom: -140px; right: -80px; }
.blob-3 { width: 300px; height: 300px; background: #1E9BFF; top: 40%; left: 55%; }

.login-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: rgba(14, 18, 38, .82);
    border: 1px solid var(--borde);
    border-radius: 20px;
    padding: 2rem 1.7rem;
    backdrop-filter: blur(14px);
}

.login-sub {
    text-align: center;
    color: var(--texto-tenue);
    font-size: .88rem;
    margin: .5rem 0 1.4rem;
}

/* --- menú móvil ---------------------------------------------------------- */

.fab-menu,
.sheet-backdrop,
.bottom-sheet {
    display: none;
}

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .content { padding: 1.4rem 1.1rem 6rem; }

    .fab-menu {
        display: grid;
        place-items: center;
        position: fixed;
        right: 1.1rem;
        bottom: 1.1rem;
        width: 54px;
        height: 54px;
        border-radius: 50%;
        border: none;
        background: linear-gradient(135deg, var(--acento), var(--acento-2));
        color: #fff;
        cursor: pointer;
        z-index: 40;
        box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
        transition: transform .2s;
    }

    .fab-menu svg { width: 24px; height: 24px; }
    .fab-menu.open { transform: rotate(45deg); }

    .sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .5);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
        z-index: 30;
    }

    .sheet-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    .bottom-sheet {
        display: flex;
        flex-direction: column;
        gap: .2rem;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 35;
        background: var(--fondo-2);
        border-top: 1px solid var(--borde);
        border-radius: 20px 20px 0 0;
        padding: .6rem 1rem 1.4rem;
        transform: translateY(110%);
        transition: transform .25s ease;
    }

    .bottom-sheet.open { transform: translateY(0); }

    .sheet-handle {
        width: 42px;
        height: 4px;
        border-radius: 4px;
        background: var(--borde);
        margin: .3rem auto .7rem;
    }

    .sheet-link {
        display: flex;
        align-items: center;
        gap: .75rem;
        padding: .75rem .6rem;
        border-radius: var(--radio-s);
        color: var(--texto-suave);
        text-decoration: none;
    }

    .sheet-link.active {
        background: rgba(109, 124, 255, .18);
        color: #fff;
    }

    .msg { max-width: 92%; }
}
