/* ========= GLOBAL & HOME PAGE STYLES (preserved) ========= */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 680px;
    background-color: #fff;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
}

h1 { font-size: 1.8em; text-align: center; color: #1c1e21; margin-bottom: 0.5em; }
p { text-align: center; color: #606770; margin-bottom: 2em; line-height: 1.6; }
#main-form { display: flex; flex-direction: column; gap: 1.5em; }
.form-group { display: flex; flex-direction: column; }
label { margin-bottom: 0.5em; font-weight: 600; color: #333; }
.field-hint { margin-top: 0.6em; font-size: 0.8em; color: #888; line-height: 1.5; text-align: left; }
textarea, select, input[type="text"]#result-link { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 1em; font-family: inherit; box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; }
textarea { resize: vertical; min-height: 80px; }
textarea:focus, select:focus, input[type="text"]#result-link:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2); }
button { padding: 12px 20px; background-color: #1a73e8; color: white; border: none; border-radius: 6px; font-size: 1em; font-weight: 600; cursor: pointer; transition: background-color 0.2s; }
button:hover { background-color: #185abc; }
#result-container { margin-top: 2em; border-top: 1px solid #e0e0e0; padding-top: 1.5em; display: flex; flex-direction: column; gap: 1em; }
#result-container p { margin-bottom: 0; text-align: left; }
#result-link { background-color: #f8f9fa; }
#copy-button { background-color: #28a745; }
#copy-button:hover { background-color: #218838; }
.hidden { display: none; }

/* ========= GPT CLONE / ANIMATION STYLES (modern ChatGPT dark UI) ========= */

body.gpt-body {
    --gpt-bg: #212121;
    --gpt-sidebar-bg: #171717;
    --gpt-bubble: #303030;
    --gpt-input-bg: #303030;
    --gpt-text: #ececec;
    --gpt-text-dim: #b4b4b4;
    --gpt-text-faint: #8e8ea0;
    --gpt-border: rgba(255, 255, 255, 0.12);
    --gpt-hover: rgba(255, 255, 255, 0.06);
    background-color: var(--gpt-bg);
    color: var(--gpt-text);
    font-family: "Helvetica Neue", Helvetica, "Segoe UI", Roboto, ui-sans-serif, system-ui, -apple-system, "Apple Color Emoji", sans-serif;
    padding: 0;
    align-items: stretch;
    overflow: hidden;
    /* CSS-driven fade-in so the clone appears smoothly even if JS is slow */
    animation: page-fade-in 0.7s ease-out both;
}
body.gpt-body.fade-out {
    animation: none;
    opacity: 0;
    transition: opacity 0.6s ease-in;
}
@keyframes page-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.gpt-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* ---- Sidebar ---- */
.gpt-sidebar {
    width: 260px;
    flex-shrink: 0;
    background-color: var(--gpt-sidebar-bg);
    color: var(--gpt-text);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
}
.sidebar-logo { display: flex; color: var(--gpt-text); }
.sidebar-icon-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 8px;
    color: var(--gpt-text-dim);
    display: flex;
    cursor: default;
}
.sidebar-icon-btn:hover { background: var(--gpt-hover); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--gpt-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    cursor: default;
    transition: background 0.15s;
}
.sidebar-link:hover { background: var(--gpt-hover); }
.sidebar-link svg { color: var(--gpt-text); flex-shrink: 0; }

.sidebar-history {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 14px;
    overflow-y: auto;
    flex-grow: 1;
}
.sidebar-section-label {
    font-size: 0.75rem;
    color: var(--gpt-text-faint);
    padding: 8px 10px 4px;
    font-weight: 500;
}
.sidebar-item {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--gpt-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
    transition: background 0.15s;
}
.sidebar-item:hover { background: var(--gpt-hover); }

.sidebar-account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    margin-top: 4px;
    cursor: default;
    transition: background 0.15s;
}
.sidebar-account:hover { background: var(--gpt-hover); }
.account-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9b5de5, #f15bb5);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.account-name { font-size: 0.875rem; color: var(--gpt-text); }

/* ---- Main column ---- */
.gpt-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
    min-width: 0;
}

.gpt-topbar {
    height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
}
.topbar-model {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--gpt-text);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: default;
    transition: background 0.15s;
}
.topbar-model:hover { background: var(--gpt-hover); }
.topbar-model svg { color: var(--gpt-text-dim); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--gpt-text);
    cursor: default;
    transition: background 0.15s;
}
.topbar-btn:hover { background: var(--gpt-hover); }
.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9b5de5, #f15bb5);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Chat area ---- */
.gpt-chat-area {
    flex-grow: 1;
    padding: 24px 20px 8px;
    overflow-y: auto;
    color: var(--gpt-text);
    font-size: 1rem;
}

.gpt-message, .user-message {
    display: flex;
    gap: 16px;
    padding: 14px 0;
    max-width: 768px;
    margin: 0 auto;
}

/* Assistant: logo avatar on the left, plain text, no background */
.gpt-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--gpt-border);
    color: var(--gpt-text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: var(--gpt-bg);
}
.gpt-avatar svg { display: block; }

