/* Wiki Button Styles */
.timspedia-btn {
    background: #D32F2F !important;
    color: white !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
}

.timspedia-btn:hover {
    background: #B71C1C !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
}

.timspedia-btn svg {
    fill: white !important;
    width: 20px;
    height: 20px;
}

/* Wiki Link Styles */
.nav-link-wiki {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link-wiki:hover {
    background: var(--pure-white);
    border-color: var(--tim-red);
    color: var(--tim-red);
    transform: translateY(-1px);
}

.nav-link-wiki svg {
    width: 20px;
    height: 20px;
}

@media (min-width: 769px) {
    .nav-link-wiki {
        display: flex;
    }
}

@media (max-width: 768px) {
    .nav-text-wiki {
        display: none;
    }
    
    .nav-link-wiki {
        padding: 0.625rem;
    }
}

/* Wiki Toggle Button Styles */
.wiki-toggle-btn {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.wiki-toggle-btn:hover {
    background: var(--pure-white);
    border-color: var(--tim-red);
    color: var(--tim-red);
    transform: translateY(-1px);
}

.wiki-toggle-btn svg {
    width: 20px;
    height: 20px;
}

@media (min-width: 769px) {
    .wiki-toggle-btn {
        display: flex;
    }
}

@media (max-width: 768px) {
    .wiki-toggle-btn .nav-text-wiki {
        display: none;
    }
    
    .wiki-toggle-btn {
        padding: 0.625rem;
    }
}

/* Admin Link Styles */
.admin-link {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #C8102E 0%, #D41432 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.2);
}

.admin-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.4);
    background: linear-gradient(135deg, #A50D25 0%, #C8102E 100%);
}

.admin-link svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .admin-text {
        display: none;
    }
    
    .admin-link {
        padding: 0.625rem;
    }
}

/* 
 * Tim Hortons Chat UI - Diseño Jonathan Ive
 * Principios: Minimalismo, Elegancia, Funcionalidad
 */

/* ===================================
   FUENTES PERSONALIZADAS
   =================================== */
@font-face {
    font-family: 'Sofia Pro Bold';
    src: url('sofia_pro_bold.otf') format('opentype');
    font-display: swap;
}

@font-face {
    font-family: 'Sofia Pro Regular';
    src: url('sofia_pro_regular.otf') format('opentype');
    font-display: swap;
}

/* ===================================
   VARIABLES DE DISEÑO
   =================================== */
:root {
    /* Colores Tim Hortons refinados */
    --tim-red: #C8102E;
    --tim-red-hover: #A50D25;
    --tim-red-light: rgba(200, 16, 46, 0.08);
    --tim-red-glow: rgba(200, 16, 46, 0.15);

    /* Colores semánticos */
    --color-success: #34C759;
    --color-success-bg: rgba(52, 199, 89, 0.10);
    --color-warning: #FF9500;
    --color-warning-bg: rgba(255, 149, 0, 0.12);
    --color-info: #007AFF;
    --color-info-bg: rgba(0, 122, 255, 0.10);

    /* Escala tipográfica */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 15px;
    --text-lg: 18px;
    --text-xl: 22px;
    --text-2xl: 28px;
    --text-3xl: 36px;
    --text-4xl: 44px;

    /* Escala de grises premium */
    --pure-white: #FFFFFF;
    --off-white: #FAFAFA;
    --light-gray: #F7F7F8;
    --gray-100: #F2F2F7;
    --gray-200: #E5E5EA;
    --gray-300: #D1D1D6;
    --gray-400: #C7C7CC;
    --gray-500: #8E8E93;
    --gray-600: #636366;
    --gray-700: #48484A;
    --gray-800: #2C2C2E;
    --gray-900: #1C1C1E;
    
    /* Dimensiones y espaciado */
    --header-height: 64px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    --input-textarea-min-height: 56px;
    
    /* Radios de borde */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 100px;
    
    /* Sombras sutiles */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.10);
    --shadow-glow: 0 0 40px rgba(200, 16, 46, 0.1);
    
    /* Transiciones */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Blur glassmorphism */
    --blur-sm: 8px;
    --blur-md: 16px;
    --blur-lg: 24px;
    --blur-xl: 40px;

    /* Ancho máximo del módulo de chat */
    --chat-width: min(900px, 90vw);
}

/* ===================================
   RESET Y BASE
   =================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*::selection {
    background-color: var(--tim-red-light);
    color: var(--tim-red);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #EDEEF2;
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Background pattern sutil */
body::before {
    display: none;
}

