/* Banner shown when arriving from the search page because a word wasn't found */
.redirect-banner {
    display: none;
    max-width: 800px;
    margin: 30px auto 0;
    padding: 14px 20px;
    background-color: #fff3cd;
    border: 1px solid #ffe69c;
    border-left: 5px solid #f0ad4e;
    border-radius: 8px;
    color: #664d03;
    text-align: center;
    line-height: 1.5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.redirect-banner.visible {
    display: block;
    animation: bannerSlideIn 0.4s ease;
}

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

/* Highlight the Word field briefly when it gets auto-filled */
.form-control input.autofilled {
    animation: autofillGlow 1.4s ease;
}

@keyframes autofillGlow {
    0% { box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.55); }
    100% { box-shadow: none; }
}

/* Styling the Form */
form {
    position: relative; /* anchors the top-right clipboard copy button */
    background-color: #ffffff; /* White background for form */
    max-width: 800px;
    margin: 40px auto 110px; /* Centered with balanced top and bottom margin */
    padding: 30px 25px; /* Uniform padding for space inside form */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: box-shadow 0.3s ease;
}

form:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3); /* Enhanced shadow on hover */
}

/* Styling Form Title */
.form-title {
    text-align: center;
    color: #3e4ab1;
}

/* Styling form-control class */
.form-control {
    text-align: left;
    margin-bottom: 20px; /* Consistent bottom margin between controls */
}

/* Styling Labels */
.form-control label {
    display: block;
    margin-bottom: 8px; /* Slightly increased for clarity */
    font-weight: 600;
    color: #3a3a3a; /* Dark grey for labels */
}

/* Input and Select Fields */
.form-control input,
.form-control select {
    border: 1.5px solid #cfd8dc; /* Soft grey border */
    border-radius: 6px;
    padding: 10px 12px; /* Reduced padding for a more compact appearance */
    font-size: 1rem;
    display: block;
    width: calc(100% - 25px); /* Accounts for padding */
    color: #3a3a3a;
}

.form-control input:focus,
.form-control select:focus {
    border-color: #5c6bc0; /* Muted purple on focus */
    outline: none;
    box-shadow: 0 0 5px rgba(92, 107, 192, 0.3);
}

/* Radio Button and Checkbox Styling */
.form-control input[type="radio"],
.form-control input[type="checkbox"] {
    display: inline-block;
    width: auto;
    margin-right: 8px;
}

/* Styling Buttons */
form button {
    background-color: #00bfa5; /* Minty teal button */
    color: #ffffff; /* White text */
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    padding: 12px 0; /* Balanced padding */
    width: 100%;
    margin: 30px 0 20px; /* Added consistent top and bottom spacing */
    cursor: pointer;
    transition: background-color 0.3s ease;
}

form button:hover {
    background-color: #00897b; /* Darker teal on hover */
}

.button-container {
    display: flex;
    justify-content: center; /* Center buttons in the container */
    gap: 10px; /* Spacing between buttons */
}

