/* ==========================================================================
   REBECA STYLE SYSTEM - GEDEON RICHTER MÉXICO
   ========================================================================== */

/* --- CSS VARIABLES & TOKENS --- */
:root {
    --bg-dark: #0d0d1a;
    --bg-darker: #070710;
    --bg-card: rgba(21, 21, 42, 0.75);
    --bg-sidebar: #090915;
    
    /* Branding Colors */
    --primary: #8b5cf6; /* Púrpura */
    --primary-glow: rgba(139, 92, 246, 0.45);
    --secondary: #a855f7; /* Magenta */
    --secondary-glow: rgba(168, 85, 247, 0.35);
    
    /* DISC Profile Colors */
    --disc-red: #ef4444;       /* Rojo Dominante */
    --disc-green: #10b981;     /* Verde Estable */
    --disc-yellow: #f59e0b;    /* Amarillo Influyente */
    --disc-gray: #6b7280;      /* Ninguno */
    
    /* Text & Status Colors */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --border-light: rgba(255, 255, 255, 0.08);
    --border-primary: rgba(139, 92, 246, 0.25);
    
    /* Fonts */
    --font-heading: 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    
    /* Layout */
    --sidebar-width: 260px;
    --transition-fast: 0.18s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- RESET & BASICS --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Small laptops: allow scrolling when content is taller than viewport */
@media (max-height: 700px) and (min-width: 769px) {
    body {
        overflow-y: auto !important;
        height: auto !important;
    }
    .app-root {
        height: auto !important;
        min-height: 100vh;
    }
    .app-environment {
        height: auto !important;
        min-height: 0;
    }
    .main-content {
        height: auto !important;
        overflow-y: visible !important;
        min-height: 0;
    }
    .content-view, .content-view.active {
        height: auto !important;
    }
    .avatar-stage-container {
        min-height: 300px;
        height: 300px;
    }
    .office-bg {
        min-height: 300px;
    }
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.01em;
}

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

/* Visually Hidden Helper (SEO/A11y compliance) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
}

/* --- SCROLLBAR STYLE --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* --- LAYOUT CONTAINERS --- */
.app-root {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15) 0%, rgba(0, 0, 0, 0) 60%),
                radial-gradient(circle at 15% 85%, rgba(168, 85, 247, 0.12) 0%, rgba(0, 0, 0, 0) 50%),
                var(--bg-darker);
}

.screen-container {
    display: none;
    width: 100%;
    height: 100%;
}

.screen-container.active {
    display: flex;
}

.app-environment {
    display: flex;
    width: 100%;
    height: 100%;
}

/* --- LOGIN SCREEN STYLE --- */
#screen-login {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
    animation: slideUp 0.5s var(--transition-normal);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.brand-logo-glow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: 0 0 25px var(--primary-glow);
    font-size: 2.2rem;
    color: white;
    margin-bottom: 15px;
}

.brand-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 15px;
    color: var(--text-dim);
    font-size: 1.2rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 16px 12px 45px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}


/* --- Dropdown options: dark bg + purple text for readability ---*/
select option {
    background-color: #1a1a2e;
    color: #8b5cf6;
}
select option:hover,
select option:checked {
    background-color: #2d1b69;
    color: #ffffff;
}
.form-textarea {
    padding: 15px;
    min-height: 120px;
    resize: none;
}

.error-banner {
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 20px;
    text-align: center;
}

/* --- SIDEBAR NAVIGATION --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 25px 15px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-left: 8px;
}

.logo-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    font-size: 1.3rem;
    color: white;
}

.brand-name {
    display: block;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    line-height: 1.1;
}

.brand-tag {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    margin-bottom: 25px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: white;
}

.user-role {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.92rem;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: white;
}

.nav-item.active {
    background-color: var(--border-primary);
    border: 1px solid rgba(139, 92, 246, 0.35);
    color: white;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.1);
}

.nav-item i {
    font-size: 1.25rem;
}

.logout-btn {
    border-top: 1px solid var(--border-light);
    padding-top: 20px;
    border-radius: 0;
    color: rgba(239, 68, 68, 0.7);
}

.logout-btn:hover {
    color: #f87171;
    background-color: rgba(239, 68, 68, 0.06);
}

/* --- MAIN PANELS ENVIRONMENT --- */
.main-content {
    flex: 1;
    height: 100%;
    padding: 30px;
    overflow-y: auto;
}