/* ===================================
   CONTENEDOR PRINCIPAL
   =================================== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 1;
    margin-left: 320px; /* Space for sidebar on desktop */
    padding-top: var(--header-height); /* Space for fixed header */
}

/* Mobile: no margin for sidebar */
@media (max-width: 768px) {
    .app-container {
        margin-left: 0;
    }
}

/* ===================================
   HEADER PREMIUM
   =================================== */
.header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(var(--blur-xl)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur-xl)) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-xl);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
    transition: all var(--transition-base);
}

/* Desktop: header covers full width including sidebar area */
@media (min-width: 769px) {
    .header {
        left: 0;
    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-home-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    text-decoration: none;
    color: inherit;
    border-radius: var(--radius-md);
    padding: var(--spacing-xs) var(--spacing-sm);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.header-home-link:hover {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-sm);
}

.header-home-link:focus,
.header-home-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.25);
}

.header-brand {
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--tim-red);
    letter-spacing: 0.4px;
    text-transform: none;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    height: 100%;
}

.header-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    filter: brightness(1.05) contrast(1.1);
    transition: transform var(--transition-spring);
    cursor: pointer;
}

.header-logo:hover {
    transform: scale(1.05);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* Botón de logout premium */
.logout-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.9);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.logout-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--tim-red-light);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width var(--transition-slow), height var(--transition-slow);
}

.logout-btn:hover {
    background: var(--pure-white);
    border-color: var(--tim-red);
    color: var(--tim-red);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.logout-btn:hover::before {
    width: 100%;
    height: 100%;
}

.logout-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.logout-icon {
    width: 18px;
    height: 18px;
    position: relative;
    z-index: 1;
}

.logout-text {
    position: relative;
    z-index: 1;
}

/* ===================================
   CONTENIDO PRINCIPAL
   =================================== */
.main-content {
    flex: 1;
   display: flex;
   flex-direction: column;
   align-items: center;
   padding: var(--spacing-lg);
   gap: var(--spacing-lg);
   min-height: 0;
   height: 100%;
   width: 100%;
   position: relative;
   overflow-x: hidden;
}


/* ===================================
   WELCOME STATE — IVE MINIMAL
   =================================== */
.new-conversation-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0;
    padding: var(--spacing-xl) var(--spacing-lg);
}

.prompt-icon,
.prompt-coffee-icon {
    color: var(--tim-red);
    margin-bottom: 20px;
    opacity: 0.9;
}

.prompt-icon svg,
.prompt-coffee-icon svg {
    width: 72px;
    height: 72px;
}

.prompt-coffee-video {
    width: 180px;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    border-radius: 18px;
    display: block;
}

.prompt-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    color: #1C1C1E;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 8px 0;
}

.prompt-subtitle {
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #86868B;
    letter-spacing: -0.01em;
    margin: 0 0 28px 0;
    line-height: 1.4;
}

.prompt-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.prompt-chip {
    display: inline-flex;
    align-items: center;
    padding: 9px 20px;
    background: transparent;
    border: 1px solid #E5E5EA;
    border-radius: 20px;
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    color: #1C1C1E;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.prompt-chip:hover {
    background: #F5F5F7;
    border-color: #D1D1D6;
}

.prompt-chip:active {
    background: #E5E5EA;
}

/* Legacy body.new-conversation classes (kept for backward compat) */
body.new-conversation .main-content {
    justify-content: center;
    gap: var(--spacing-xl);
}

body.new-conversation .chat-container,
body.new-conversation .scroll-to-bottom,
body.new-conversation .mobile-footer {
    display: none;
}

/* ===================================
   CONTENEDOR DE CHAT — IVE MINIMAL
   =================================== */
.chat-container {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    width: var(--chat-width);
    background: transparent;
    border-radius: var(--radius-xl);
    border: none;
    padding: var(--spacing-lg) var(--spacing-md);
    overflow-y: auto;
    position: relative;
    transition: opacity var(--transition-base);
    scrollbar-width: thin;
    scrollbar-gutter: stable;
    scrollbar-color: transparent transparent;
    -webkit-overflow-scrolling: touch;
}

