/* ============================================================== 
   VARIABLES Y TEMAS
   ============================================================== */
:root {
    /* DEFAULT: Dark Theme */
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --primary: #8b5cf6; /* Skale Purple */
    --primary-hover: #7c3aed;
    --primary-light: rgba(139, 92, 246, 0.2);
    
    --bot-msg-bg: rgba(139, 92, 246, 0.85); /* Bot bubbles */
    --user-msg-bg: rgba(30, 41, 59, 0.8); /* User bubbles */
    --msg-text: #f8fafc;
    --msg-subtext: #cbd5e1;
    
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-text: #f8fafc;
    --input-border: rgba(255, 255, 255, 0.15);
    
    --danger: #ef4444;
    --success: #10b981;
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.05);
    
    --primary: #6366f1; /* Skale Indigo */
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    
    --bot-msg-bg: #6366f1;
    --user-msg-bg: #e2e8f0;
    --msg-text: #ffffff;
    --user-msg-text: #334155;
    --msg-subtext: #94a3b8;
    
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-text: #334155;
    --input-border: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    transition: background-color 0.4s ease;
    overflow: hidden;
}

/* Background animated circles for Glassmorphism effect */
.glass-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.15), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.15), transparent 25%);
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* SELECTION */
::selection { background: var(--primary); color: #fff; }

/* ============================================================== 
   CHAT WRAPPER (GLASSMORPHISM)
   ============================================================== */
.wrapper {
    width: 420px;
    height: 85vh; /* Increased from fixed 400px to dynamic height */
    max-height: 800px;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Rediseño para vista móvil */
@media (max-width: 480px) {
    .wrapper {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
}

/* ============================================================== 
   HEADER
   ============================================================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: transparent;
    border-bottom: 1px solid var(--glass-border);
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bot-avatar {
    position: relative;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.status-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--bg-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.bot-details .title {
    font-weight: 600;
    font-size: 16px;
    color: var(--input-text);
}

.bot-details .status-text {
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-actions button, .header-actions a {
    background: transparent;
    border: none;
    color: var(--msg-subtext);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-actions button:hover, .header-actions a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* ============================================================== 
   CHAT BODY
   ============================================================== */
.form {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.inbox {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 85%;
}

.bot-inbox { align-self: flex-start; }
.user-inbox { align-self: flex-end; flex-direction: row-reverse; }

.inbox .icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.msg-header {
    display: flex;
    flex-direction: column;
}

.msg-header p {
    padding: 12px 16px;
    font-size: 14.5px;
    line-height: 1.5;
    word-break: break-word; /* Prevents overflow of long words */
}

/* Bot Message specific styles */
.bot-inbox .msg-header p {
    background: var(--bot-msg-bg);
    color: #fff;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* User Message specific styles */
.user-inbox .msg-header p {
    background: var(--user-msg-bg);
    color: var(--input-text);
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

[data-theme="light"] .user-inbox .msg-header p {
    color: var(--user-msg-text);
}

.timestamp {
    font-size: 10px;
    color: var(--msg-subtext);
    margin-top: 4px;
}
.bot-inbox .timestamp { align-self: flex-start; margin-left: 4px; }
.user-inbox .timestamp { align-self: flex-end; margin-right: 4px; }

/* Message Entrance Animation */
.msg-anim {
    animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.init-anim {
    animation: slideUp 0.5s ease 0.5s both;
}

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

/* ============================================================== 
   TYPING INDICATOR
   ============================================================== */
.hidden { display: none !important; }

.typing-bubble {
    background: var(--user-msg-bg);
    border-radius: 16px 16px 16px 4px;
    padding: 12px 16px;
    display: flex;
    flex-direction: row !important;
    gap: 4px;
    align-items: center;
    height: 38px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--msg-subtext);
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}
.typing-dot:nth-child(1) { animation-delay: 0.2s; }
.typing-dot:nth-child(2) { animation-delay: 0.4s; }
.typing-dot:nth-child(3) { animation-delay: 0.6s; }

@keyframes blink {
    0% { opacity: 0.2; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.2; transform: scale(0.8); }
}

/* ============================================================== 
   SUGGESTIONS AREA
   ============================================================== */
.suggestions-container {
    padding: 0 20px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.sugg-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    animation: fadeIn 0.5s ease;
}

.sugg-btn:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

[data-theme="light"] .sugg-btn {
    background: #fff;
}
[data-theme="light"] .sugg-btn:hover {
    background: var(--primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================================== 
   INPUT FIELD AREA
   ============================================================== */
.typing-field {
    padding: 15px 20px;
    border-top: 1px solid var(--glass-border);
    background: transparent;
}

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

.input-data input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 14px 50px 14px 20px;
    border-radius: 25px;
    color: var(--input-text);
    font-size: 15px;
    outline: none;
    transition: all 0.3s;
}

.input-data input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-data input::placeholder {
    color: var(--msg-subtext);
}

.input-data button {
    position: absolute;
    right: 6px;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
    transform: scale(0.9);
}

/* Only show button as active when typing */
.input-data input:valid ~ button {
    opacity: 1;
    transform: scale(1);
}

.input-data button:hover {
    background: var(--primary-hover);
    transform: scale(1.05) !important;
}