* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    color: #eee;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Link Input */
#link-input-container {
    width: 90%;
    max-width: 500px;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#link-input-container h3 {
    color: #00ffff;
    margin-bottom: 20px;
    font-size: 18px;
}

#link-input-container input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #0f3460;
    border-radius: 8px;
    background: #1a1a2e;
    color: #eee;
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
}

#link-input-container input:focus {
    border-color: #00ffff;
}

#link-input-container button {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

#link-input-container button:hover {
    background: linear-gradient(135deg, #6d28d9, #1d4ed8);
    box-shadow: 0 0 16px rgba(124, 58, 237, 0.4);
}

/* Chat Container */
#chat-container {
    width: 95%;
    max-width: 700px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    background: #16213e;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(124, 58, 237, 0.12), 0 4px 20px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    border: 1px solid rgba(124, 58, 237, 0.15);
}

/* Top Bar */
#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #0f3460, #1a1040);
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, #7c3aed, #00ffff) 1;
    flex-shrink: 0;
}

#top-bar-left h3 {
    color: #00ffff;
    font-size: 16px;
    text-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
}

#top-bar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

#top-bar-controls select {
    padding: 6px 10px;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #533483;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

#top-bar-controls select:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.3);
}

.icon-btn {
    width: 32px;
    height: 32px;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #533483;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #533483;
    border-color: #7c3aed;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.3);
}

/* Tab Bar */
#tab-bar {
    display: flex;
    align-items: center;
    background: #12122a;
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
    padding: 0 8px;
    flex-shrink: 0;
    overflow: hidden;
}

#tabs {
    display: flex;
    flex: 1;
    overflow-x: auto;
    gap: 2px;
    padding: 6px 0;
}

#tabs::-webkit-scrollbar {
    height: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    color: #888;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.2s;
    min-width: 0;
}

.tab:hover {
    color: #ccc;
    background: rgba(124, 58, 237, 0.1);
}

.tab.active {
    color: #eee;
    background: #1a1a2e;
    border-color: rgba(124, 58, 237, 0.3);
    border-bottom-color: transparent;
}

.tab-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-name[contenteditable="true"] {
    outline: none;
    background: #1a1a2e;
    border-radius: 3px;
    padding: 0 4px;
    max-width: 160px;
    color: #00ffff;
}

.tab-close {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 11px;
    opacity: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}

.tab:hover .tab-close {
    opacity: 0.6;
}

.tab-close:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

#new-chat-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    color: #888;
    border: 1px dashed #533483;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: 4px;
}

#new-chat-btn:hover {
    color: #00ffff;
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.15);
}

/* Messages Area */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: radial-gradient(ellipse at top, #1a1a2e 0%, #12122a 100%);
}

#messages::-webkit-scrollbar {
    width: 6px;
}

#messages::-webkit-scrollbar-track {
    background: transparent;
}

#messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #7c3aed, #533483);
    border-radius: 3px;
}

.welcome-msg {
    text-align: center;
    color: #888;
    margin: auto;
    font-size: 14px;
}

.welcome-msg p {
    padding: 20px;
    background: #16213e;
    border-radius: 12px;
    border: 1px dashed #533483;
}

/* Chat Bubbles */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #5b9bf5, #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.25);
}

.ai-message {
    align-self: flex-start;
    background: linear-gradient(135deg, #1a1040, #0f3460);
    color: #eee;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(124, 58, 237, 0.3);
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.1);
}

.message-label {
    display: block;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 4px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Thinking animation */
.thinking {
    display: inline-flex;
    gap: 4px;
    padding-top: 4px;
}

.thinking span {
    width: 6px;
    height: 6px;
    background: #7c3aed;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.thinking span:nth-child(2) {
    animation-delay: 0.2s;
    background: #a78bfa;
}

.thinking span:nth-child(3) {
    animation-delay: 0.4s;
    background: #00ffff;
}

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

/* Input Bar */
#input-bar {
    display: flex;
    padding: 12px 16px;
    background: linear-gradient(135deg, #0f3460, #1a1040);
    border-top: 1px solid rgba(124, 58, 237, 0.25);
    gap: 10px;
    flex-shrink: 0;
}

#input-bar input {
    flex: 1;
    padding: 12px 16px;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #533483;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

#input-bar input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.25);
}

#input-bar input::placeholder {
    color: #666;
}

#send-btn {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.3);
}

#send-btn:hover {
    background: linear-gradient(135deg, #6d28d9, #1d4ed8);
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Responsive */
@media (max-width: 768px) {
    #chat-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    #top-bar {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }

    #top-bar-controls {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }

    #top-bar-controls select {
        flex: 1;
        min-width: 100px;
    }

    .message {
        max-width: 90%;
        font-size: 13px;
        padding: 10px 14px;
    }

    #messages {
        padding: 12px;
        gap: 10px;
    }

    #input-bar {
        padding: 10px 12px;
    }

    #input-bar input {
        font-size: 13px;
        padding: 10px 14px;
    }

    #send-btn {
        width: 40px;
        height: 40px;
    }

    .tab-name {
        max-width: 80px;
    }
}
