/* Forms, dialog, genres page + responsive rules (loaded after base.css) */

.form-card {
    background-color: var(--nub-white);
    color: #222;
    border-radius: 12px;
    border: 2px solid var(--nub-purple-light);
    max-width: 760px;
    margin: 1.5rem auto;
    padding: 1.5rem 1.75rem;
}

.form-card h2 {
    color: var(--nub-purple);
}

.form-card-wide {
    max-width: 900px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.25rem;
    margin: 1rem 0;
}

.form-grid .field.full {
    grid-column: 1 / -1;
}

.form-grid label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
    color: var(--nub-purple);
}

.ref-suggest {
    display: block;
    font-size: 0.8rem;
    margin: 0.1rem 0 0.25rem;
}

.ref-suggest button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--nub-purple);
    text-decoration: underline;
    cursor: pointer;
}

.ref-suggest button:hover {
    color: #6a46b8;
}

.ref-suggest-hint {
    color: #777;
    margin-left: 0.4rem;
}

.form-grid input:not([type="checkbox"]):not([type="radio"]),
.form-grid select,
.form-grid textarea {
    width: 100%;
}

.form-grid textarea {
    resize: vertical;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem 0.75rem;
    border: 1px solid #d5cdf0;
    border-radius: 6px;
    padding: 0.5rem;
}

.checkbox-grid li {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.checkbox-grid input {
    accent-color: var(--nub-purple);
}

.only-dialog {
    display: none;
}

#form-dialog .only-standalone {
    display: none;
}

#form-dialog .only-dialog {
    display: inline-block;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.form-actions .btn {
    flex: 1 1 0;
    min-width: 150px;
}

.genre-table .btn {
    min-width: 92px;
}

.form-dialog .btn-outline,
.form-card .btn-outline {
    color: var(--nub-purple);
    border-color: var(--nub-purple-light);
}

.form-dialog .btn-outline:hover,
.form-card .btn-outline:hover {
    background-color: var(--nub-purple-light);
    color: var(--nub-white);
    text-decoration: none;
}

.errorlist {
    color: #b3261e;
    font-size: 0.85rem;
    margin: 0.2rem 0 0;
    padding-left: 1.1rem;
}

.field:has(.errorlist) input,
.field:has(.errorlist) select,
.field:has(.errorlist) textarea {
    border-color: #b3261e;
}

.delete-summary {
    border: 1px solid #d5cdf0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
}

.btn-danger {
    background-color: #b3261e;
    color: var(--nub-white);
}

.btn-danger:hover {
    filter: brightness(1.1);
    text-decoration: none;
}

.form-dialog {
    background-color: var(--nub-white);
    color: #222;
    border: 2px solid var(--nub-purple-light);
    border-radius: 12px;
    padding: 0;
    width: min(760px, 92vw);
    max-height: 88vh;
    overflow: auto;
}

.form-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.form-dialog form {
    padding: 1.25rem 1.5rem;
}

.form-dialog form h2 {
    color: var(--nub-purple);
    margin: 0 0 0.75rem;
}

.genre-add {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1rem 0 1.5rem;
    flex-wrap: wrap;
}

.genre-add label {
    font-weight: 600;
}

.genre-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.genre-table th, .genre-table td {
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #e4defa;
}

.genre-table th {
    color: var(--nub-purple);
    font-family: var(--font-heading);
}

.genre-rename {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.genre-rename input[type="text"] {
    min-width: 220px;
}

.badge-input {
    width: 70px;
    min-width: 0 !important;
}

.genre-actions-col {
    width: 120px;
}

.user-add {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto 1fr auto 1fr;
    align-items: center;
    gap: 0.6rem 0.5rem;
    margin: 1rem 0 1.5rem;
}

.user-add label {
    font-weight: 600;
}

.user-add select {
    height: 2.2rem;
}

.user-add .btn {
    grid-column: 1 / -1;
    justify-self: start;
}

.user-role {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.user-role select {
    min-width: 110px;
}

.user-pass {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.user-pass input[type="password"] {
    min-width: 160px;
}

.user-actions-col {
    width: 120px;
}

@media (max-width: 720px) {
    .site-main {
        padding: 1rem 0.75rem 2rem;
    }

    .toolbar .btn {
        padding: 0.45rem 0.8rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .checkbox-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-card {
        margin: 0.75rem auto;
        padding: 1rem 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        min-width: 0;
        width: 100%;
    }

    .form-dialog {
        width: 96vw;
        max-height: 92vh;
    }

    .form-dialog form {
        padding: 1rem;
    }

    .genre-rename {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
    }

    .genre-rename input[type="text"] {
        min-width: 0;
        width: 100%;
    }

    .genre-add {
        flex-direction: column;
        align-items: stretch;
    }

    .genre-actions-col {
        width: auto;
    }

    .user-add {
        grid-template-columns: 1fr;
    }

    .user-add .btn {
        grid-column: auto;
    }

    .user-role {
        flex-direction: column;
        align-items: stretch;
    }

    .user-pass {
        flex-direction: column;
        align-items: stretch;
    }

    .user-pass input[type="password"] {
        min-width: 0;
        width: 100%;
    }
}