.chat-container:hover {
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.chat-container.waiting {
    /* No glow — restraint */
}

/* Scrollbar — nearly invisible */
.chat-container::-webkit-scrollbar {
    width: 4px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background 0.3s;
}

.chat-container:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ===================================
   MENSAJES — IVE CLEAN GEOMETRY
   =================================== */
.message {
    margin-bottom: 8px;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.55;
    max-width: 72%;
    position: relative;
    word-wrap: break-word;
}

.message:hover .message-timestamp {
    opacity: 1;
}

/* Message content wrapper */
.message-content {
    color: inherit;
}

.message-content > *:first-child {
    margin-top: 0;
}

.message-content > *:last-child {
    margin-bottom: 0;
}

/* User message — solid, confident, no tail */
.user-message {
    background: #C8102E;
    color: var(--pure-white);
    margin-left: auto;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.15);
}

.user-message::before {
    display: none;
}

/* Bot message — quiet, recessive, no tail */
.bot-message {
    background: #F5F5F7;
    color: #1C1C1E;
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.bot-message::before {
    display: none;
}

/* Timestamp — hidden until hover */
.message-timestamp {
    display: block;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.2px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.user-message .message-timestamp {
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
}

.bot-message .message-timestamp {
    color: #AEAEB2;
}

/* Links and code — refined */
.bot-message a {
    color: #C8102E;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s;
    word-break: break-all;
}

.bot-message a:hover {
    opacity: 0.7;
}

.bot-message code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 13px;
    color: #1C1C1E;
}

.bot-message pre {
    background: rgba(0, 0, 0, 0.04);
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 8px 0;
    border: none;
}

.bot-message pre code {
    background: transparent;
    padding: 0;
    color: #1C1C1E;
}

.bot-message .bot-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #86868B;
}

.bot-message .bot-image {
    margin: 10px 0;
    border-radius: 12px;
    overflow: hidden;
    display: inline-block;
    max-width: min(480px, 100%);
}

.bot-message .bot-image img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
}

.bot-message .bot-image figcaption {
    font-size: 11px;
    color: #86868B;
    padding: 6px 8px 8px;
}

.bot-message .bot-video {
    margin: 10px 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    max-width: min(480px, 100%);
}

.bot-message .bot-video-frame {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: #000;
}

.bot-message .bot-video-frame iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.bot-message .bot-video .video-caption {
    font-size: 11px;
    color: #86868B;
    padding: 6px 8px 8px;
}

/* ===================================
   LOADING — IVE BREATHING
   =================================== */
.loading {
    display: inline-flex;
    align-items: center;
    padding: 12px 18px;
    margin-bottom: 8px;
}

.loading-pulse {
    display: flex;
    gap: 5px;
}

.loading-dot {
    width: 6px;
    height: 6px;
    background: #AEAEB2;
    border-radius: 50%;
}

.loading-message {
    margin-left: 12px;
    font-size: 13px;
    color: #86868B;
    font-weight: 400;
}

.loading-elapsed {
    margin-left: 6px;
    font-size: 11px;
    color: #AEAEB2;
    font-weight: 400;
}

/* ===================================
   INPUT — IVE MINIMAL
   =================================== */
.input-container {
    width: var(--chat-width);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border-radius: 16px;
    border: none;
    box-shadow: 0 -1px 20px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.25s ease;
}

.input-container:focus-within {
    box-shadow: 0 -2px 30px rgba(0, 0, 0, 0.1);
}

/* Textarea — clean */
textarea {
    flex: 1;
    padding: 10px 14px;
    background: #F2F2F7;
    border: 1px solid transparent;
    border-radius: 12px;
    font-family: 'Sofia Pro Regular', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    color: #1C1C1E;
    resize: none;
    overflow-y: hidden;
    min-height: 44px;
    max-height: 180px;
    line-height: 1.5;
    transition: background 0.2s, box-shadow 0.2s;
}

textarea.is-empty {
    line-height: 1.5;
}

textarea::placeholder {
    color: #AEAEB2;
}

textarea:hover {
    background: #E5E5EA;
}

textarea:focus {
    outline: none;
    background: #FFFFFF;
    border-color: transparent;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* Buttons */
.input-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
}

/* Clear / new conversation button */
.clear-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: #AEAEB2;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn::before {
    display: none;
}

.clear-btn:hover {
    background: #F2F2F7;
    color: #636366;
    transform: none;
}

.clear-btn:hover::before {
    display: none;
}

.clear-btn:active {
    background: #E5E5EA;
    transform: none;
}

.clear-btn svg {
    width: 20px;
    height: 20px;
}

/* Send button — circle, icon only */
.send-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: #C8102E;
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    font-size: 0;
    overflow: hidden;
    position: relative;
}