.content-view {
    display: none;
    animation: fadeIn 0.4s var(--transition-normal);
    height: 100%;
}

.content-view.active {
    display: flex;
    flex-direction: column;
}

.view-header {
    margin-bottom: 25px;
}

.view-header h2 {
    font-size: 1.8rem;
    color: white;
}

.text-muted {
    color: var(--text-muted);
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- CARDS & GENERAL UI GLASS --- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    padding: 25px;
}

/* --- BUTTONS --- */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    opacity: 0.95;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-danger-sm {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger-sm:hover {
    background-color: rgba(239, 68, 68, 0.25);
}

.btn-action-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 1rem;
    cursor: pointer;
    margin: 0 4px;
    transition: var(--transition-fast);
}

.btn-action-icon:hover {
    background-color: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

/* --- MEDICAL AGENT SELECTOR GRID --- */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    overflow-y: auto;
}

.agent-card {
    position: relative;
    overflow: hidden;
    transition: var(--transition-normal);
    cursor: pointer;
}

.agent-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.15);
}

/* Carisma profile top indicator lines */
.agent-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--profile-color, var(--disc-gray));
}

.agent-profile-row {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.agent-avatar-wrap {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--profile-color, var(--border-light));
    overflow: hidden;
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.agent-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agent-card-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: white;
}

.agent-card-spec {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.agent-disc-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background-color: var(--profile-bg, rgba(255, 255, 255, 0.05));
    color: var(--profile-color, var(--text-muted));
    text-transform: uppercase;
}

.agent-disc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--profile-color, var(--text-muted));
}

.agent-card-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.4;
    min-height: 60px;
    border-top: 1px solid var(--border-light);
    padding-top: 12px;
}

