/* ==================== VARIABLES ==================== */
:root {
    --bg-dark: #1a1a1a;
    --bg-panel: #2d2d2d;
    --bg-sidebar: #232323;
    --border-color: #5a5a5a;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent: #ffffff;
    --accent-purple: #ab9ff2;
    --user-msg: #3a3a3a;
    --ai-msg: #252525;
    --phantom-purple: #ab9ff2;
}

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

body {
    font-family: 'Space Mono', monospace;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== ANIMATIONS ==================== */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==================== LOGIN SCREEN ==================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    flex-direction: column;
}

.login-screen.hidden {
    display: none;
}

.login-container {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 60px 80px;
    background: var(--bg-panel);
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.login-logo {
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
    animation: pulse 3s ease-in-out infinite;
}

.login-title {
    font-family: 'VT323', monospace;
    font-size: 36px;
    letter-spacing: 4px;
    margin-bottom: 12px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 40px;
}

.phantom-btn {
    background: linear-gradient(135deg, #ab9ff2 0%, #7c6dd8 100%);
    color: #1a1a1a;
    border: none;
    border-radius: 12px;
    padding: 16px 40px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    width: 100%;
}

.phantom-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(171, 159, 242, 0.4);
}

.phantom-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.phantom-btn svg {
    width: 24px;
    height: 24px;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.login-divider span {
    padding: 0 16px;
}

.guest-btn {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 40px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    width: 100%;
}

.guest-btn:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.guest-btn svg {
    width: 20px;
    height: 20px;
}

.login-error {
    color: #ff5f56;
    font-size: 12px;
    margin-top: 20px;
    display: none;
}

.login-error.show {
    display: block;
}

/* ==================== APP CONTAINER ==================== */
.app-container {
    display: none;
    flex: 1;
    flex-direction: column;
    height: 100vh;
}

.app-container.visible {
    display: flex;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(180deg, #3d3d3d 0%, #2d2d2d 100%);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.traffic-lights {
    display: flex;
    gap: 8px;
}

.traffic-light {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.traffic-light.red { background: #ff5f56; }
.traffic-light.yellow { background: #ffbd2e; }
.traffic-light.green { background: #27ca40; }

.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-logo {
    width: 28px;
    height: 28px;
    filter: brightness(1.1);
}

.header-title {
    font-family: 'VT323', monospace;
    font-size: 24px;
    letter-spacing: 4px;
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wallet-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-dark);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 12px;
}

.wallet-dot {
    width: 8px;
    height: 8px;
    background: #27ca40;
    border-radius: 50%;
}

.wallet-address {
    color: var(--accent-purple);
}

.wallet-info.guest-mode .wallet-dot {
    background: var(--text-secondary);
}

.wallet-info.guest-mode .wallet-address {
    color: var(--text-secondary);
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 8px;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: #ff5f56;
    color: #ff5f56;
}

/* ==================== MAIN LAYOUT ==================== */
.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px dashed var(--border-color);
}

.new-chat-btn {
    width: 100%;
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.new-chat-btn svg {
    width: 16px;
    height: 16px;
}

.sidebar-title {
    padding: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
}

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

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    position: relative;
}

.chat-item:hover {
    background: var(--bg-panel);
}

.chat-item.active {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.chat-item-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-date {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-item-delete {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    color: #ff5f56;
    background: rgba(255, 95, 86, 0.1);
}

.chat-item-delete svg {
    width: 14px;
    height: 14px;
}

.no-chats {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* ==================== MAIN CHAT AREA ==================== */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.chat-wrapper {
    flex: 1;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-panel);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ==================== WELCOME SCREEN ==================== */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.welcome-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
    animation: pulse 3s ease-in-out infinite;
}

.welcome-title {
    font-family: 'VT323', monospace;
    font-size: 32px;
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.welcome-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.8;
}

.welcome-hint {
    margin-top: 30px;
    font-size: 12px;
    color: var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.blink {
    animation: blink 1s step-end infinite;
}

/* ==================== MESSAGES ==================== */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: bold;
}

.message.user .message-avatar {
    background: var(--accent-purple);
    color: var(--bg-dark);
}

.message.assistant .message-avatar {
    background: var(--accent);
    padding: 4px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message-content {
    background: var(--user-msg);
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    border: 1px solid var(--border-color);
}

.message.assistant .message-content {
    background: var(--ai-msg);
    border-left: 3px solid var(--accent);
}

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

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

.message-content code {
    background: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    font-size: 13px;
}

.message-content pre {
    background: var(--bg-dark);
    padding: 14px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

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

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

/* ==================== INPUT AREA ==================== */
.input-area {
    padding: 16px;
    border-top: 1px dashed var(--border-color);
    background: var(--bg-panel);
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#message-input {
    width: 100%;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 18px;
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: border-color 0.2s;
}

#message-input:focus {
    outline: none;
    border-color: var(--accent);
}

#message-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    padding: 14px 24px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.send-btn:active {
    transform: translateY(0);
}

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

.send-btn svg {
    width: 18px;
    height: 18px;
}

/* ==================== FOOTER ==================== */
.footer {
    text-align: center;
    padding: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

.footer span {
    opacity: 0.6;
}

/* ==================== ERROR MESSAGE ==================== */
.error-message {
    background: rgba(255, 95, 86, 0.1);
    border: 1px solid #ff5f56;
    color: #ff5f56;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin: 10px 0;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100%;
        z-index: 100;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .main-container {
        padding: 10px;
    }

    .chat-messages {
        padding: 12px;
    }

    .message {
        max-width: 95%;
    }

    .welcome-logo {
        width: 80px;
        height: 80px;
    }

    .welcome-title {
        font-size: 24px;
    }

    .input-container {
        flex-direction: column;
    }

    .send-btn {
        width: 100%;
        justify-content: center;
    }

    .header-center {
        position: static;
        transform: none;
    }

    .wallet-info {
        display: none;
    }
}
