* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #38bdf8;
    --secondary-color: #7dd3fc;
    --accent-color: #0ea5e9;
    --background-light: rgba(15, 23, 42, 0.6);
    --background-dark: #020617;
    --text-dark: #f8fafc;
    --text-light: #94a3b8;
    --border-radius: 15px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-dark);
    background-image: 
        linear-gradient(rgba(2, 6, 23, 0.5), rgba(2, 6, 23, 0.8)),
        url('../background/Pantai-Sulamadaha.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

/* Background waves animation */
.wave {
    display: none;
}

@keyframes wave {
    0% { transform: translateX(0); }
    100% { transform: translateX(50%); }
}

/* ===== APP NAVBAR ===== */
.app-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* very subtle so it matches the right border of sidebar */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%;
    z-index: 1000;
}

.logo {
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.logo:hover {
    transform: translateY(-2px);
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.btn {
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
}

.btn-ghost {
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--text-dark);
    color: var(--background-dark);
    border: none;
}

.btn-primary:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.user-profile-dropdown {
    position: relative;
}

.user-profile-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 0;
}

.user-profile-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.2);
}

.user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s ease;
    z-index: 2000;
    overflow: hidden;
}

.user-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.user-menu-header {
    padding: 16px 20px;
    font-weight: 700;
    color: var(--text-dark);
    border-bottom: 1px solid var(--glass-border);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.05);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dark);
}

.user-menu-item.logout {
    border-top: 1px solid var(--glass-border);
    color: #ef4444;
}

.user-menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ===== APP LAYOUT ===== */
.app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    padding-top: 70px; /* offset for navbar */
    overflow: hidden;
}

/* ===== HISTORY SIDEBAR ===== */
.history-sidebar {
    width: 300px;
    height: 100%;
    background: rgba(2, 6, 23, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 900;
}

.history-sidebar.collapsed {
    margin-left: -300px;
}

.history-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.history-sidebar-header h4 {
    color: var(--primary-color);
    font-size: 15px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== APP MAIN CONTAINER ===== */
.app-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 2;
    padding: 20px;
    overflow: hidden;
}

.chat-history {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-history h4 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(0, 132, 214, 0.05);
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 132, 214, 0.2);
    border-radius: 10px;
}

.history-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    word-break: break-word;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.history-item-content {
    flex: 1;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.history-item-delete {
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-light);
    width: 28px;
    height: 28px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.history-item-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: scale(1.1);
}

.history-empty {
    padding: 15px;
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
    font-style: italic;
}

.new-chat-btn {
    padding: 12px 16px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: var(--primary-color);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 15px;
}

.new-chat-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.2);
}

.clear-btn {
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 50px;
    color: #ef4444;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    transform: translateY(-2px);
}

/* ===== CHAT CONTAINER (Exact clone of landing.html) ===== */
.chat-container {
    width: 100%;
    max-width: 800px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 800px;
    overflow: hidden;
    position: relative;
    animation: fadeInUp 1s ease-out 0.2s both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-color), #0ea5e9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.ai-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.ai-info p {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.ai-info p::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--accent-color);
}

.login-prompt {
    font-size: 0.85rem;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== MESSAGES CONTAINER ===== */
.messages-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}
.messages-container::-webkit-scrollbar-track {
    background: transparent;
}
.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Message Styles */
.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.assistant {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-icon {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.assistant .message-icon {
    background: linear-gradient(135deg, var(--accent-color), #0ea5e9);
    color: white;
}

.user .message-icon {
    background: var(--text-dark);
    color: var(--background-dark);
}

.message-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 100%;
}

.user .message-body {
    align-items: flex-end;
}

.assistant .message-body {
    align-items: flex-start;
}

.message-content {
    padding: 1rem 1.2rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    color: var(--text-dark);
}

.assistant .message-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 4px;
}

.user .message-content {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 1px solid rgba(255,255,255,0.1);
    border-top-right-radius: 4px;
}

/* Edit Message Container styling */
.message-edit-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.message-edit-input {
    width: 100%;
    min-width: 300px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--primary-color);
    color: var(--text-dark);
    border-radius: 12px;
    padding: 12px 15px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.message-edit-input:focus {
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
    border-color: var(--secondary-color);
}

.message-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.message-save-btn, .message-cancel-btn {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.message-save-btn {
    background: var(--primary-color);
    color: var(--background-dark);
}

.message-save-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.message-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dark);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.message-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Base formatting for strong/bold text */
.message-content strong, .message-content b {
    font-weight: 700;
    color: var(--text-dark);
    background: linear-gradient(to right, #fff, #38bdf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 1rem;
}

.chip {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chip:hover {
    background: rgba(56, 189, 248, 0.2);
    transform: translateY(-2px);
}

/* Format Markdown like content */
.message-content strong {
    color: var(--accent-color);
    font-weight: 600;
}

.message-content br {
    margin-bottom: 0.5rem;
}

/* Typing indicator exact match */
.typing-indicator {
    padding: 1rem 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 18px;
    border-top-left-radius: 4px;
    align-self: flex-start;
    margin-bottom: 1rem;
    margin-left: 3.2rem;
    display: none;
}

.typing-indicator.active {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    animation: slideIn 0.3s ease-out forwards;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== INPUT AREA ===== */
.chat-input-container {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(2, 6, 23, 0.5);
    position: relative;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.5rem;
    transition: all 0.3s;
}

.input-wrapper:focus-within {
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.8rem 1rem;
    color: var(--text-dark);
    font-size: 1rem;
    resize: none;
    outline: none;
}

.chat-input::placeholder {
    color: var(--text-light);
}

.send-btn {
    background: var(--primary-color);
    color: var(--bg-base);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
    margin-left: 0.5rem;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

.input-hint {
    display: block;
    margin-top: 8px;
    color: var(--text-light);
    font-size: 12px;
    text-align: center;
}

/* ===== MESSAGE ACTIONS (Edit, Delete, Copy) ===== */
.message-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-actions button {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.message-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dark);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

.message-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.message-edit-btn:hover {
    background: rgba(56, 189, 248, 0.2) !important;
    color: var(--primary-color) !important;
    border-color: rgba(56, 189, 248, 0.3) !important;
}

.copy-btn:hover {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #10b981 !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
}

.bot-actions-row {
    margin-top: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .history-sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 2px solid rgba(0, 132, 214, 0.1);
        margin-left: 0 !important;
    }

    .chat-header {
        padding: 15px 20px;
    }

    .header-content h1 {
        font-size: 20px;
    }

    .header-content p {
        font-size: 12px;
    }

    .messages-container {
        padding: 15px;
    }

    .message-content {
        max-width: 85%;
    }

    .input-area {
        padding: 15px 20px 20px;
    }

    .welcome-message {
        padding: 40px 20px 20px;
    }

    .welcome-message h2 {
        font-size: 24px;
    }

    .welcome-buttons {
        gap: 10px;
    }

    .welcome-btn {
        padding: 10px 16px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 95%;
        padding: 10px 14px;
        font-size: 13px;
    }

    .messages-container {
        padding: 10px;
        gap: 10px;
    }

    .chat-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .sidebar-content {
        padding: 10px;
        gap: 10px;
    }
}
