/* --- Base Styles --- */
body {
    font-family: var(--font-primary);
    font-size: 16px;
    background-color: var(--clr-background);
    color: var(--clr-text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--clr-border);
    z-index: 1000;
    padding: 0 1rem;
    transition: var(--transition);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Theme Switcher --- */
.theme-switcher {
    border-radius: 0.5rem;
    position: static;
    cursor: pointer;
}

.theme-switcher:hover {
    transform: scale(1.08);
}

/* --- Form & Inputs --- */
form {
    margin-top: 5rem;
    display: flex;
    align-items: center;
    justify-content: start;
    flex-direction: column;
    width: 100%;
    padding: 1rem;
}

h1 {
    text-align: center;
}

.separator {
    margin-top: 0.6rem;
}

.Inputs {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.UserQuestion {
    flex-grow: 1;
}

.Inputs input {
    outline: none;
    padding: 0.75rem 1rem;
    border: 1px solid var(--clr-border);
    border-radius: 10px;
    font-size: 1.1rem;
    transition: var(--transition);
    font-family: var(--ff);
    font-weight: 500;
    color: var(--clr-text-primary);
    background-color: var(--clr-background);
}

.Inputs input:focus {
    border-color: var(--clr-accent-primary);
    box-shadow: 0 0 0 2px var(--clr-accent-primary);
}

.Inputs button {
    cursor: pointer;
    padding: 1rem 1.2rem;
    border: 1px solid var(--clr-border);
    border-radius: 10px;
    transition: var(--transition);
    color: var(--clr-text-primary);
    background-color: var(--clr-background);
}

.Inputs button:hover {
    box-shadow: var(--card-shadow);
}

/* --- Questions List --- */
.Questions {
    width: 100%;
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.Question {
    animation: fade 1s ease;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    border: 2px solid var(--clr-border);
    padding: 1rem;
    border-radius: 1rem;
    position: relative;
    padding-right: 60px;
}

.Question h2 {
    font-size: 1.3rem;
    word-break: break-word;
    margin: 0;
}

.delete-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 1rem;
    background: none;
    border: 1px solid var(--clr-border);
    color: var(--clr-text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    color: #ff4444;
    border-color: #ff4444;
    background-color: rgba(255, 68, 68, 0.1);
}

/* --- Sync Button --- */
.sync-trigger-btn {
    font-family: var(--font-primary);
    border: 1px solid var(--clr-border);
    color: var(--clr-text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    background: var(--clr-background-alt);
    box-shadow: 0 4px 12px var(--clr-shadow);
    height: 42px;
    transition: all 0.2s ease;
}

.sync-trigger-btn:hover {
    border-color: var(--clr-accent-primary);
    color: var(--clr-accent-primary);
}

/* --- Dialog (Modal) & Animations --- */
.sync-dialog {
    margin: auto;
    border: none;
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 550px;
    background: var(--clr-background);
    color: var(--clr-text-primary);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);

    /* Animation setup */
    transition:
        display 0.3s allow-discrete,
        overlay 0.3s allow-discrete,
        opacity 0.3s ease,
        transform 0.3s ease;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
}

/* State when <dialog open> */
.sync-dialog[open] {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Backdrop Animation */
.sync-dialog::backdrop {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    transition:
        display 0.3s allow-discrete,
        overlay 0.3s allow-discrete,
        background-color 0.3s,
        backdrop-filter 0.3s;
}

.sync-dialog[open]::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

/* Modern Browser entry point */
@starting-style {
    .sync-dialog[open] {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    .sync-dialog[open]::backdrop {
        background: rgba(0, 0, 0, 0);
        backdrop-filter: blur(0px);
    }
}

/* --- Modal Content Styles --- */
.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--clr-text-muted);
    cursor: pointer;
}

#modal-content {
    padding: 1.5rem;
}

.user-code-display {
    background: var(--clr-background) !important;
    border: 1px solid var(--clr-border) !important;
    border-radius: 10px !important;
    padding: 1rem !important;
    margin: 1rem auto !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--card-shadow);
}

.copy-code-btn {
    background: var(--clr-accent-primary) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    cursor: pointer;
    font-weight: 600;
}

#use-different-code {
    display: block;
    margin-top: .5rem;
    padding-top: .5rem;
    text-decoration: none;
    color: var(--clr-accent-primary);
    font-weight: 500;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .Inputs {
        flex-direction: column;
    }

    .Inputs input,
    .Inputs button {
        width: 100%;
    }
}

@media screen and (max-width: 568px) {
    #open-sync-modal span {
        display: none;
    }

    #open-sync-modal {
        width: 42px;
        height: 42px;
        padding: 0;
        display: grid;
        place-items: center;
    }

    .user-code-display {
        flex-direction: column;
        align-items: start;
        gap: 1rem;
    }

    .UserCode {
        /* Forces the text to wrap even if it's one long string */
        inline-size: 100%;
        overflow-wrap: break-word;
        word-break: break-all;
        white-space: normal;
    }

    .user-code-display button {
        align-self: center;
        width: 100%;
    }
}