:root {
    --bg-primary: #15151a;
    --bg-secondary: #1c1c22;
    --bg-card: #1e1e25;

    --accent: #5b7fd1;
    --accent-hover: #7b9ae0;
    --highlight: #d9a441;

    --text-primary: #ece9e2;
    --text-secondary: #8a8a94;
    --text-placeholder: #55555f;

    --border: #2a2a33;
    --error: #d9645a;
    --success: #d9a441;

    --border-radius: 6px;
    --font-display: 'Zodiak', serif;
    --font-mono: 'JetBrains Mono', monospace;
    --font-body: 'General Sans', sans-serif;

    --transition: all 0.35s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    background-image: radial-gradient(ellipse 900px 500px at 50% -5%, rgba(91, 127, 209, 0.1) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 60px 0 30px;
    animation: heroIn 0.7s ease-out;
}

header h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 56px;
    letter-spacing: -1px;
    line-height: 1.1;
    background: linear-gradient(135deg, #ffffff 30%, #b8b3ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

header p {
    color: var(--text-secondary);
    font-size: 17px;
    margin-top: 14px;
    font-weight: 400;
    font-family: var(--font-body);
}

@keyframes heroIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }

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

.columns {
    display: flex;
    gap: 0;
    padding: 0;
    max-width: 1000px;
    margin: 50px auto 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.input-side,
.output-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 40px;
}

.input-side {
    border-right: 1px solid var(--border);
}

.input-side:hover,
.output-side:hover {
    border-color: rgba(124, 106, 255, 0.25);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

#text-input {
    width: 100%;
    min-height: 220px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-body);
    padding: 10px;
    resize: vertical;
}

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

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

#char-count {
    text-align: right;
    color: var(--text-secondary);
    font-size: small;
}

#mode-select {
    width: 100%;
    font-family: var(--font-mono);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    padding: 10px;
    cursor: pointer;
}

#mode-select:focus {
    outline: none;
    border-color: var(--accent);
}

#run-btn {
    width: 100%;
    padding: 14px;
    border: 1.5px solid var(--accent);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

#run-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s ease;
    z-index: -1;
}

#run-btn:hover::before {
    transform: scaleX(1);
}

#run-btn:active {
    transform: scale(0.98);
}

#run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#api-key {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    padding: 10px;
}

#api-key::placeholder {
    color: var(--text-placeholder);
}

#api-key:focus {
    outline: none;
    border-color: var(--accent);
}

#help-procedure-toggler {
    align-self: flex-end;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 10px;
    letter-spacing: 1px;
    color: #ffffff94;
    font-weight: 600;
    border: none;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

#help-procedure-toggler:hover {
    /* text-decoration: underline; */
    color: white;
    background: #000000e0;
}

/* Popover Styling */
.popover {
    position: fixed;
    /* top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); */
    inset: 0;
    /* Lengendary property for placing an element on center of the page */
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* --- NEW POP-OVER PROCEDURE CONTAINER --- */
.popover-procedure {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    position: relative;
    color: var(--text-primary);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 5px;
}

.close-btn:hover {
    color: var(--error);
    transform: rotate(90deg);
}

.popover-procedure h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.steps {
    padding-left: 20px;
    line-height: 1.8;
    margin: 20px 0;
    color: var(--text-secondary);
}

.steps li {
    margin-bottom: 12px;
    font-size: 14px;
}

/* Bold parts inside steps */
.steps strong {
    color: var(--text-primary);
}

.steps a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.steps a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.note {
    background: rgba(255, 95, 109, 0.1);
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 13px;
    color: var(--error);
    margin-top: 20px;
    border-left: 4px solid var(--error);
}

.row-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.row-flex #loader {
    font-size: small;
    color: var(--text-secondary);
}

#loader.hidden {
    display: none;
}

.section-label,
.row-flex h2 {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

#output {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 20px;
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* Animation for the output text: */
#output.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

#copy-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--border-radius);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-weight: 600;
    width: 100px;
    padding: 8px 0;
    align-self: flex-end;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
}

#copy-btn:hover {
    background-color: var(--accent);
    color: white;
    transform: translateY(-1px);
}

#copy-btn.success {
    background-color: var(--success);
    border-color: var(--success);
    color: white;
}

#error-msg {
    color: var(--error);
    background-color: #ff5f6c3e;
    font-size: small;
}

footer {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px 28px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    font-size: 0.82rem;
}

footer p a {
    color: var(--accent);
    text-decoration: none;
}

footer p a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 14px;
    position: absolute;
    right: 28px;
}

.footer-links a {
    color: var(--text-secondary);
    font-size: 0.95rem;
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
    text-decoration: none;
}

.footer-links a:hover {
    opacity: 1;
    color: var(--accent);
    text-decoration: none;
}



#text-input,
#mode-select,
#api-key,
#output {
    background: rgba(15, 17, 23, 0.8);
    border: 1px solid rgba(46, 49, 72, 0.7);
}

#text-input {
    transition: border-color 0.2s ease, box-shadow 0.25s ease;
}

#mode-select,
#api-key {
    transition: var(--transition), box-shadow 0.25s ease;
}

#text-input:focus,
#mode-select:focus,
#api-key:focus {
    box-shadow: 0 0 0 3px rgba(91, 127, 209, 0.15);
    border-color: var(--accent);
}

/* Dropdown styling: */
#mode-select {
    padding: 12px 40px 12px 15px;
    transition: var(--transition);

    /* 1. Disappearing the default arrow */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* 2. Custom Elegant Arrow Background (SVG Icon) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239a9ab0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    letter-spacing: 0.3px;
}

#mode-select:hover {
    border-color: var(--accent-hover);
    background-color: #222634;
}

#mode-select option {
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 10px;
}

/* Animation for the output text when appears: */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

@keyframes wordIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

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

/* Media Query for Mobile and Tablets */
@media (max-width: 768px) {
    .columns {
        flex-direction: column;
        margin: 30px auto 0;
    }

    header h1 {
        font-size: 34px;
    }

    .input-side,
    .output-side {
        padding: 20px;
    }

    .input-side {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #output {
        white-space: unset;
    }

    .popover-procedure h3 {
        margin-right: 8px;
    }
}

#loader {
    display: flex;
    gap: 4px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

#output h1,
#output h2,
#output h3 {
    font-family: var(--font-display);
    font-weight: 400;
    margin: 16px 0 8px;
    color: var(--text-primary);
}

/* Output typography */

#output h1 {
    font-size: 24px;
}

#output h2 {
    font-size: 20px;
}

#output h3 {
    font-size: 17px;
}

#output p {
    margin-bottom: 10px;
    line-height: 1.6;
}

#output ul,
#output ol {
    padding-left: 22px;
    margin-bottom: 10px;
}

#output li {
    margin-bottom: 6px;
    line-height: 1.5;
}

#output strong {
    color: var(--text-primary);
    font-weight: 600;
}

#output code {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(91, 127, 209, 0.12);
    color: var(--accent-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

#output>*:first-child {
    margin-top: 0;
}

#char-count.near-limit {
    color: var(--highlight);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}