/* ===== BASE STYLES ===== */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,opsz,wght@0,18..144,300..900;1,18..144,300..900&display=swap');

* {
    margin: 0;
    padding: 0;
    outline: none;
    box-sizing: border-box;
    font-family: "Merriweather", serif;
}

:root {
    /* Color Variables - Dark Mode */
    --primary-clr: #131314;
    --secondary-clr: #1e1f20;
    --secondary-hover-clr: #333537;
    --focus-clr: #282a2c;
    --focus-hover-clr: #37393b;
    --btn-hover-clr: #2f3030;
    --text-clr: #fff;
    --text-secondary-clr: #d8d8d8;
    --heading-secondary-clr: #444746;
    --placeholder: #abafb3;
    --accent-clr: #8ab4f8;
    --error-clr: #e55865;
}

.light-mode {
    /* Color Variables - Light Mode */
    --primary-clr: #ffffff;
    --secondary-clr: #f0f4f9;
    --secondary-hover-clr: #dde3ea;
    --focus-clr: #e9eef6;
    --focus-hover-clr: #e1e6ed;
    --btn-hover-clr: #e9ecf1;
    --text-clr: #000;
    --text-secondary-clr: #4d4d4d;
    --heading-secondary-clr: #c4c7c5;
    --placeholder: #717175;
    --accent-clr: #1a73e8;
    --error-clr: #d93025;
}

body {
    background: var(--primary-clr);
    color: var(--text-clr);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== LAYOUT COMPONENTS ===== */
/* Navigation Bar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--primary-clr);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-logo {
    color: var(--text-secondary-clr);
    font-weight: 600;
    font-size: 1.1rem;
}

.navbar-btn {
    padding: 0.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    border: none;
    background: var(--secondary-clr);
    color: var(--text-clr);
    cursor: pointer;
    transition: background 0.3s ease;
}

.navbar-btn:hover {
    background: var(--secondary-hover-clr);
}

/* Header Section */
.header {
    margin-top: 6vh;
    padding: 0 1rem;
    text-align: center;
}

.header-title h1 {
    width: fit-content;
    margin: 0 auto;
    background: linear-gradient(to right, #4a90e2, #a355b9, #ff6b6b);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 3.25rem;
    font-weight: 600;
}

.header-title h2 {
    color: var(--heading-secondary-clr);
    font-size: 3.25rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Suggestion Cards */
.suggests {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4.875rem auto 0;
    gap: 0.5rem;
    max-width: 824px;
    flex-wrap: wrap;
}

.suggests-item {
    background: var(--secondary-clr);
    color: var(--text-secondary-clr);
    padding: 1rem;
    height: 12.5rem;
    width: 12.5rem;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggests-item:hover {
    background: var(--secondary-hover-clr);
    transform: translateY(-2px);
}

.suggests-item-text {
    font-weight: 500;
    line-height: 1.375rem;
}

.suggests-item-icon {
    text-align: right;
}

.suggests-item-icon i {
    font-size: 1.5rem;
    background: var(--primary-clr);
    padding: 0.5rem;
    border-radius: 50%;
}

/* Chat Container */
.chats {
    padding: 2rem 1rem 10rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--placeholder) transparent;
    flex-grow: 1;
}

.chats::-webkit-scrollbar {
    width: 6px;
}

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

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

/* Message Styles */
.message {
    max-width: 824px;
    margin: 0 auto 1.5rem;
}

.message-content {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    width: 100%;
}

.message-outgoing .message-content {
    justify-content: flex-end;
}

.message-avatar {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
    background: var(--secondary-clr);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-text {
    color: var(--text-clr);
    white-space: pre-wrap;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 18px;
    background: var(--secondary-clr);
    max-width: 80%;
    position: relative;
}

.message-outgoing .message-text {
    border-radius: 18px 0 18px 18px;
    background: var(--focus-clr);
}

.message-incoming .message-text {
    border-radius: 0 18px 18px 18px;
}

.message-error .message-text {
    color: var(--error-clr);
    background: rgba(229, 88, 101, 0.1);
}

.message-loading .message-text {
    display: none;
}

.message-loading .message-avatar {
    animation: rotate 3s linear infinite;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

/* Loading Indicator */
.message-loading-indicator {
    display: none;
    gap: 0.6rem;
    width: 100%;
    flex-direction: column;
    margin-bottom: 20px;
}

.message-loading .message-loading-indicator {
    display: flex;
}

.message-loading-indicator .message-loading-bar {
    height: 1rem;
    width: 100%;
    border-radius: 0.135rem;
    background: linear-gradient(to right, #2563ed60 30%, var(--primary-clr) 60%, #2563ed60);
    animation: loading 3s linear infinite;
    background-position: -800px 0;
}

.message-loading-indicator .message-loading-bar:first-child {
    width: 85%;
}

.message-loading-indicator .message-loading-bar:nth-child(2) {
    width: 70%;
}

@keyframes loading {
    0% {
        background-position: -800px 0;
    }

    50% {
        background-position: 0px 0;
    }

    100% {
        background-position: 800px 0;
    }
}

/* Hide header when messages exist */
.hide-header .header,
.hide-header .suggests {
    display: none;
}

/* Prompt Input */
.prompt {
    position: fixed;
    background: var(--primary-clr);
    z-index: 1000;
    width: 100%;
    left: 0;
    bottom: 0;
    padding: 1rem;
    border-top: 1px solid var(--secondary-clr);
}

.prompt-form {
    max-width: 824px;
    margin: 0 auto;
}

.prompt-input-wrapper {
    display: flex;
    position: relative;
    align-items: center;
}

.prompt-form-input {
    height: 100%;
    width: 100%;
    border: none;
    resize: none;
    font-size: 1rem;
    color: var(--text-clr);
    padding: 1rem 4.5rem 1rem 1.75rem;
    border-radius: 100px;
    background: var(--secondary-clr);
    transition: all 0.3s ease;
}

.prompt-form-input:focus {
    background: var(--focus-clr);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.3);
}

.prompt-form-input::placeholder {
    color: var(--placeholder);
}

.prompt-form-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    height: 40px;
    width: 40px;
    cursor: pointer;
    border-radius: 50%;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-clr);
    background: transparent;
    transition: all 0.3s ease;
}

.prompt-form-btn:hover {
    background: var(--btn-hover-clr);
}

.prompt-form-btn#sendBtn {
    transform: translateY(-50%) scale(0);
}

.prompt-form-input:valid~.prompt-form-btn#sendBtn {
    transform: translateY(-50%) scale(1);
}

.prompt-form-input:valid~#deletBtn {
    right: 3.5rem;
}

