:root {
    --primary-color: #10a37f; /* Verde de ChatGPT, más elegante y sobrio */
    --secondary-color: #343541; /* Gris oscuro para fondos */
    --bg-light: #ffffff;
    --bg-dark: #343541;
    --text-dark: #1a1a1a;
    --text-light: #ececf1;
    --sidebar-color: #202123;
    --message-user-bg: #f7f7f8;
    --message-ai-bg: #ffffff;
    --border-color: #e5e5e5;
    --button-hover: #0e8f70;
    --error-color: #ef4444;
    
    /* Tamaños responsivos */
    --sidebar-width-desktop: 260px;
    --sidebar-width-tablet: 240px;
    --sidebar-width-mobile: 100%;
    --max-content-width: 800px;
}

/* Estilo para el botón de volver a la página principal */
.back-to-home {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.back-to-home a {
    display: inline-block;
    color: var(--text-light);
    text-decoration: none;
    padding: 8px 16px;
    background-color: rgba(16, 163, 127, 0.7);
    border-radius: 4px;
    transition: background-color 0.3s, transform 0.2s;
    font-size: 14px;
}

.back-to-home a:hover {
    background-color: var(--primary-color);
    transform: translateY(-2px);
}

body, html {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    /* Eliminar overflow para que no haya scroll global */
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    display: flex;
    margin: 0;
    padding: 0;
    height: 100vh;
    background-color: var(--bg-light);
    color: var(--text-dark);
    transition: background-color 0.3s, color 0.3s;
}

body.dark {
    background-color: var(--bg-dark);
    color: var(--text-light);
}

body.loading {
    overflow: hidden;
}

/* Layout Principal */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    /* Eliminar scroll aquí también */
    overflow: hidden;
    position: relative;
}

/* Barra lateral (similar a ChatGPT) */
.sidebar {
    width: var(--sidebar-width-desktop);
    background-color: var(--sidebar-color);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    padding: 0.75rem;
    border-radius: 0.375rem;
    width: 100%;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
    color: rgba(255, 255, 255, 0.8);
}

.chat-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.chat-item.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: none;
    color: var(--text-light);
    padding: 0.75rem;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

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

/* Panel de configuración */
.settings-panel, .edit-profile-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background-color: var(--sidebar-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header h2 {
    margin: 0;
    color: var(--text-light);
    font-size: 1.25rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

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

.settings-content {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-light);
    font-size: 1.1rem;
}

.settings-description {
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Contenido principal */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    background-color: #ffffff;
}

.chat-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: var(--max-content-width);
    margin: 0 auto;
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 0 1rem;
}

.messages {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
    min-height: 0;
    /* El scroll solo aquí */
    max-height: 100%;
}

