/* responsive.css - v1.0
   Nueva interfaz responsiva y cómoda para todos los dispositivos
   Cargar DESPUÉS de enhancements.css */

/* ============================================================
   VARIABLES Y BASE
   ============================================================ */
:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 0px;
    --header-height: 56px;
    --input-area-height: auto;
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252539;
    --bg-hover: #2a2a3f;
    --border: #2d2d3f;
    --text: #eee;
    --text-muted: #888;
    --accent: #4cc9f0;
    --accent-soft: #72efdd;
    --danger: #e74c3c;
    --success: #2ecc71;
    --warning: #f39c12;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
}

/* Light theme override */
body.light-theme {
    --bg-primary: #f5f5fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #efeff5;
    --bg-hover: #e5e5ef;
    --border: #d8d8e0;
    --text: #1a1a2e;
    --text-muted: #666;
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.main-wrapper {
    display: flex;
    /* v14: usar 100dvh (dynamic viewport height) para que en móvil la barra
       de escritura NO se mueva cuando aparece el teclado virtual.
       Fallback a 100vh para navegadores antiguos. */
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, width 0.25s ease;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

/* ============================================================
   HEADER
   ============================================================ */
.main-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
}

.header-title {
    flex: 1;
    min-width: 0;
}

.header-title h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-badge {
    font-size: 0.7em;
    background: rgba(76,201,240,0.15);
    color: var(--accent);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    border: 1px solid rgba(76,201,240,0.3);
}

.toggle-sidebar-btn,
.btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 1rem;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-sidebar-btn:hover,
.btn-icon-only:hover {
    background: var(--bg-hover);
}

/* ============================================================
   SIDEBAR ELEMENTS
   ============================================================ */
.brand {
    padding: 16px;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand .icon-format {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
}

.brand .gradient-text {
    background: linear-gradient(135deg, #4cc9f0, #72efdd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-info {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.user-logged-in .user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.user-logged-in .user-row i {
    font-size: 1.4rem;
    color: var(--accent);
}

#user-email-display {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-mini {
    width: auto !important;
    padding: 4px 10px !important;
    font-size: 0.75rem !important;
}

.btn-new-chat {
    margin: 12px 16px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #4cc9f0, #72efdd);
    color: #0a0a1a;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
    flex-shrink: 0;
}

.btn-new-chat:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-new-chat:active {
    transform: translateY(0);
}

.personality-controls {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-thinking {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: all var(--transition);
}

.btn-thinking:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn-thinking.active {
    background: rgba(76,201,240,0.15);
    border-color: var(--accent);
    color: var(--accent);
}

/* Historial colapsable */
.history-collapsible,
.writer-mode-collapsible {
    border-bottom: 1px solid var(--border);
}

.history-collapsible-toggle,
.writer-mode-toggle {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background var(--transition);
}

.history-collapsible-toggle:hover,
.writer-mode-toggle:hover {
    background: var(--bg-hover);
}

.history-collapsible-toggle span,
.writer-mode-toggle span {
    display: flex;
    align-items: center;
    gap: 8px;
}

#history-icon,
#writer-mode-icon {
    transition: transform var(--transition);
    font-size: 0.75em;
    opacity: 0.7;
}

.history-collapsible.collapsed #history-icon,
.writer-mode-collapsible.collapsed #writer-mode-icon {
    transform: rotate(-90deg);
}

.history-collapsible-content,
.writer-mode-content {
    padding: 0 8px 8px;
    max-height: 280px;
    overflow-y: auto;
}

.conversation-history-list,
.writer-history-list-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conversation-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--transition);
    font-size: 0.82rem;
}

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

.conversation-item.active {
    background: rgba(76,201,240,0.12);
    border-left: 3px solid var(--accent);
}

.conv-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.conv-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.conv-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.conv-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-delete-conv {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    opacity: 0;
    transition: all var(--transition);
}

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

.btn-delete-conv:hover {
    color: var(--danger);
    background: rgba(231,76,60,0.1);
}