.send-btn::before {
    display: none;
}

.send-btn:hover {
    transform: scale(1.06);
    box-shadow: none;
}

.send-btn:hover::before {
    display: none;
}

.send-btn:active {
    transform: scale(0.95);
    box-shadow: none;
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

/* ===================================
   BOTÓN SCROLL TO BOTTOM
   =================================== */
/* Scroll to bottom button removed */

.scroll-icon::before {
    content: '↓';
    font-size: 20px;
    font-weight: bold;
}

/* ===================================
   SISTEMA DE NOTIFICACIONES TOAST
   =================================== */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-lg));
    right: var(--spacing-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(var(--blur-xl)) saturate(150%);
    -webkit-backdrop-filter: blur(var(--blur-xl)) saturate(150%);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: 
        var(--shadow-xl),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    min-width: 320px;
    max-width: 420px;
    pointer-events: all;
    border-left: 3px solid var(--gray-400);
}

/* Iconos de toast */
.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 50%;
    padding: 2px;
}

/* Contenido del toast */
.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.toast-title {
    font-family: 'Sofia Pro Bold', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.3;
}

.toast-message {
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.5;
}

/* Acciones del toast */
.toast-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.toast-action-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 500;
    border: none;
}

.toast-action-btn.primary {
    background: var(--tim-red);
    color: var(--pure-white);
}

.toast-action-btn.primary:hover {
    background: var(--tim-red-hover);
    transform: scale(1.05);
}

.toast-action-btn.secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.toast-action-btn.secondary:hover {
    background: var(--gray-200);
}

/* Botón cerrar toast */
.toast-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-500);
    font-size: 20px;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    border-radius: 50%;
}

.toast-close:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

/* Tipos de toast */
.toast.success {
    border-left-color: #34C759;
}

.toast.success .toast-icon {
    color: #34C759;
    background: rgba(52, 199, 89, 0.1);
}

.toast.error {
    border-left-color: #FF3B30;
}

.toast.error .toast-icon {
    color: #FF3B30;
    background: rgba(255, 59, 48, 0.1);
}

.toast.warning {
    border-left-color: #FF9500;
}

.toast.warning .toast-icon {
    color: #FF9500;
    background: rgba(255, 149, 0, 0.1);
}

.toast.info {
    border-left-color: #007AFF;
}

.toast.info .toast-icon {
    color: #007AFF;
    background: rgba(0, 122, 255, 0.1);
}

/* Barra de progreso del toast */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--tim-red);
    border-radius: 0 0 0 var(--radius-md);
    animation: progressBar linear;
}

@keyframes progressBar {
    from { width: 100%; }
    to { width: 0%; }
}
/* ===================================
   CONVERSATION SIDEBAR
   =================================== */
.conversations-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 320px;
    height: calc(100vh - var(--header-height));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(var(--blur-xl)) saturate(150%);
    -webkit-backdrop-filter: blur(var(--blur-xl)) saturate(150%);
    border-right: 1px solid var(--gray-200);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: left var(--transition-slow);
}

/* Mobile: sidebar hidden by default and covers full height */
@media (max-width: 768px) {
    .conversations-sidebar {
        top: 0;
        left: -320px;
        height: 100vh;
        z-index: 1500;
    }
    
    .conversations-sidebar.open {
        left: 0;
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--gray-200);
    background: rgba(255, 255, 255, 0.5);
}

/* Mobile: show header with close button */
@media (max-width: 768px) {
    .sidebar-header {
        height: var(--header-height);
    }
}

/* Desktop: hide header */
@media (min-width: 769px) {
    .sidebar-header {
        display: none;
    }
}

.sidebar-header h2 {
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

.sidebar-close {
    width: 32px;
    height: 32px;
    display: none; /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--transition-base);
}

.sidebar-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    transform: scale(1.1);
}

.sidebar-close svg {
    width: 20px;
    height: 20px;
}

/* Show close button only on mobile */
@media (max-width: 768px) {
    .sidebar-close {
        display: flex;
    }
}

.sidebar-search {
    padding: var(--spacing-md);
}

.sidebar-search-panel {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 0 var(--spacing-sm);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sidebar-search-panel input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--spacing-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--gray-800);
}

.sidebar-search-panel input::placeholder {
    color: var(--gray-400);
}

.sidebar-search-panel input:focus {
    outline: none;
}

