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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #1a1a1a;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    gap: 0;
    padding: 0;
}

/* Chat Section Styles - Now 30% width */
.chat-section {
    width: 30%;
    background: #2d2d2d;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #3a3a3a;
}

.chat-header {
    background: #252525;
    color: #e0e0e0;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3a3a3a;
}

.chat-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header h2::before {
    content: "🤖";
    font-size: 1.2rem;
}

.clear-btn {
    background: #3a3a3a;
    border: none;
    color: #e0e0e0;
    padding: 0.4rem 0.8rem;
    border-radius: 0.4rem;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.8rem;
}

.clear-btn:hover {
    background: #4a4a4a;
    transform: translateY(-1px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #2d2d2d;
}

/* Custom scrollbar for dark mode */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #252525;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease-out;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #404040;
}

.message.assistant .message-avatar {
    background: #3a3a3a;
}

.message-content {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border-radius: 0.8rem;
    line-height: 1.4;
    font-size: 0.85rem;
}

.message.user .message-content {
    background: #404040;
    color: #e0e0e0;
}

.message.assistant .message-content {
    background: #252525;
    color: #d0d0d0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.message-content ul {
    margin-top: 0.4rem;
    margin-left: 1.2rem;
}

.message-content li {
    margin: 0.2rem 0;
    font-size: 0.8rem;
}

.typing .message-content {
    color: #888;
    font-style: italic;
}

.chat-input-area {
    padding: 1rem;
    background: #252525;
    border-top: 1px solid #3a3a3a;
}

#messageInput {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #3a3a3a;
    border-radius: 0.4rem;
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
    transition: all 0.3s;
    background: #2d2d2d;
    color: #e0e0e0;
}

#messageInput:focus {
    outline: none;
    border-color: #666;
    background: #333;
}

#messageInput::placeholder {
    color: #777;
}

.send-btn {
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.6rem;
    background: #404040;
    color: #e0e0e0;
    border: none;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #4a4a4a;
    transform: translateY(-1px);
}

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

/* Preview Section Styles - Now 70% width */
.preview-section {
    width: 70%;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    background: #252525;
    color: #e0e0e0;
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3a3a3a;
}

.preview-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-header h2::before {
    content: "🌐";
    font-size: 1.1rem;
}

.preview-controls {
    display: flex;
    gap: 0.5rem;
}

.preview-btn {
    background: #3a3a3a;
    border: none;
    color: #e0e0e0;
    padding: 0.4rem 0.8rem;
    border-radius: 0.4rem;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.8rem;
}

.preview-btn:hover {
    background: #4a4a4a;
    transform: translateY(-1px);
}

.preview-container {
    flex: 1;
    background: #1a1a1a;
    position: relative;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .chat-section {
        width: 100%;
        height: 40%;
        border-right: none;
        border-bottom: 1px solid #3a3a3a;
    }
    
    .preview-section {
        width: 100%;
        height: 60%;
    }
    
    .chat-header h2 {
        font-size: 0.9rem;
    }
    
    .message-content {
        font-size: 0.8rem;
    }
}

/* Status indicators and animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.typing-indicator {
    display: inline-flex;
    gap: 0.2rem;
    align-items: center;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #888;
    animation: bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Small tweaks for better readability */
.message-content strong {
    color: #aaa;
}

.message-content code {
    background: #1a1a1a;
    padding: 0.1rem 0.2rem;
    border-radius: 0.2rem;
    font-family: monospace;
    font-size: 0.8rem;
}

.message-content pre {
    background: #1a1a1a;
    padding: 0.4rem;
    border-radius: 0.3rem;
    overflow-x: auto;
    margin: 0.4rem 0;
}

/* Focus styles */
button:focus, textarea:focus {
    outline: none;
}

/* Smooth transitions */
.chat-section, .preview-section {
    transition: all 0.3s ease;
}






/* Add to existing CSS */

.download-btn {
    background: #4a4a4a;
    border: 1px solid #5a5a5a;
}

.download-btn:hover {
    background: #5a5a5a;
    border-color: #6a6a6a;
    transform: translateY(-1px);
}

/* Optional: Add a pulse animation for the download button when new content is available */
@keyframes gentlePulse {
    0%, 100% {
        background: #4a4a4a;
    }
    50% {
        background: #5a8a5a;
    }
}