.history-actions {
    padding: 8px 4px 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.btn-history-action {
    width: 100%;
    padding: 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
}

.btn-history-action:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Atajos info */
.shortcuts-info {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    opacity: 0.85;
}

.shortcuts-info strong {
    color: var(--accent);
    display: block;
    margin-bottom: 6px;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Footer actions */
.footer-actions {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.btn-config {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: background var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.btn-config:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

/* ============================================================
   CHAT AREA
   ============================================================ */
.content-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.content-section.active {
    display: flex;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.empty-state {
    margin: auto;
    text-align: center;
    padding: 40px 20px;
    max-width: 500px;
    opacity: 0.9;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.6rem;
    margin: 0 0 8px;
    background: linear-gradient(135deg, #4cc9f0, #72efdd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.empty-state p {
    color: var(--text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

.empty-tips {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.empty-tips i {
    color: var(--warning);
}

/* Message wrappers */
.message-wrapper {
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
    position: relative;
}

.message-wrapper.user {
    align-self: flex-end;
}

.message-wrapper.ai {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    line-height: 1.55;
    font-size: 0.92rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-wrapper.user .message-content {
    background: linear-gradient(135deg, #4cc9f0, #3aa8d8);
    color: #0a0a1a;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.message-wrapper.ai .message-content {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* ============================================================
   NUEVO: FOOTER DE MENSAJE CON ACCIONES
   ============================================================ */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity var(--transition);
    flex-wrap: wrap;
}

.message-wrapper.ai:hover .message-actions,
.message-wrapper.ai.show-actions .message-actions {
    opacity: 1;
}

/* En móvil siempre visibles */
@media (max-width: 768px) {
    .message-actions {
        opacity: 1;
    }
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
}

.action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(76,201,240,0.08);
}

.action-btn.speaking {
    color: var(--success);
    border-color: var(--success);
    background: rgba(46,204,113,0.1);
}

.action-btn.speaking i {
    animation: voiceWave 0.6s ease-in-out infinite;
}

@keyframes voiceWave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.4); }
}

/* ============================================================
   BOTÓN FLOTANTE PARA DETENER VOZ (v11)
   Aparece cuando Andrea está hablando, fácil de clicar
   ============================================================ */
.stop-voice-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(231, 76, 60, 0.4), 0 0 0 0 rgba(231, 76, 60, 0.4);
    animation: stopVoicePulse 2s ease-in-out infinite;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stop-voice-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(231, 76, 60, 0.5);
}

.stop-voice-fab:active {
    transform: scale(0.98);
}

.stop-voice-fab i {
    font-size: 1.1em;
}

@keyframes stopVoicePulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(231, 76, 60, 0.4), 0 0 0 0 rgba(231, 76, 60, 0.4);
    }
    50% {
        box-shadow: 0 8px 24px rgba(231, 76, 60, 0.4), 0 0 0 12px rgba(231, 76, 60, 0);
    }
}

@media (max-width: 768px) {
    .stop-voice-fab {
        bottom: 80px; /* subir para que no choque con el input */
        right: 16px;
        padding: 12px 18px;
        font-size: 0.88rem;
    }
}

@media (max-width: 480px) {
    .stop-voice-fab span {
        display: none; /* en móvil pequeño solo icono */
    }
    .stop-voice-fab {
        padding: 14px;
        border-radius: 50%;
    }
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.input-area {
    padding: 12px 20px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 8px;
    transition: border-color var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(76,201,240,0.1);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 8px 10px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 200px;
    min-height: 24px;
    line-height: 1.4;
}

#user-input::placeholder {
    color: var(--text-muted);
}

.btn-modes {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-modes:hover {
    background: var(--bg-hover);
}

.btn-modes.active {
    color: var(--accent);
}

.modes-current-label {
    font-weight: 500;
}

.btn-voice {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-voice:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.btn-voice.listening {
    color: var(--danger);
    background: rgba(231,76,60,0.15);
    animation: voicePulse 1.2s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.5); }
    50% { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
}

.btn-send {
    background: linear-gradient(135deg, #4cc9f0, #72efdd);
    color: #0a0a1a;
    border: none;
    cursor: pointer;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: transform var(--transition), opacity var(--transition);
    flex-shrink: 0;
}

.btn-send:hover {
    transform: translateY(-1px);
}

.btn-send:active {
    transform: translateY(0);
}

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

/* ============================================================
   WRITER MODE
   ============================================================ */
.writer-mode-container,
.pages-mode-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;          /* v13: scroll vertical cuando el contenido no cabe */
    overflow-x: hidden;
    padding: 20px;
    gap: 16px;
    -webkit-overflow-scrolling: touch;  /* scroll suave en iOS */
}

.writer-mode-header,
.pages-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: sticky;          /* v13: header sticky para que siempre sea visible */
    top: 0;
    background: var(--bg-primary);
    z-index: 5;
    padding: 8px 0;
    margin: -8px 0;
}

.writer-mode-header h2,
.pages-mode-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--accent);
}

.btn-exit-writer {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
}

.btn-exit-writer:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.writer-mode-input-area,
.pages-mode-input-area,
.pages-mode-description {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    flex-shrink: 0;
}

.writer-mode-input-area label,
.pages-mode-input-area label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.writer-mode-input-area textarea,
.pages-mode-input-area textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color var(--transition);
}

.writer-mode-input-area textarea:focus,
.pages-mode-input-area textarea:focus {
    border-color: var(--accent);
}

.btn-generate {
    background: linear-gradient(135deg, #4cc9f0, #72efdd);
    color: #0a0a1a;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    margin-top: 10px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform var(--transition);
}

.btn-generate:hover {
    transform: translateY(-1px);
}

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

.writer-mode-output-area,
.pages-mode-output-area {
    /* v13: ya no hace scroll propio, lo hace el contenedor padre */
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    flex-shrink: 0;
}

.writer-mode-output-area[style*="display: block"],
.pages-mode-output-area[style*="display: block"] {
    display: block !important;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.btn-copy {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
}

.btn-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.writer-output {
    background: var(--bg-tertiary);
    padding: 14px;
    border-radius: var(--radius-sm);
    line-height: 1.6;
    min-height: 100px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============================================================
   PAGES MODE ESPECÍFICO
   ============================================================ */
.pages-mode-description p {
    margin: 0;
    line-height: 1.6;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.pages-templates {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.pages-templates-label {
    width: 100%;
    font-size: 0.82rem;
    color: var(--text-muted, #888);
    font-weight: 500;
    margin-bottom: 4px;
}

.pages-template-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: all var(--transition);
    user-select: none;
}

.pages-template-chip:hover {
    background: rgba(76,201,240,0.12);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.pages-output-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ============================================================
   MOBILE OVERLAY
   ============================================================ */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
    backdrop-filter: blur(2px);
}

.mobile-overlay.active {
    display: block;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.typing-indicator {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    border-bottom-left-radius: 4px;
    display: inline-block;
}

.simple-spinner {
    display: flex;
    gap: 4px;
    align-items: center;
}

.simple-spinner span {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.simple-spinner span:nth-child(2) { animation-delay: 0.2s; }
.simple-spinner span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet grande y desktop pequeño */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 250px;
    }
    
    .message-wrapper {
        max-width: 90%;
    }
    
    .chat-container {
        padding: 16px;
    }
}

/* Tablet */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .main-header {
        padding: 0 12px;
    }
    
    .header-title h2 {
        font-size: 0.95rem;
    }
    
    .mode-badge {
        font-size: 0.65em;
    }
    
    #new-chat-mobile {
        display: inline-flex !important;
    }
    
    .chat-container {
        padding: 12px;
        gap: 12px;
    }
    
    .message-wrapper {
        max-width: 92%;
    }
    
    .message-content {
        font-size: 0.9rem;
        padding: 10px 14px;
    }
    
    .input-area {
        padding: 8px 12px 12px;
    }
    
    .input-wrapper {
        padding: 4px 6px;
    }
    
    .btn-modes .modes-current-label {
        display: none;
    }
    
    .btn-modes::after {
        content: ' ▾';
        font-size: 0.7em;
        opacity: 0.7;
    }
    
    .writer-mode-container,
    .pages-mode-container {
        padding: 12px;
    }
    
    .shortcuts-info {
        display: none;
    }
}

/* Móvil */
@media (max-width: 480px) {
    .brand {
        padding: 12px 14px;
        font-size: 1.1rem;
    }
    
    .brand .icon-format {
        width: 28px;
        height: 28px;
    }
    
    .empty-state h2 {
        font-size: 1.3rem;
    }
    
    .empty-state p {
        font-size: 0.9rem;
    }
    
    .empty-tips {
        font-size: 0.78rem;
        padding: 10px;
    }
    
    .message-wrapper {
        max-width: 95%;
    }
    
    .message-content {
        font-size: 0.88rem;
        padding: 10px 12px;
    }
    
    .action-btn {
        font-size: 0.72rem;
        padding: 3px 8px;
    }
    
    .header-title h2 {
        font-size: 0.88rem;
    }
    
    .pages-template-chip {
        font-size: 0.75rem;
        padding: 5px 10px;
    }
}

/* Móvil pequeño */
@media (max-width: 360px) {
    .header-title h2 {
        font-size: 0.82rem;
    }
    
    .mode-badge {
        font-size: 0.6em;
    }
    
    .message-content {
        font-size: 0.85rem;
        padding: 9px 11px;
    }
}

/* Modo paisaje en móvil */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-container {
        padding: 8px 12px;
    }
    
    .input-area {
        padding: 6px 12px;
    }
    
    .empty-state {
        padding: 20px;
    }
    
    .empty-icon {
        font-size: 2.5rem;
    }
}

/* Pantallas muy grandes */
@media (min-width: 1600px) {
    :root {
        --sidebar-width: 320px;
    }
    
    .chat-container {
        max-width: 1100px;
        margin: 0 auto;
        width: 100%;
    }
    
    .input-area {
        max-width: 1140px;
        margin: 0 auto;
        width: 100%;
    }
    
    .message-wrapper {
        max-width: 75%;
    }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ============================================================
   MODO ACCESIBILIDAD
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Para usuarios que prefieren alto contraste */
@media (prefers-contrast: high) {
    :root {
        --border: #555;
        --text-muted: #aaa;
    }
}

/* ============================================================
   PRINT (si alguien imprime una conversación)
   ============================================================ */
@media print {
    .sidebar, .input-area, .main-header, .footer-actions {
        display: none !important;
    }
    
    .content-area {
        overflow: visible !important;
    }
    
    .chat-container {
        overflow: visible !important;
        padding: 0;
    }
    
    .message-wrapper {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}