.clear-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-search-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.clear-search-btn svg {
    width: 18px;
    height: 18px;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    display: none; /* Hidden on desktop */
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--gray-700);
    transition: all var(--transition-base);
    margin-right: var(--spacing-sm);
}

.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--tim-red);
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
}

/* Show hamburger menu only on mobile */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }
}

.sidebar-nav-link {
    display: none;
    align-items: center;
    gap: var(--spacing-sm);
    margin: 0 var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    background: rgba(214, 20, 50, 0.08);
    color: var(--tim-red);
    text-decoration: none;
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 14px;
    line-height: 1.2;
    transition: all var(--transition-base);
    box-shadow: inset 0 0 0 1px rgba(212, 20, 50, 0.15);
}

.sidebar-nav-link:hover {
    background: rgba(212, 20, 50, 0.14);
    box-shadow: inset 0 0 0 1px rgba(212, 20, 50, 0.3);
    transform: translateY(-1px);
}

.sidebar-nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .sidebar-nav-link {
        display: flex;
    }
}

.new-conversation-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin: var(--spacing-md);
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--tim-red) 0%, #D41432 100%);
    color: var(--pure-white);
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
}

.new-conversation-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.new-conversation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.new-conversation-btn svg {
    width: 18px;
    height: 18px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.conversations-list::-webkit-scrollbar {
    width: 6px;
}

.conversations-list::-webkit-scrollbar-track {
    background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-pill);
}

.conversation-item {
    padding: var(--spacing-md);
    background: var(--pure-white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.conversation-item:hover {
    background: var(--gray-100);
    border-color: var(--tim-red);
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.conversation-item.active {
    background: var(--tim-red-light);
    border-color: var(--tim-red);
    box-shadow: var(--shadow-md);
}

.conversation-item:hover .conversation-delete-btn {
    opacity: 1;
    visibility: visible;
}

.conversation-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-900);
    margin-bottom: var(--spacing-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 32px; /* Space for delete button */
}

.conversation-delete-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #dc2626;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: 10;
}

.conversation-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: scale(1.1);
}

.conversation-delete-btn svg {
    width: 14px;
    height: 14px;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--gray-500);
}

.conversation-date {
    font-weight: 400;
}

.conversation-count {
    font-weight: 500;
}

.no-conversations {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--gray-500);
    font-size: 14px;
}

.load-more-btn {
    width: 100%;
    padding: var(--spacing-md);
    margin-top: var(--spacing-sm);
    background: rgba(200, 16, 46, 0.08);
    color: var(--tim-red);
    border: 1px solid rgba(200, 16, 46, 0.2);
    border-radius: var(--radius-md);
    font-family: 'Sofia Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.load-more-btn:hover:not(:disabled) {
    background: rgba(200, 16, 46, 0.15);
    border-color: var(--tim-red);
    transform: translateY(-1px);
}

.load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ===================================
   FOOTER MÓVIL
   =================================== */
.mobile-footer {
    display: none;
}

/* ===================================
   MEDIA QUERIES - DISEÑO RESPONSIVE
   =================================== */

/* Tablets */
@media (max-width: 1024px) {
    :root {
        --header-height: 60px;
    }
    
    .chat-container,
    .input-container {
        width: 95%;
    }

    .message {
        max-width: 80%;
    }
}