.agent-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* --- DATA TABLES --- */
.table-container {
    padding: 0;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background-color: rgba(255, 255, 255, 0.02);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

/* --- BADGES --- */
.badge {
    display: inline-flex;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    text-transform: uppercase;
}

.badge.admin {
    background-color: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge.user {
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* --- DASHBOARD STATISTICS PANEL --- */
.stats-panel-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 25px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.purple {
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.stat-icon.magenta {
    background-color: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.stat-icon.green {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.stat-value {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card-title-table {
    padding: 20px 20px 0;
    font-size: 1.1rem;
    color: white;
}

/* --- CONFIGURATION & SETTINGS VIEW --- */
.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.config-card {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-card .card-title {
    font-size: 1.15rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 12px;
}

.config-form .form-group {
    margin-bottom: 15px;
}

.text-mono {
    font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.88rem;
}

/* Switch Toggle Slider */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-title {
    display: block;
    font-weight: 600;
    color: var(--text-main);
}

.font-sm { font-size: 0.82rem; }
.font-xs { font-size: 0.75rem; }
.font-xs-mono { font-family: monospace; font-size: 0.72rem; }

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--border-light);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- ACTIVE VISITS AREA & PRACTICE SCREEN --- */
.stage-mode-selector {
    animation: fadeIn 0.4s var(--transition-normal);
}

.selector-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.btn-back-square {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: white;
    font-size: 1.2rem;
    transition: var(--transition-fast);
}

.btn-back-square:hover {
    background-color: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
}

.mode-grid-2col {
    max-width: 800px;
    margin: 0 auto;
}

.mode-card {
    text-align: center;
    padding: 40px 30px;
    transition: var(--transition-normal);
    cursor: pointer;
}

.mode-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.15);
}

.mode-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    font-size: 2.2rem;
    margin-bottom: 20px;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.mode-card h3 {
    font-size: 1.25rem;
    margin-bottom: 12px;
    color: white;
}

.mode-card p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 25px;
    min-height: 60px;
}

.btn-mode-start {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background-color: var(--border-primary);
    color: white;
    font-weight: 600;
    transition: var(--transition-fast);
}

.mode-card:hover .btn-mode-start {
    background-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* --- ARENA INTERACTIVE LAYOUT --- */
.stage-arena {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 20px;
}

.arena-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 25px;
}

.arena-doctor-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.arena-avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.arena-doctor-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: white;
}

.arena-doctor-spec {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.arena-session-meta {
    display: flex;
    gap: 10px;
}

.arena-session-meta .badge {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
}

/* --- TEXT CHAT UI --- */
.arena-chat-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 400px;
}

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Message Bubbles */
.chat-bubble {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

.chat-bubble.doctor {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-top-left-radius: 4px;
    border: 1px solid var(--border-light);
}

.chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
}

.chat-input-bar {
    padding: 15px 25px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.chat-input-bar .chat-input {
    flex: 1;
    min-width: 120px;
}

.chat-input {
    flex: 1;
    padding: 12px 20px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    color: white;
    font-size: 0.95rem;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-chat-send {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    transition: var(--transition-fast);
}

.btn-chat-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(139, 92, 246, 0.5);
}

/* --- VOICE & AVATAR INMERSIVE CONSOLE --- */
.arena-voice-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 400px;
}

.avatar-stage-container {
    flex: 1;
    padding: 0;
    overflow: hidden;
    position: relative;
    min-height: 300px;
}

.office-bg {
    width: 100%;
    height: 100%;
    min-height: 300px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Video Player — inset:0 cubre el contenedor sin depender de height:100%
   (necesario cuando el padre solo tiene min-height sin height explícito) */
.avatar-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

/* Voice ripples stage */
.avatar-voice-stage {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-avatar-ring-wrapper {
    position: relative;
    width: 130px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-ripple {
    position: absolute;
    border-radius: 50%;
    border: 3px solid var(--primary);
    opacity: 0;
}

/* Ripples animations triggerable in JS */
.voice-avatar-ring-wrapper.speaking .ring1 { animation: voiceRipple 1.6s ease-out infinite; }
.voice-avatar-ring-wrapper.speaking .ring2 { animation: voiceRipple 1.6s ease-out 0.4s infinite; }
.voice-avatar-ring-wrapper.speaking .ring3 { animation: voiceRipple 1.6s ease-out 0.8s infinite; }

.voice-stage-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    z-index: 3;
}

/* HUD HUD STATS ON STAGE */
.hud-status-pill {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-status-pill.idle { background-color: rgba(21, 21, 42, 0.85); color: var(--text-muted); }
.hud-status-pill.listening { 
    background-color: rgba(239, 68, 68, 0.25); 
    color: #f87171; 
    border-color: rgba(239, 68, 68, 0.4);
}
.hud-status-pill.processing { 
    background-color: rgba(245, 158, 11, 0.25); 
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}
.hud-status-pill.speaking { 
    background-color: rgba(139, 92, 246, 0.25); 
    color: #c084fc;
    border-color: rgba(139, 92, 246, 0.4);
}

.hud-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
}

.hud-status-pill.listening .hud-status-dot { animation: pulseBlink 0.8s infinite; }
.hud-status-pill.processing .hud-status-dot { animation: pulseBlink 1.2s infinite; }
.hud-status-pill.speaking .hud-status-dot { animation: pulseBlink 0.9s infinite; }

/* Subtitles overlay */
.hud-subtitles {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 4;
    padding: 15px 25px;
    background-color: rgba(7, 7, 16, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.5;
    transition: var(--transition-fast);
}

.sub-role {
    font-weight: 700;
    color: var(--primary);
    margin-right: 8px;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.sub-content {
    color: white;
}

/* Spinner for video rendering wait */
.hud-loading-spinner {
    position: absolute;
    z-index: 5;
    background-color: rgba(7, 7, 16, 0.9);
    padding: 15px 25px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Controls bar (Zoom style) */
.avatar-controls-bar {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Fila principal: soundwave — botones — hint, todos en línea */
.controls-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.controls-row {
    display: flex;
    gap: 15px;
    margin: 0 auto;
}

.btn-control {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: var(--transition-fast);
}

.btn-control:hover {
    background-color: rgba(255, 255, 255, 0.09);
    transform: scale(1.05);
}

.btn-control.mute-btn.active {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.btn-control.hangup-btn {
    background-color: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.btn-control.hangup-btn:hover {
    background-color: #ef4444;
    color: white;
}

.btn-control.active-glow {
    border-color: var(--primary);
    background-color: rgba(139, 92, 246, 0.15);
    color: white;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
    animation: sendPulse 1.5s ease-in-out infinite;
}

@keyframes sendPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(139, 92, 246, 0.4); }
    50%       { box-shadow: 0 0 18px rgba(139, 92, 246, 0.8); }
}

.voice-countdown-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--text-dim);
    animation: countdownFade 1s ease-in-out infinite;
    width: fit-content;
    margin: 0 auto;
}

.voice-countdown-bar strong {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    min-width: 14px;
    display: inline-block;
    text-align: center;
}

@keyframes countdownFade {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

.mic-hint {
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
}

/* soundwave animations indicators */
.soundwave-bar {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.sw-line {
    width: 3px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 2px;
}

.soundwave-bar.active .sw-line {
    animation: waveBounce 0.45s ease-in-out infinite alternate;
}

.soundwave-bar.active .sw-line:nth-child(1) { animation-duration: 0.3s; }
.soundwave-bar.active .sw-line:nth-child(2) { animation-duration: 0.45s; }
.soundwave-bar.active .sw-line:nth-child(3) { animation-duration: 0.35s; }
.soundwave-bar.active .sw-line:nth-child(4) { animation-duration: 0.4s; }
.soundwave-bar.active .sw-line:nth-child(5) { animation-duration: 0.5s; }

/* --- EVALUATION / FEEDBACK VIEW --- */
.fb-loading-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 350px;
}

.feedback-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 25px;
}

.p-large { padding: 40px 25px; }

.fb-score-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    color: var(--primary);
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    background-color: rgba(139, 92, 246, 0.06);
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.1);
}

.fb-split-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.fb-card-title {
    font-size: 1.05rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 10px;
}

.fb-card-title.green { color: #34d399; }
.fb-card-title.red { color: #f87171; }
.fb-card-title.orange { color: #fbbf24; }

.fb-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fb-list li {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.fb-list li::before {
    content: '•';
    position: absolute;
    left: 5px;
    color: var(--primary);
}

.feedback-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.fb-obj-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fb-obj-row {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.fb-obj-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
}

.fb-obj-eval {
    font-size: 0.88rem;
    color: var(--text-main);
}

.fb-concepts-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fb-concept-tag {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #fbbf24;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.fb-tip-box {
    background-color: rgba(139, 92, 246, 0.06);
    border-left: 3px solid var(--primary);
    padding: 15px;
    border-radius: 0 10px 10px 0;
}

.fb-tip-title {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 5px;
}

#fb-advice-val {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* --- MODALS (DIALOGS) --- */
.modal-dialog {
    margin: auto;
    width: 90%;
    max-width: 500px;
    outline: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-dialog::backdrop {
    background-color: rgba(7, 7, 16, 0.75);
    backdrop-filter: blur(4px);
}

.modal-large {
    max-width: 800px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    color: white;
}

.btn-close-modal {
    color: var(--text-dim);
    font-size: 1.3rem;
    transition: var(--transition-fast);
}

.btn-close-modal:hover {
    color: white;
}

.modal-form .form-group {
    margin-bottom: 15px;
}

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

.modal-split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.textarea-hint {
    text-align: right;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.border-top-divider {
    border-top: 1px solid var(--border-light);
}

.pt-2 { padding-top: 10px; }
.pt-3 { padding-top: 15px; }
.mt-3 { margin-top: 15px; }
.mt-4 { margin-top: 20px; }

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.checkboxes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.02);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    padding: 6px 0;
}

.checkbox-row input {
    cursor: pointer;
}

/* Avatar upload preview HUD in modal */
.avatar-upload-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 5px;
}

.avatar-upload-preview {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.avatar-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-input-hidden {
    display: none;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-range {
    flex: 1;
    cursor: pointer;
}

.slider-val {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}


/* --- HISTORY VIEW --- */
#view-history .table-container {
    overflow-x: auto;
}

/* ===== SESIÓN FINALIZADA — inputs y botones bloqueados ===== */

/* Input de chat deshabilitado */
.session-ended-input:disabled {
    background-color: rgba(255,255,255,0.02) !important;
    border-color: rgba(255,255,255,0.06) !important;
    color: var(--text-dim) !important;
    cursor: not-allowed !important;
    opacity: 0.5;
}

/* Botones de acción deshabilitados */
.session-ended-btn:disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none;
    filter: grayscale(0.6);
}

/* Banner de "sesión finalizada" en el chat */
.session-ended-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    margin-top: 12px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #34d399;
    font-weight: 500;
}

/* ===== HISTORIAL — TOOLBAR, BÚSQUEDA Y SELECCIÓN ===== */
.history-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.history-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.history-search-wrap i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 1rem;
    pointer-events: none;
}
.history-search-input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    background-color: rgba(255,255,255,0.05);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}
.history-search-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(255,255,255,0.08);
}
.history-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.history-select-all-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: rgba(255,255,255,0.03);
}
.history-bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.history-sel-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.th-check, .td-check { padding: 0 8px !important; }

/* ── HISTORIAL RESPONSIVE: tarjetas en móvil ─────────────────── */
@media (max-width: 768px) {
    .history-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .history-search-wrap { min-width: unset; }
    #history-admin-controls { flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
    .history-select-all-ctrl { flex: none; }
    .history-search-input { font-size: 16px !important; }
    #history-admin-controls .btn-danger-sm {
        padding: 8px 14px;
        font-size: 0.85rem;
        min-height: 38px;
        touch-action: manipulation;
    }
    /* Anular overflow-x:auto que el bloque general impone a TODAS las tablas */
    #table-history {
        display: block !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
    }
    #table-history thead  { display: none !important; }
    #table-history tbody  { display: block; width: 100%; }
    /* Cada fila = tarjeta */
    #table-history tr {
        display: block !important;
        width: 100%;
        margin-bottom: 10px;
        border: 1px solid var(--border-light);
        border-radius: 10px;
        padding: 10px 14px;
        background: rgba(255,255,255,0.02);
        box-sizing: border-box;
    }
    /* Cada celda = fila interna label + valor */
    #table-history td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none !important;
        font-size: 0.88rem;
        min-height: 32px;
        box-sizing: border-box;
    }
    #table-history td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-right: 8px;
        flex-shrink: 0;
    }
    /* Celda checkbox: sin pseudo-label, checkbox grande para toque */
    #table-history td.td-check {
        justify-content: flex-start;
        padding: 4px 0 2px;
        min-height: 36px;
    }
    #table-history td.td-check::before { content: none; }
    #table-history td.td-check input[type="checkbox"] {
        width: 20px; height: 20px;
        cursor: pointer;
        accent-color: var(--primary);
        touch-action: manipulation;
    }
    /* Celda de acciones: botones más grandes a la derecha */
    #table-history td[data-label="Acciones"] {
        justify-content: flex-end;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid var(--border-light) !important;
        margin-top: 4px;
    }
    #table-history td[data-label="Acciones"] .btn-action-icon {
        width: 40px; height: 40px;
        font-size: 1.1rem;
        touch-action: manipulation;
    }
}
/* ─────────────────────────────────────────────────────── */