/* Styling Input Fields inside form-control-inputB */
.form-control-inputB input {
    background-color: #00bfa5; /* Minty teal background */
    color: #ffffff; /* White text */
    border: none;
    border-radius: 5px;
    font-family: inherit;
    padding: 10px;
    display: block;
    width: 60%;
    margin: 10px auto; /* Centered with balanced margin */
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.form-control-inputB input:hover {
    background-color: #00897b; /* Darker teal on hover */
}

/* "Direct paste on wiktionary" while it's checking words against Wiktionary */
.form-control-inputB input.processing {
    opacity: 0.7;
    cursor: wait;
}

/* Styling Textarea */
.form-control textarea {
    background-color: #e3f2fd; /* Light pastel blue */
    border: 1.5px solid #cfd8dc; /* Soft grey border */
    border-radius: 5px;
    padding: 12px;
    display: block;
    width: calc(100% - 25px); /* Accounts for padding */
    height: 200px;
    font-family: inherit;
    color: #3a3a3a;
    resize: vertical;
}

/* Reset Button Styling */
.form-control-reset input {
    background-color: #ff5252; /* Bright coral red */
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    padding: 10px;
    display: block;
    width: 40%;
    margin: 15px auto; /* Centered with balanced margin */
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-align: center;
}

.form-control-reset input:hover {
    background-color: #d32f2f; /* Darker coral red on hover */
}

/* Toast container styling */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Toast message styling */
.toast {
    min-width: 200px;
    padding: 12px 20px;
    background-color: #333;
    color: #fff;
    border-radius: 8px;
    opacity: 0;
    transform: translateY(-20px);
    animation: slideIn 0.5s forwards, fadeOut 0.5s 3s forwards;
}

/* ===========================================================================
   Word-level card & repeatable Part-of-Speech blocks
   =========================================================================== */

.section-heading {
    margin: 0 0 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e3f2fd;
    color: #3e4ab1;
    font-size: 1.05rem;
    letter-spacing: 0.2px;
}

.section-heading-sub {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #8a93a6;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Word-level details card */
.word-card {
    background: linear-gradient(180deg, #f8faff 0%, #ffffff 100%);
    border: 1px solid #e3e8f5;
    border-radius: 10px;
    padding: 22px 20px 6px;
    margin-bottom: 26px;
}

/* Container that holds one card per part of speech */
#pos-container {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-bottom: 16px;
}

/* Each Part-of-Speech card */
.pos-block {
    position: relative;
    background-color: #ffffff;
    border: 1px solid #dfe4ee;
    border-left: 4px solid var(--pos-accent, #00bfa5);
    border-radius: 10px;
    padding: 20px 20px 6px;
    box-shadow: 0 2px 8px rgba(30, 42, 90, 0.06);
    transition: box-shadow 0.25s ease, border-left-color 0.25s ease;
    animation: posBlockIn 0.35s ease;
}

.pos-block:hover {
    box-shadow: 0 6px 16px rgba(30, 42, 90, 0.1);
}

@keyframes posBlockIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pos-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e3e8f5;
}

.pos-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--pos-badge-bg, #e6faf6);
    color: var(--pos-badge-color, #00897b);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 999px;
    letter-spacing: 0.3px;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Give each Part-of-Speech card its own accent color, cycling through a
   6-color palette, so consecutive cards are easy to tell apart at a glance. */
#pos-container > .pos-block:nth-child(6n + 1) {
    --pos-accent: #00bfa5; /* teal */
    --pos-badge-bg: #e6faf6;
    --pos-badge-color: #00897b;
}
#pos-container > .pos-block:nth-child(6n + 2) {
    --pos-accent: #5c6bc0; /* indigo */
    --pos-badge-bg: #eef0fb;
    --pos-badge-color: #3949ab;
}
#pos-container > .pos-block:nth-child(6n + 3) {
    --pos-accent: #e6b84f; /* amber */
    --pos-badge-bg: #fff8ec;
    --pos-badge-color: #a9790a;
}
#pos-container > .pos-block:nth-child(6n + 4) {
    --pos-accent: #ec407a; /* rose */
    --pos-badge-bg: #fde8ef;
    --pos-badge-color: #c2185b;
}
#pos-container > .pos-block:nth-child(6n + 5) {
    --pos-accent: #66bb6a; /* green */
    --pos-badge-bg: #edf7ee;
    --pos-badge-color: #2e7d32;
}
#pos-container > .pos-block:nth-child(6n + 6) {
    --pos-accent: #42a5f5; /* blue */
    --pos-badge-bg: #e8f4fd;
    --pos-badge-color: #1565c0;
}

.remove-pos-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background-color: #fdecea;
    color: #d32f2f;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.remove-pos-btn:hover {
    background-color: #ff5252;
    color: #fff;
    transform: scale(1.08);
}

.remove-pos-btn[hidden] {
    display: none;
}

.translation-heading {
    margin: 6px 0 14px;
    padding-top: 10px;
    border-top: 1px dashed #e3e8f5;
    color: #3a3a3a;
    font-size: 0.95rem;
}

/* Two-column layout for translation inputs on wider screens */
.translation-grid {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: 18px;
}

@media (min-width: 640px) {
    .translation-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* "+ Add another Part of Speech" button */
.add-pos-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background-color: #ffffff;
    color: #00897b;
    border: 1.5px dashed #00bfa5;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 0;
    margin: 4px 0 24px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.add-pos-btn:hover {
    background-color: #e6faf6;
}

.add-pos-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #00bfa5;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1;
}

/* ===========================================================================
   Clipboard "Copy" icon button — sits at the far right of the
   "ᱟᱢᱟᱜ ᱚᱱᱚᱞ ᱚᱨᱡᱚ" (output) label
   =========================================================================== */

.output-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.output-label-row label {
    margin-bottom: 0;
}

.copy-icon-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #00bfa5, #00897b);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 137, 123, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.copy-icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 137, 123, 0.45);
}

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