/* User: right-aligned rounded bubble, no avatar (matches current ChatGPT) */
.user-message { justify-content: flex-end; }
.user-avatar { display: none; }

.gpt-message-content { padding-top: 4px; line-height: 1.75; }
.gpt-message-content p { text-align: left; color: var(--gpt-text); margin: 0; }

.user-message-content {
    background-color: var(--gpt-bubble);
    padding: 10px 18px;
    border-radius: 22px;
    max-width: 70%;
    line-height: 1.6;
}
.user-message-content p { text-align: left; color: var(--gpt-text); margin: 0; }

.user-message {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.45s, transform 0.45s;
}
.user-message.visible { opacity: 1; transform: translateY(0); }

/* AI "thinking" indicator: three bouncing dots before the redirect */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 28px;
}
.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--gpt-text-dim);
    animation: typing-bounce 1.2s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* ---- Input area ---- */
.gpt-input-area {
    padding: 8px 20px 18px;
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(180deg, rgba(33,33,33,0), var(--gpt-bg) 40%);
}

.gpt-input-wrapper {
    max-width: 768px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background-color: var(--gpt-input-bg);
    border: 1px solid transparent;
    border-radius: 28px;
    padding: 10px 12px 10px 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    transition: border-color 0.25s, box-shadow 0.25s;
}
/* Subtle highlight when the "user" focuses the box */
.gpt-input-wrapper.focused {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#chat-input {
    width: 100%;
    padding: 6px 4px;
    border: none;
    font-size: 1rem;
    background: transparent;
    color: var(--gpt-text);
    outline: none;
}
#chat-input::placeholder { color: var(--gpt-text-faint); }

.input-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.input-tools { display: flex; align-items: center; gap: 6px; }

.tool-btn {
    height: 34px;
    min-width: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--gpt-border);
    border-radius: 18px;
    background: transparent;
    color: var(--gpt-text);
    font-size: 0.875rem;
    cursor: default;
    transition: background 0.15s;
}
.tool-btn:hover { background: var(--gpt-hover); }
.tool-btn-pill { padding: 0 12px; }

#send-button {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #676767;
    cursor: default;
    transition: background-color 0.2s, transform 0.15s;
}
#send-button svg { stroke: #ececec; transition: stroke 0.2s; }
/* Brightens to a solid white "ready" button once there's text, like real ChatGPT */
#send-button.enabled { background-color: #ffffff; }
#send-button.enabled svg { stroke: #1a1a1a; }
#send-button.active { transform: scale(0.88); }

.gpt-footer-text {
    font-size: 0.75rem;
    color: var(--gpt-text-faint);
    text-align: center;
    margin-top: 12px;
}

/* On narrow screens, hide the sidebar like ChatGPT's collapsed mobile view */
@media (max-width: 860px) {
    .gpt-sidebar { display: none; }
}

#cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    transform: translate(-100px, 50px); /* Start off-screen */
    transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
    z-index: 100;
    pointer-events: none;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
    will-change: transform;
}
#cursor svg {
    display: block;
    width: 100%;
    height: 100%;
    transition: transform 0.12s ease-out;
}
/* Press-down feedback: shrink the pointer slightly when "clicking" */
#cursor.clicking svg {
    transform: scale(0.78);
}

/* Click ripple that radiates from the cursor tip */
.click-ripple {
    position: fixed;
    top: 0;
    left: 0;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 99;
    animation: ripple 0.6s ease-out forwards;
}
@keyframes ripple {
    0%   { transform: scale(0.3); opacity: 0.9; }
    100% { transform: scale(4);   opacity: 0; }
}

#tutorial-text-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    background: linear-gradient(135deg, #e0544f, #c0392b);
    color: white;
    padding: 11px 22px;
    border-radius: 22px;
    z-index: 101;
    font-weight: bold;
    max-width: min(90vw, 560px);
    box-shadow: 0 6px 20px rgba(192, 57, 43, 0.45);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#tutorial-text-container.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#tutorial-text {
    margin: 0;
    text-align: center;
    color: white;
}