#history-detail-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 0;
}

#history-detail-messages .chat-bubble {
    max-width: 85%;
}


/* --- API KEY STATUS PILLS --- */
.config-key-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.config-key-label-row .form-label {
    margin-bottom: 0;
}

.key-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.key-status-pill.key-ok {
    background-color: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.key-status-pill.key-error {
    background-color: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
    max-width: 300px;
    white-space: normal;
    line-height: 1.3;
    padding: 4px 10px;
}

.key-status-pill.key-saved {
    background-color: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.key-status-pill.key-testing {
    background-color: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: pulseBlink 1.2s infinite;
}

.key-status-pill.key-none {
    background-color: rgba(107, 114, 128, 0.1);
    color: var(--text-dim);
    border: 1px solid rgba(107, 114, 128, 0.2);
}


/* --- HISTORY MODAL TABS --- */
.history-tabs {
    display: flex;
    gap: 6px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 4px;
}

.history-tab-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
    cursor: pointer;
    background: none;
}

.history-tab-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.history-tab-btn.active-tab {
    background-color: var(--border-primary);
    border-color: rgba(139, 92, 246, 0.35);
    color: white;
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulseBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes voiceRipple {
    0% { opacity: 0.7; transform: scale(0.85); }
    100% { opacity: 0; transform: scale(1.15); }
}

@keyframes waveBounce {
    0% { transform: scaleY(0.3); }
    100% { transform: scaleY(1); }
}

/* Helper spacing classes */
.text-center { text-align: center; }
.w-100 { width: 100%; }

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (min-width: 769px) and (max-width: 1024px) {
    .app-root {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 15px;
    }
    .sidebar-brand {
        margin-bottom: 0;
    }
    .user-pill {
        display: none;
    }
    .sidebar-nav {
        flex-direction: row;
        margin-left: 20px;
    }
    .sidebar-footer {
        margin-left: 15px;
    }
    .logout-btn {
        border-top: none;
        padding-top: 0;
    }
    .stats-panel-grid {
        grid-template-columns: 1fr;
    }
    .config-grid {
        grid-template-columns: 1fr;
    }
    .mode-grid {
        grid-template-columns: 1fr;
    }
    .feedback-grid {
        grid-template-columns: 1fr;
    }
    .feedback-details-grid {
        grid-template-columns: 1fr;
    }
    .modal-split-grid {
        grid-template-columns: 1fr;
    }
}


/* ================================================================
   RESPONSIVE — LAPTOP MEDIANO (769px – 1280px)
   Ensures scrollable layout for 13-14" laptops and tablet-landscape
   ================================================================ */
@media (min-width: 769px) and (max-width: 1280px) {
    .main-content {
        padding: 20px;
        overflow-y: auto;
    }

    .mode-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 16px;
    }

    .mode-card {
        padding: 25px 20px;
    }

    .mode-card p {
        min-height: 0;
    }

    .stage-arena {
        gap: 12px;
    }

    .arena-chat-layout {
        min-height: 300px;
    }

    .arena-voice-layout {
        min-height: 300px;
    }

    .avatar-stage-container {
        min-height: 280px;
        height: 280px;
    }

    /* office-bg necesita height explícito en móvil porque todos sus hijos
       son position:absolute y no contribuyen a la altura del contenedor */
    .office-bg {
        min-height: 280px;
        height: 100%;
    }

    .feedback-grid {
        grid-template-columns: 260px 1fr;
        gap: 16px;
    }

    .feedback-details-grid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .stats-panel-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }

    .config-grid {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .modal-split-grid {
        grid-template-columns: 1fr 1fr;
    }

    .agents-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* Laptop pequeño (~1024px): sidebar más estrecho */
@media (min-width: 769px) and (max-width: 1100px) {
    :root {
        --sidebar-width: 220px;
    }
    .sidebar {
        padding: 20px 10px;
    }
    .nav-item {
        font-size: 0.85rem;
        padding: 10px 12px;
    }
    .main-content {
        padding: 20px 16px;
    }
    .view-header h2 {
        font-size: 1.5rem;
    }
}

/* ================================================================
   RESPONSIVE — CELULAR (≤ 768 px)
   ================================================================ */
@media (max-width: 768px) {

    /* --- Scroll: cambiar de "app scroll" a scroll natural de documento ---
       El modelo desktop (body:hidden + main-content:auto) no funciona bien
       en móviles. Usamos scroll de body que todos los browsers móviles
       manejan correctamente.
    ----------------------------------------------------------------- */
    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
    }
    .app-root {
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
    }
    .app-environment {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
    .main-content {
        height: auto !important;
        overflow-y: visible !important;
        overflow-x: hidden !important;
        min-height: 60vh;
    }
    .content-view,
    .content-view.active {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    /* --- Hamburger button --- */
    #mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 12px;
        right: 12px;
        left: auto;
        z-index: 10000;
        width: 44px;
        height: 44px;
        border: none;
        border-radius: 10px;
        background: var(--primary);
        color: #fff;
        font-size: 1.3rem;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.4);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* --- Backdrop overlay --- */
    #mobile-menu-backdrop {
        display: none;
        position: fixed;
        top: 0; left: 0;
        width: 100%; height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }
    #mobile-menu-backdrop.active {
        display: block;
    }

    /* --- Sidebar: drawer from left --- */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 75% !important;
        max-width: 260px !important;
        height: 100vh !important;
        z-index: 9999 !important;
        transition: left 0.3s ease !important;
        overflow-y: auto !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        padding: 68px 15px 25px !important;
        border-right: 1px solid var(--border-light);
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }
    .sidebar.mobile-open {
        left: 0 !important;
    }
    .sidebar-brand {
        margin-bottom: 30px !important;
    }
    .user-pill {
        display: flex !important;
    }
    .sidebar-nav {
        flex-direction: column !important;
        margin-left: 0 !important;
        flex: 0 0 auto !important;
    }
    .sidebar-footer {
        margin-left: 0 !important;
        margin-top: 12px !important;
        flex-shrink: 0 !important;
        display: block !important;
        padding-bottom: 8px !important;
    }
    .logout-btn {
        border-top: 1px solid var(--border-light) !important;
        padding-top: 15px !important;
        display: flex !important;
    }

    /* --- Main content: full width, espacio para hamburguesa (top-right) --- */
    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding: 65px 62px 20px 16px !important;
        box-sizing: border-box !important;
    }

    /* --- Grids to single column --- */
    .mode-grid, .stats-panel-grid, .config-grid,
    .feedback-grid, .feedback-details-grid,
    .modal-split-grid, .agents-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .form-row-2 {
        grid-template-columns: 1fr !important;
    }

    /* --- Arena header --- */
    .arena-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .arena-session-meta {
        align-self: flex-end;
    }

    /* --- Avatar stage --- */
    .avatar-stage-container {
        min-height: 300px !important;
        height: 300px !important;
    }
    .office-bg {
        min-height: 300px !important;
    }
    #avatar-gif-player {
        max-height: 55vw !important;
    }
    /* Barra de controles en móvil */
    .avatar-controls-bar {
        padding: 10px 12px;
        gap: 6px;
    }
    /* En móvil la fila principal pone el hint debajo: columna */
    .controls-main-row {
        flex-direction: column;
        gap: 6px;
    }
    .soundwave-bar {
        justify-content: center;
    }
    .controls-row {
        gap: 10px;
        justify-content: center;
    }
    .btn-control {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }
    .mic-hint {
        text-align: center;
        white-space: normal;
    }
    .voice-countdown-bar {
        font-size: 0.75rem;
        padding: 5px 14px;
    }

    /* --- Tables scroll horizontally --- */
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Modals: near full-screen --- */
    dialog {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    /* --- iOS: prevent input zoom --- */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* --- Typography --- */
    h1 { font-size: 22px !important; }
    h2 { font-size: 19px !important; }
    h3 { font-size: 17px !important; }

    /* --- Pause overlay --- */
    #session-pause-overlay h2 { font-size: 1.3rem; }
}

/* Hide hamburger and backdrop on desktop */
@media (min-width: 769px) {
    #mobile-menu-btn, #mobile-menu-backdrop {
        display: none !important;
    }
}

/* ================================================================
   RESPONSIVE — PEQUEÑO (≤ 480 px)
   ================================================================ */
@media (max-width: 480px) {
    .main-content {
        padding: 62px 60px 16px 10px;
    }
    .view-header h2 {
        font-size: 1.3rem;
    }
    .arena-header h3 {
        font-size: 1rem;
    }
    .btn-control {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
    }
    #avatar-gif-player {
        max-height: 48vw !important;
    }
}
