/* ===== CSS Variables ===== */
:root {
    --primary-yellow: #FFF9E6;
    --secondary-yellow: #FFF3CC;
    --accent-yellow: #FFE599;
    --warm-yellow: #FFD966;
    --primary-blue: #E8F4FD;
    --secondary-blue: #D0E8F9;
    --accent-blue: #A8D4F0;
    --deep-blue: #7EC4E8;
    --text-primary: #2D3748;
    --text-secondary: #4A5568;
    --text-muted: #718096;
    --white: #FFFFFF;
    --border-light: rgba(166, 196, 214, 0.3);
    --gradient-heaven: linear-gradient(135deg, var(--primary-yellow) 0%, var(--primary-blue) 50%, var(--secondary-yellow) 100%);
    --gradient-soft: linear-gradient(180deg, var(--primary-blue) 0%, var(--primary-yellow) 100%);
    --gradient-sidebar: linear-gradient(180deg, var(--secondary-blue) 0%, var(--primary-blue) 100%);
    --shadow-soft: 0 4px 20px rgba(166, 196, 214, 0.2);
    --shadow-medium: 0 8px 30px rgba(166, 196, 214, 0.3);
    --shadow-glow: 0 0 40px rgba(166, 196, 214, 0.4);
    --sidebar-width: 280px;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-heaven);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar.hidden {
    transform: translateX(-100%);
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    color: var(--deep-blue);
    display: flex;
    align-items: center;
}

.logo h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--deep-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-soft);
}

.new-chat-btn:hover {
    background: var(--primary-yellow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.plus-icon {
    font-size: 1.2rem;
    color: var(--deep-blue);
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.chat-history h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 600;
}

.history-list {
    list-style: none;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-bottom: 4px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.6);
}

.history-item.active {
    background: var(--white);
    box-shadow: var(--shadow-soft);
}

.history-icon {
    color: var(--text-muted);
}

.history-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.history-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-guide {
    padding: 20px;
    border-top: 1px solid var(--border-light);
}

.sidebar-guide h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
    font-weight: 600;
}

.guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.guide-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 8px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}

.guide-card:hover {
    background: var(--primary-yellow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.guide-card svg {
    color: var(--deep-blue);
}

.guide-card span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
}

.guide-note {
    margin-top: 14px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
}

.help-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-smooth);
}

.help-link:hover {
    background: rgba(255, 255, 255, 0.5);
}

.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
}

.sidebar-toggle:hover {
    background: var(--primary-yellow);
}

.sidebar-toggle .toggle-open {
    display: none;
}

.sidebar-toggle.collapsed .toggle-open {
    display: block;
}

.sidebar-toggle.collapsed .toggle-close {
    display: none;
}

.sidebar:not(.hidden) ~ .sidebar-toggle {
    left: calc(var(--sidebar-width) + 20px);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 100px;
    filter: blur(40px);
    pointer-events: none;
}

.cloud-1 {
    width: 400px;
    height: 200px;
    top: -50px;
    right: 10%;
    animation: cloudFloat 20s ease-in-out infinite;
}

.cloud-2 {
    width: 300px;
    height: 150px;
    bottom: 20%;
    left: 5%;
    animation: cloudFloat 25s ease-in-out infinite reverse;
}

.cloud-3 {
    width: 350px;
    height: 180px;
    top: 40%;
    right: -5%;
    animation: cloudFloat 22s ease-in-out infinite;
}

@keyframes cloudFloat {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(20px, -10px); }
    50% { transform: translate(-10px, 5px); }
    75% { transform: translate(15px, -5px); }
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px 24px;
    position: relative;
    z-index: 1;
}

.greeting-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    animation: fadeInUp 0.6s ease-out;
}

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

.greeting-content {
    text-align: center;
    max-width: 600px;
}

.greeting-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 24px;
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 500;
}

.greeting-icon svg {
    filter: drop-shadow(0 4px 12px rgba(126, 196, 232, 0.4));
}

.greeting-title {
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--deep-blue) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.greeting-line {
    font-size: 1.1rem;
    line-height: 2;
    color: var(--text-secondary);
}

.greeting-line.line-1 {
    color: var(--text-primary);
}

.greeting-line.line-3 {
    margin-top: 8px;
    color: var(--deep-blue);
    font-weight: 500;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    display: none;
    scroll-behavior: smooth;
}

.messages-container.active {
    display: block;
}

.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: messageSlide 0.4s ease-out;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent-yellow) 0%, var(--warm-yellow) 100%);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--deep-blue) 100%);
}

.message-content {
    flex: 1;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    line-height: 1.7;
    position: relative;
}

.message.user .message-content {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-light);
}

.message.assistant .message-content {
    background: var(--white);
    box-shadow: var(--shadow-soft);
}

.message-content p {
    margin-bottom: 12px;
}

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

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 8px;
}

.message-content strong {
    font-weight: 600;
}

/* Speaker Button */
.speaker-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--accent-blue);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(126, 196, 232, 0.3);
}

.speaker-btn:hover:not(:disabled) {
    background: var(--deep-blue);
    transform: scale(1.1);
}

.speaker-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-6px); opacity: 1; }
}

.input-section {
    padding-top: 20px;
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    min-height: 56px;
    box-shadow: var(--shadow-medium);
    transition: var(--transition-smooth);
}

.input-container:focus-within {
    border-color: var(--deep-blue);
    box-shadow: var(--shadow-glow);
}

textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: transparent;
    line-height: 1.5;
    max-height: 150px;
}

textarea::placeholder {
    color: var(--text-muted);
}

.voice-btn {
    width: 44px;
    height: 44px;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--deep-blue);
    flex-shrink: 0;
}

.voice-btn:hover:not(:disabled) {
    background: var(--primary-blue);
    transform: scale(1.05);
}

.voice-btn.recording {
    background: #DC2626;
    border-color: #DC2626;
    color: white;
    animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }
}

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

.send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--deep-blue) 100%);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(126, 196, 232, 0.5);
}

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

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

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

.messages-container::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 150;
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
        margin-left: 0;
    }
    
    .chat-container {
        padding: 80px 16px 24px;
    }
    
    .greeting-header {
        font-size: 1.5rem;
        flex-direction: column;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 140;
}

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