/* Móviles */
@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --spacing-lg: 16px;
        --spacing-xl: 20px;
        --chat-width: 100vw;
        --input-height: 112px;
    }

    body {
        overflow: auto;
    }
    
    .app-container {
        min-height: 100vh;
        height: auto;
    }
    
    .header {
        padding: 0 var(--spacing-md);
    }
    
    /* Reducir tamaño del logo en móviles */
    .header-logo {
        height: 28px;
    }
    
	    /* Reducir tamaño del texto "Training" en móviles */
	    .header-brand {
	        font-size: 16px;
	    }
    
    /* Ocultar texto de Wiki en móviles, mostrar solo icono */
    .wiki-toggle-text {
        display: none;
    }
    
    /* Ajustar padding del botón Wiki para solo icono */
    .timspedia-btn {
        padding: 10px !important;
        min-width: 40px;
    }
    
    .logout-text {
        display: none;
    }
    
    .logout-btn {
        padding: var(--spacing-sm);
        aspect-ratio: 1;
        border-radius: 50%;
    }
    
    .main-content {
        padding: var(--spacing-md);
        height: auto;
        min-height: calc(100vh - var(--header-height));
        overflow: visible;
        padding-bottom: calc(var(--input-height) + var(--spacing-lg) + env(safe-area-inset-bottom));
    }
    
    .chat-container {
        width: 100%;
        height: calc(100vh - var(--header-height) - var(--input-height));
        min-height: 320px;
        border-radius: 0;
        padding: var(--spacing-sm) var(--spacing-md);
        padding-bottom: calc(var(--spacing-md) + var(--input-height) + env(safe-area-inset-bottom));
        scroll-padding-bottom: calc(var(--input-height) + var(--spacing-md) + env(safe-area-inset-bottom));
    }

    .input-container {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        gap: 8px;
        box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.06);
    }

    textarea {
        min-height: 44px;
        font-size: 16px;
        padding: 8px 12px;
    }

    .message {
        max-width: 88%;
        padding: 10px 14px;
        font-size: 14px;
    }

    .prompt-title {
        font-size: 28px;
    }

    .prompt-subtitle {
        font-size: 14px;
    }

    .prompt-suggestions {
        gap: 8px;
    }

    .prompt-chip {
        font-size: 12px;
        padding: 7px 14px;
    }
    
    .scroll-to-bottom {
        bottom: calc(var(--input-height) + var(--spacing-lg));
        left: auto;
        right: var(--spacing-md);
        width: 44px;
        height: 44px;
    }
    
    .toast-container {
        top: calc(var(--header-height) + var(--spacing-sm));
        right: var(--spacing-sm);
        left: var(--spacing-sm);
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }

    .mobile-footer {
        display: block;
        height: calc(env(safe-area-inset-bottom) + var(--spacing-md));
    }
}

/* ===================================
   CLASES DE UTILIDAD
   =================================== */
.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;
}

.background-gradient {
    display: none;
}

/* Send icon — handled via SVG in component */

/* Móviles pequeños */
@media (max-width: 380px) {
    .chat-container {
        height: calc(100vh - var(--header-height) - var(--input-height));
    }
    
    .logo {
        height: 28px;
    }
    
    textarea {
        min-height: 44px;
        font-size: 16px; /* Previene zoom en iOS */
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }

    .clear-btn {
        width: 36px;
        height: 36px;
    }
}

/* Animaciones reducidas para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode automático */
@media (prefers-color-scheme: dark) {
    :root {
        /* Los colores se mantienen luminosos para conservar
           el estilo premium de Ive incluso en dark mode */
    }
}

/* GPU acceleration */
.chat-container,
.input-container {
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Focus visible para accesibilidad */
*:focus-visible {
    outline: 2px solid var(--tim-red);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .header,
    .input-container,
    .scroll-to-bottom,
    .toast-container {
        display: none;
    }
    
    .chat-container {
        box-shadow: none;
        border: 1px solid var(--gray-300);
        background: var(--pure-white);
    }
}

/* ===================================
   USER PROFILE DROPDOWN
   =================================== */
.user-profile-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.user-profile-btn:hover {
    background: var(--pure-white);
    border-color: var(--tim-red);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.user-avatar,
.user-avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-fallback {
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-fallback svg {
    width: 20px;
    height: 20px;
    color: var(--gray-600);
}

.user-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-base);
}

.user-profile-btn[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 280px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(var(--blur-xl)) saturate(150%);
    -webkit-backdrop-filter: blur(var(--blur-xl)) saturate(150%);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-base);
    z-index: 2000;
}

.user-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-avatar-large,
.user-avatar-fallback-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-fallback-large {
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar-fallback-large svg {
    width: 28px;
    height: 28px;
    color: var(--gray-600);
}

.user-dropdown-info {
    flex: 1;
    min-width: 0;
}

.user-dropdown-name {
    font-family: 'Sofia Pro Bold', sans-serif;
    font-size: 16px;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-email {
    font-size: 13px;
    color: var(--gray-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0 var(--spacing-md);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--gray-700);
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: 14px;
    font-weight: 500;
}

.user-dropdown-item:hover {
    background: var(--gray-100);
}

.user-dropdown-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.user-dropdown-item.logout-item {
    color: var(--tim-red);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.user-dropdown-item.logout-item:hover {
    background: var(--tim-red-light);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .user-name {
        display: none;
    }
    
    .dropdown-arrow {
        display: none;
    }
    
    .user-profile-btn {
        padding: var(--spacing-xs);
        width: 40px;
        height: 40px;
        justify-content: center;
    }
    
    .user-dropdown-menu {
        right: -8px;
        min-width: 260px;
    }
}