.prompt-disclaim {
    text-align: center;
    color: var(--placeholder);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* Markdown Content Styles */
.message-text p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.message-text ul,
.message-text ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.message-text ul {
    list-style-type: disc;
}

.message-text ol {
    list-style-type: decimal;
}

.message-text li {
    margin-bottom: 0.5rem;
}

.message-text strong {
    font-weight: bold;
}

.message-text em {
    font-style: italic;
}

.message-text a {
    color: var(--accent-clr);
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text pre {
    position: relative;
    background-color: var(--secondary-clr);
    padding: 1.5rem 1rem 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: monospace;
}

.message-text code {
    font-family: monospace;
    font-size: 0.9rem;
    color: inherit;
}

.code-language-label {
    position: absolute;
    top: 0.5rem;
    left: 0.75rem;
    color: var(--placeholder);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: bold;
}

.code-copy-btn {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary-clr);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.code-copy-btn:hover {
    color: var(--text-clr);
    background: var(--secondary-hover-clr);
}

.message-text blockquote {
    border-left: 3px solid var(--accent-clr);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary-clr);
    font-style: italic;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.message-text th,
.message-text td {
    border: 1px solid var(--secondary-hover-clr);
    padding: 0.5rem;
    text-align: left;
}

.message-text th {
    background-color: var(--secondary-clr);
}

/* ===== RESPONSIVE STYLES ===== */
@media (max-width: 1024px) {
    .suggests {
        flex-wrap: wrap;
        justify-content: center;
    }

    .suggests-item {
        width: 45%;
        height: auto;
        min-height: 10rem;
    }
}

@media (max-width: 768px) {

    .header-title h1,
    .header-title h2 {
        font-size: 2.5rem;
    }

    .navbar {
        padding: 1rem;
    }

    .suggests-item {
        width: 100%;
        height: auto;
        min-height: 8rem;
    }

    .message-text {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .navbar-logo {
        font-size: 1rem;
    }

    .header-title h1,
    .header-title h2 {
        font-size: 1.75rem;
    }

    .header {
        margin-top: 2rem;
    }

    .suggests {
        margin-top: 2rem;
    }

    .suggests-item {
        height: auto;
        min-height: 6rem;
        padding: 1rem;
    }

    .suggests-item-icon {
        display: none;
    }

    .chats {
        padding: 1rem 1rem 8rem;
    }

    .message-content {
        gap: 0.75rem;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .prompt-form-input {
        padding: 0.75rem 3.5rem 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .prompt-form-btn {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .prompt-form-input:valid~#deletBtn {
        right: 3rem;
    }

    .prompt-disclaim {
        font-size: 0.7rem;
    }
}