/* ===========================================================================
   Etymology (ᱟᱹᱲᱟᱹ ᱥᱤᱨᱡᱚᱱ) — off by default, up to 3 entries
   Alternative forms (ᱵᱷᱮᱜᱟᱨ ᱨᱩᱯᱠᱚ) — off by default, single field
   =========================================================================== */

#etymology-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.etymology-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #fff8ec;
    border: 1px solid #f5e2bd;
    border-radius: 8px;
    padding: 6px 10px;
}

.etymology-entry input {
    flex: 1 1 auto;
    border: 1.5px solid #cfd8dc;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 1rem;
    color: #3a3a3a;
}

.etymology-entry input:focus {
    border-color: #5c6bc0;
    outline: none;
    box-shadow: 0 0 5px rgba(92, 107, 192, 0.3);
}

.remove-etymology-entry-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background-color: #fdecea;
    color: #d32f2f;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.remove-etymology-entry-btn:hover {
    background-color: #ff5252;
    color: #fff;
    transform: scale(1.08);
}

.etymology-control {
    background-color: #fff8ec;
    border: 1px solid #f5e2bd;
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 4px;
}

.etymology-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.etymology-header label {
    margin-bottom: 0;
}

.remove-etymology-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background-color: #fdecea;
    color: #d32f2f;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.remove-etymology-btn:hover {
    background-color: #ff5252;
    color: #fff;
    transform: scale(1.08);
}

.add-buttons-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 6px 0 4px;
}

@media (min-width: 560px) {
    .add-buttons-row {
        grid-template-columns: 1fr 1fr;
    }
}

.add-etymology-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background-color: #ffffff;
    color: #b8860b;
    border: 1.5px dashed #e6b84f;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 0;
    margin: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-etymology-btn:hover {
    background-color: #fff8ec;
}

.add-etymology-btn .add-pos-icon {
    background-color: #e6b84f;
}

.add-altform-btn {
    color: #5c6bc0;
    border-color: #9fa8da;
}

.add-altform-btn:hover {
    background-color: #eef0fb;
}

.add-altform-btn .add-pos-icon {
    background-color: #5c6bc0;
}

/* ===========================================================================
   References (ᱥᱟᱹᱠᱷᱭᱟᱹᱛ) — collapsible, tick which ones to include
   =========================================================================== */

.references-section {
    margin-bottom: 22px;
}

.references-collapsible {
    background: linear-gradient(180deg, #f8faff 0%, #ffffff 100%);
    border: 1px solid #e3e8f5;
    border-radius: 10px;
    padding: 4px 20px;
}

.references-collapsible summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 0;
    color: #3e4ab1;
}

.references-collapsible summary::-webkit-details-marker {
    display: none;
}

.references-collapsible summary::marker {
    display: none;
    content: "";
}

.ref-summary-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 1.05rem;
}

.ref-summary-title::before {
    content: "▸";
    display: inline-block;
    color: #00897b;
    transition: transform 0.2s ease;
}

.references-collapsible[open] .ref-summary-title::before {
    transform: rotate(90deg);
}

.references-actions {
    display: flex;
    gap: 10px;
    padding-bottom: 10px;
}

.ref-action-btn {
    background-color: #e6faf6;
    color: #00897b;
    border: none;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ref-action-btn:hover {
    background-color: #c8f2ea;
}

.ref-action-btn-muted {
    background-color: #f1f2f6;
    color: #5a6270;
}

.ref-action-btn-muted:hover {
    background-color: #e2e4ec;
}

.references-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 2px 16px;
    border-top: 1px dashed #e3e8f5;
}

.reference-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #3a3a3a;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.reference-item:hover {
    background-color: #f2f6ff;
}

.reference-item input[type="checkbox"] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: #00bfa5;
    flex-shrink: 0;
    cursor: pointer;
}

/* ===========================================================================
   Button row — Reset (small) on the left, Direct-paste (larger) on the right
   =========================================================================== */

.button-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-control-inputB input.btn-direct-paste {
    background: linear-gradient(135deg, #5c6bc0, #3949ab);
    flex: 1 1 auto;
    width: auto;
    margin: 0;
}

.form-control-inputB input.btn-direct-paste:hover {
    background: linear-gradient(135deg, #3949ab, #2c3a94);
}

.form-control-inputB input.btn-reset-small {
    background: linear-gradient(135deg, #ff7043, #d84315);
    flex: 0 0 auto;
    width: auto;
    padding: 10px 20px;
    font-size: 0.82rem;
    margin: 0;
}

.form-control-inputB input.btn-reset-small:hover {
    background: linear-gradient(135deg, #d84315, #bf360c);
}
