/* AI Chat Styles (extends harithkavish.github.io style.css) */
.page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    flex-direction: column;
}

/* Chat wrapper with sidebar */
.ai-chat-wrapper {
    width: 100%;
    max-width: 1200px;
    height: 600px;
    display: flex;
    gap: 15px;
}

/* Sidebar styles */
.chat-sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 15px;
    gap: 15px;
}

body.dark-mode .chat-sidebar {
    background: rgba(17, 19, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.new-chat-btn {
    padding: 12px 16px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(59, 130, 246, 0.3);
}

.chat-item.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: #2563eb;
}

body.dark-mode .chat-item {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .chat-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.chat-item-btn {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

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

/* Scrollbar for chat list */
.chat-list::-webkit-scrollbar {
    width: 4px;
}

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

.chat-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

body.dark-mode .chat-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
}

body.dark-mode .chat-container {
    background: rgba(17, 19, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.chat-header {
    flex-shrink: 0;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

body.dark-mode .chat-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
}

.chat-header h1 {
    margin: 0 0 5px 0;
    font-size: 24px;
    color: var(--text);
    font-weight: 600;
}

.chat-header .subtitle {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.5px;
}

.status {
    font-size: 12px;
    color: var(--muted);
    margin-top: 10px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--muted);
}

.welcome h2 {
    margin: 0 0 10px 0;
    color: var(--text);
}

.message {
    display: flex;
    animation: slideIn 0.3s ease-out;
    max-width: 75%;
    margin-bottom: 8px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user {
    justify-content: flex-end;
    align-self: flex-end;
    margin-left: auto;
}

.assistant {
    justify-content: flex-start;
    align-self: flex-start;
    margin-right: auto;
}

.error {
    justify-content: flex-start;
    align-self: flex-start;
}

.message-content {
    padding: 12px 14px;
    border-radius: 14px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    font-size: 14px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.user .message-content {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.assistant .message-content {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.dark-mode .assistant .message-content {
    background: rgba(17, 19, 26, 0.6);
    color: #f4f6fb;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.error .message-content {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.3);
}

/* Webkit scrollbar styling */
.messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.messages::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

.message-form {
    flex-shrink: 0;
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

body.dark-mode .message-form {
    border-top-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.message-form input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e5e7eb;
    background: #ffffff;
    color: #1a1a1a;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

body.dark-mode .message-form input {
    background: #2a2d38;
    color: #ffffff;
    border-color: #444654;
}

.message-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: rgba(255, 255, 255, 0.95);
}

body.dark-mode .message-form input:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.message-form input::placeholder {
    color: #9ca3af;
}

body.dark-mode .message-form input::placeholder {
    color: #a0aec0;
}

.message-form button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.message-form button:hover:not(:disabled) {
    opacity: 0.95;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.message-form button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2);
}

.message-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}


/* Responsive Design */
@media (max-width: 900px) {
    .ai-chat-wrapper {
        flex-direction: column;
        height: auto;
        max-width: 100%;
    }

    .chat-sidebar {
        width: 100%;
        height: 120px;
        max-height: 120px;
        flex-direction: row;
        padding: 10px;
        gap: 10px;
    }

    .new-chat-btn {
        flex-basis: auto;
        padding: 8px 12px;
        font-size: 13px;
    }

    .chat-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .chat-item {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 12px;
    }

    .chat-container {
        max-width: 100%;
        border-radius: 0;
    }

    .message-content {
        max-width: 90% !important;
    }

    .chat-header h1 {
        font-size: 20px;
    }

    .message-form {
        padding: 12px;
        gap: 8px;
    }

    .message-form input,
    .message-form button {
        padding: 9px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .page {
        padding: 10px;
    }

    .ai-chat-wrapper {
        max-width: 100%;
        height: auto;
    }

    .chat-sidebar {
        width: 100%;
        height: 100px;
        padding: 8px;
        gap: 8px;
    }

    .new-chat-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .chat-item {
        padding: 8px;
        font-size: 11px;
    }

    .chat-header {
        padding: 15px;
    }

    .chat-header h1 {
        font-size: 18px;
    }

    .messages {
        padding: 15px;
        gap: 10px;
    }

    .message-content {
        max-width: 95% !important;
        padding: 10px 12px;
        font-size: 13px;
    }

    .message-form {
        padding: 10px;
        gap: 6px;
    }

    .message-form input,
    .message-form button {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* Google Sign In Button Styles */
#googleSignInButton {
    display: flex;
    align-items: center;
    justify-content: center;
}

.signed-in-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: var(--font, 'Space Grotesk', sans-serif);
}

.signed-in-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.signed-in-button__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.signed-in-button__name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Google Sign In Button default styling (pill shape, outline) */
#googleSignInButton {
    --g_id_signin_btn_border_radius: 999px;
}

#auth-status {
    font-size: 12px;
    color: var(--muted, #666);
}

/* Delete button styling */
.delete-btn {
    background: transparent;
    border: none;
    color: #dc2626;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    transition: color 0.2s ease, transform 0.2s ease;
    opacity: 0.6;
    margin-left: 6px;
}

.delete-btn:hover {
    opacity: 1;
    color: #dc2626;
    transform: scale(1.2);
    box-shadow: none;
}

body.dark-mode .delete-btn {
    color: #ff7b7b;
}