.message-group {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.dark .message-group {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.message-group.ai {
    background-color: var(--message-ai-bg);
}

.message-group.user {
    background-color: var(--message-user-bg);
}

.message-group.system-message {
    background-color: rgba(16, 163, 127, 0.1);
    border-left: 3px solid var(--primary-color);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    border-radius: 0.375rem;
    animation: fadeIn 0.5s ease-out;
}

.system-message .message-text {
    color: var(--primary-color);
    font-size: 0.95rem;
    font-style: italic;
    opacity: 0.9;
}

.dark .message-group.user {
    background-color: #343541;
}

.dark .message-group.ai {
    background-color: #444654;
}

.message-content {
    max-width: var(--max-content-width);
    margin: 0 auto;
    width: 100%;
    line-height: 1.6;
    color: #000000;
    font-weight: 500;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 0.25rem;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.message-text {
    white-space: pre-wrap;
    color: #000000;
    font-size: 1.05rem;
    font-weight: normal;
}

.message-meta {
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Área de entrada */
.input-container {
    padding: 1.5rem;
    position: relative;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-light);
}

.dark .input-container {
    background-color: var(--bg-dark);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.input-box {
    display: flex;
    position: relative;
    max-width: var(--max-content-width);
    margin: 0 auto;
    width: 100%;
}

.input-area {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem 3rem 0.75rem 1rem;
    resize: none;
    outline: none;
    max-height: 200px;
    overflow-y: auto;
    background-color: white;
    color: #000000;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.dark .input-area {
    background-color: #444654;
    border-color: rgba(255, 255, 255, 0.1);
    color: #000000;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}

.input-area:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

.send-button {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-button:hover {
    background-color: var(--button-hover);
}

.send-button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Error message */
.error-message {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin: 1rem auto;
    max-width: 800px;
    text-align: center;
    animation: fadeIn 0.3s ease-in;
}

.dark .error-message {
    background-color: rgba(239, 68, 68, 0.2);
}

/* Botones para borrar chat actual */
.delete-chat-btn {
    color: var(--error-color);
}

/* Perfil de usuario */
.profile-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.profile-avatar, .user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 500;
    overflow: hidden;
}

.profile-avatar img, .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-details {
    flex: 1;
}

.profile-email {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.25rem;
    word-break: break-all;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.settings-action-btn {
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.settings-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

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

.settings-action-btn.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Edición de perfil */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    color: #000000;
    font-size: 1rem;
}

.avatar-selection {
    margin-bottom: 1.5rem;
}

.avatar-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem;
}

.avatar-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.avatar-option:nth-child(1) { background-color: #10a37f; }
.avatar-option:nth-child(2) { background-color: #3b82f6; }
.avatar-option:nth-child(3) { background-color: #8b5cf6; }
.avatar-option:nth-child(4) { background-color: #ef4444; }
.avatar-option:nth-child(5) { background-color: #f97316; }
.avatar-option:nth-child(6) { background-color: #eab308; }

.avatar-option.selected {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

/* Loading spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dark .loading-overlay {
    background-color: rgba(0, 0, 0, 0.8);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.dark .loading-spinner {
    border-color: #444654;
    border-top-color: var(--primary-color);
}

/* Animaciones para mensajes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes messageAppear {
    0% { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    20% { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.message-sending {
    opacity: 0;
    animation: messageAppear 2s forwards;
}

.message-appear {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Media queries para responsividad */
/* Tablets */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-width-tablet);
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .chat-container {
        max-width: 90%;
    }
}

/* Móviles grandes y tablets pequeñas */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100dvh;
        min-height: 100dvh;
    }
    
    .sidebar {
        width: var(--sidebar-width-mobile);
        min-width: 0;
        max-width: 100vw;
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100%;
        height: 100%;
        padding-top: 60px; /* Espacio para el botón de menú */
    }
    
    .mobile-menu-button {
        display: flex;
        position: absolute;
        top: 1rem;
        left: 1rem;
        z-index: 101;
        background-color: var(--bg-light);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
        align-items: center;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }
    
    .dark .mobile-menu-button {
        background-color: var(--bg-dark);
    }
    
    .sidebar-header, .sidebar-footer, .user-section {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .sidebar-content {
        padding: 1rem;
    }
    
    .message-group {
        padding: 1rem 0.75rem;
    }
    
    .message-content {
        max-width: 100%;
        padding: 0 0.5rem;
    }
    
    .input-container {
        padding: 0.75rem 0.5rem;
    }
    
    .input-box {
        max-width: 100%;
        padding: 0 0.5rem;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .message-group {
        padding: 0.5rem 0.1rem;
    }
    
    .sidebar {
        font-size: 0.95em;
    }
    
    .input-area {
        font-size: 1em;
        padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    }
    
    .login-form {
        font-size: 1em;
        min-width: 90%;
        max-width: 95%;
        padding: 1.5rem 1rem;
    }
    
    .user-avatar {
        width: 30px;
        height: 30px;
    }
    
    .message-avatar {
        width: 25px;
        height: 25px;
        min-width: 25px;
    }
    
    .message-content {
        font-size: 0.95em;
    }
    
    .sidebar-header, .sidebar-footer, .user-section {
        padding: 0.75rem 0.5rem;
    }
    
    .new-chat-btn, .settings-btn {
        padding: 0.6rem;
        font-size: 0.9em;
    }
    
    .chat-item {
        padding: 0.6rem;
        font-size: 0.9em;
    }
    
    /* Ajustar tamaño de botones */
    .send-button {
        width: 36px;
        height: 36px;
    }
}

/* Mejoras extra para UX móvil */
.input-area {
    min-height: 44px;
    font-size: 1.1em;
}
.send-button {
    width: 40px;
    height: 40px;
    font-size: 1.2em;
}

::-webkit-scrollbar {
    width: 8px;
    background: #eee;
}
::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* Animaciones para transiciones suaves */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Modelo selector en el panel de configuración */
.model-selection {
    margin-top: 1rem;
}

.model-selector {
    width: 100%;
    padding: 0.85rem;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1.5px solid rgba(16, 163, 127, 0.3);
    border-radius: 0.5rem;
    color: #000000;
    outline: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.1);
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%2310a37f' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.5rem;
    padding-right: 2.5rem;
}

.model-selector:hover {
    border-color: rgba(16, 163, 127, 0.5);
    box-shadow: 0 2px 10px rgba(16, 163, 127, 0.15);
}

.model-selector:focus {
    border-color: rgba(16, 163, 127, 0.7);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.2);
}

.model-selector option {
    background-color: #ffffff;
    color: #000000;
    padding: 0.75rem;
    font-weight: 500;
}

/* Tema toggle */
.theme-toggle {
display: flex;
align-items: center;
gap: 0.75rem;
margin-top: 0.5rem;
}

.theme-label {
color: var(--text-light);
font-size: 0.95rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.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-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

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

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

/* Botón para exportar chat */
.export-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    padding: 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.export-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Overlay para paneles modales */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: none;
}

/* Sección de usuario */
.user-section {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

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

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

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

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

.user-id {
    font-size: 0.75rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    opacity: 0.7;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

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

/* Mejoras visuales para login y registro */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.login-container {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    background: linear-gradient(135deg, #10a37f 0%, #343541 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-wrapper {
    display: block;
    width: 100%;
    max-width: 350px;
    position: relative;
}

.login-form {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 8px 40px rgba(16,163,127,0.15);
    padding: 2.5rem 2rem 2rem 2rem;
    min-width: 280px;
    max-width: 350px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
    animation: fadeIn 0.5s ease-out;
    margin: 0;
    box-sizing: border-box;
}

.login-form h2 {
    margin-bottom: 1rem;
    color: #10a37f;
    text-align: center;
    font-size: 1.75rem;
    font-weight: 600;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.login-form input[type="email"],
.login-form input[type="password"] {
    padding: 0.85rem 1rem;
    border: 1.5px solid #e5e5e5;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
    color: #000000;
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
}

.login-form input:focus {
    border-color: #10a37f;
    box-shadow: 0 0 0 3px rgba(16,163,127,0.15);
}

.login-form button[type="submit"],
.login-form button.google-login-btn {
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 0.5rem;
    background: #10a37f;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.75rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(16,163,127,0.2);
    position: relative;
    overflow: hidden;
}

.login-form button[type="submit"]:hover,
.login-form button.google-login-btn:hover {
    background: #0e8f70;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16,163,127,0.3);
}

.login-form button[type="submit"]:active,
.login-form button.google-login-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(16,163,127,0.2);
}

.login-form button.google-login-btn {
    background: #fff;
    color: #222;
    border: 1.5px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.login-form button.google-login-btn:hover {
    background: #f7f7f8;
    color: #10a37f;
    border-color: #10a37f;
}

.form-feedback {
    min-height: 1.5em;
    text-align: center;
    margin-top: 0.5rem;
}

.login-error {
    color: #ef4444;
    font-size: 0.95em;
    margin: 0;
    font-weight: 500;
    animation: shake 0.5s ease-in-out;
}

.login-register {
    text-align: center;
    font-size: 0.95em;
    margin-top: 0.5rem;
    color: #666;
}

.login-register a {
    color: #10a37f;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.login-register a:hover {
    color: #0e8f70;
}

.login-register a::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: #10a37f;
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

.login-register a:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Animaciones para el formulario de login */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Spinner pequeño para botones */
.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.google-login-btn .spinner-small {
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #333;
}

/* Estilos para el formulario que se oculta */
#registerForm[style*="display:none"],
#loginForm[style*="display:none"] {
    opacity: 0;
    transform: translateY(20px);
    position: absolute;
}

/* Pantallas móviles */
@media (max-width: 480px) {
    body, html {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
    
    .login-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    
    .login-wrapper {
        max-width: 100%;
        width: 90%;
        padding: 0;
        margin: 0 auto;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .login-form {
        min-width: unset;
        max-width: 100%;
        width: 100%;
        padding: 2rem 1.5rem;
        border-radius: 1rem;
        box-shadow: 0 10px 25px rgba(16,163,127,0.2);
        margin: 0 auto;
    }
    
    .login-form h2 {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
        text-align: center;
    }
    
    .login-form input[type="email"],
    .login-form input[type="password"] {
        padding: 0.8rem 1rem;
        font-size: 1rem;
        border-width: 2px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .login-form button[type="submit"],
    .login-form button.google-login-btn {
        padding: 0.9rem 1rem;
        font-size: 1rem;
        font-weight: 600;
        margin-top: 1rem;
        width: 100%;
    }
    
    .login-register {
        margin-top: 1rem;
        font-size: 1rem;
        text-align: center;
    }
    
    .form-feedback {
        min-height: 2em;
        text-align: center;
    }
    
    .or-divider {
        margin: 1rem 0;
        text-align: center;
    }
}
    
/* Estilos para la interfaz de chat en móviles */
@media (max-width: 480px) {
    .message-group {
        padding: 0.4rem 0.1rem;
    }
    
    .message-content {
        font-size: 0.9em;
    }
    
    .input-area {
        padding: 0.6rem 2.25rem 0.6rem 0.6rem;
    }
    
    .send-button {
        width: 32px;
        height: 32px;
        right: 0.25rem;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 360px) {
    .login-form {
        padding: 1.75rem 1.25rem;
    }
    
    .login-form h2 {
        font-size: 1.4rem;
        margin-bottom: 1.25rem;
    }
    
    .login-form input[type="email"],
    .login-form input[type="password"] {
        padding: 0.7rem 0.9rem;
        font-size: 0.95rem;
    }
    
    .login-form button[type="submit"],
    .login-form button.google-login-btn {
        padding: 0.8rem 0.9rem;
        font-size: 0.95rem;
    }
}

/* Pantallas grandes */
@media (min-width: 1440px) {
    :root {
        --max-content-width: 900px;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .message-content {
        font-size: 1.05em;
    }
}

/* Soporte para dispositivos con orientación horizontal */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        padding-bottom: 0;
    }
    
    .user-section {
        padding: 0.5rem 1rem;
    }
    
    .sidebar-footer {
        padding: 0.5rem 1rem;
    }
    
    .sidebar-header {
        padding: 0.5rem 1rem;
    }
    
    .input-container {
        padding: 0.5rem;
    }
    
    .message-group {
        padding: 0.75rem 0.5rem;
    }
    
    .login-container {
        padding: 0;
        align-items: center;
    }
    
    .login-wrapper {
        display: flex;
        justify-content: center;
        max-width: 90%;
    }
    
    .login-form {
        padding: 1.25rem 1.5rem;
        max-height: 85vh;
        overflow-y: auto;
        max-width: 400px;
        margin: 0 auto;
        border-radius: 1rem;
    }
    
    .login-form h2 {
        margin-bottom: 0.75rem;
        font-size: 1.5rem;
    }
    
    .input-group {
        margin-bottom: 0.5rem;
    }
}

/* Soporte para pantallas de alta densidad */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .message-content img,
    .message-avatar img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Soporte para modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
    body:not(.light) {
        background-color: var(--bg-dark);
        color: var(--text-light);
    }
}

/* Soporte para preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Estilos para accesibilidad */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Mejoras de enfoque para accesibilidad */
a:focus, button:focus, input:focus, textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Mejoras para dispositivos táctiles */
@media (hover: none) {
    .send-button,
    .mobile-menu-button,
    .new-chat-btn,
    .settings-btn {
        padding: 0.75rem;
    }
    
    .input-area {
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    .login-form input {
        font-size: 16px; /* Evita zoom en iOS */
    }
}