.download-btn.new-content {
    animation: gentlePulse 1.5s ease-in-out;
}

/* Tooltip for download button */
.preview-btn {
    position: relative;
}

.preview-btn:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid #3a3a3a;
}

/* Add tooltip text */
.download-btn {
    data-tooltip: "Download HTML code";
}

.refresh-btn {
    data-tooltip: "Refresh preview";
}

.preview-btn:last-child {
    data-tooltip: "Open in new tab";
}













/* ============================================ */
/* RESPONSIVE DESIGN PARA MÓVIL - Chat abajo, Preview arriba */
/* ============================================ */

@media (max-width: 768px) {
    /* Invertir el orden: preview arriba, chat abajo */
    .container {
        flex-direction: column-reverse !important;
    }
    
    /* Chat section - ahora abajo */
    .chat-section {
        width: 100% !important;
        height: 45% !important;
        border-right: none !important;
        border-top: 1px solid #3a3a3a !important;
        border-bottom: none !important;
    }
    
    /* Preview section - ahora arriba */
    .preview-section {
        width: 100% !important;
        height: 55% !important;
    }
    
    /* Ajustes del chat para móvil */
    .chat-header {
        padding: 0.75rem !important;
    }
    
    .chat-header h2 {
        font-size: 0.9rem !important;
    }
    
    .clear-btn {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.7rem !important;
    }
    
    .chat-messages {
        padding: 0.75rem !important;
    }
    
    .message {
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .message-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.9rem !important;
    }
    
    .message-content {
        padding: 0.5rem 0.7rem !important;
        font-size: 0.8rem !important;
    }
    
    .message-content ul {
        margin-top: 0.3rem !important;
        margin-left: 1rem !important;
    }
    
    .message-content li {
        font-size: 0.75rem !important;
    }
    
    .chat-input-area {
        padding: 0.75rem !important;
    }
    
    #messageInput {
        padding: 0.5rem !important;
        font-size: 0.8rem !important;
    }
    
    /* Evitar zoom automático en iOS */
    #messageInput {
        font-size: 16px !important;
    }
    
    .send-btn {
        padding: 0.5rem !important;
        font-size: 0.8rem !important;
        margin-top: 0.5rem !important;
    }
    
    /* Ajustes del preview para móvil */
    .preview-header {
        padding: 0.6rem 0.75rem !important;
    }
    
    .preview-header h2 {
        font-size: 0.9rem !important;
    }
    
    .preview-controls {
        gap: 0.3rem !important;
    }
    
    .preview-btn {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.7rem !important;
    }
    
    /* Mejorar el scroll en móvil */
    .chat-messages {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Mejorar los botones para touch */
    .send-btn, .clear-btn, .preview-btn {
        min-height: 36px !important;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Animación suave al cambiar de orientación */
    .chat-section, .preview-section {
        transition: height 0.3s ease !important;
    }
    
    /* Ocultar scrollbar en móvil pero mantener funcionalidad */
    .chat-messages::-webkit-scrollbar {
        width: 3px !important;
    }
    
    .chat-messages::-webkit-scrollbar-track {
        background: #252525 !important;
    }
    
    .chat-messages::-webkit-scrollbar-thumb {
        background: #4a4a4a !important;
    }
}

/* Para landscape en móvil (pantalla horizontal) */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-section {
        height: 40% !important;
    }
    
    .preview-section {
        height: 60% !important;
    }
    
    .chat-messages {
        max-height: calc(40vh - 100px) !important;
    }
    
    .message-content {
        font-size: 0.7rem !important;
    }
}

/* Para tablets (entre 769px y 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .chat-section {
        width: 35% !important;
    }
    
    .preview-section {
        width: 65% !important;
    }
    
    .chat-header h2 {
        font-size: 1rem !important;
    }
    
    .message-content {
        font-size: 0.8rem !important;
    }
}

/* Mejoras para dispositivos muy pequeños (menos de 480px) */
@media (max-width: 480px) {
    .chat-header {
        padding: 0.6rem !important;
    }
    
    .chat-header h2 {
        font-size: 0.85rem !important;
    }
    
    .preview-header h2 {
        font-size: 0.85rem !important;
    }
    
    .message-content {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.6rem !important;
    }
    
    .preview-btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.65rem !important;
    }
}
