/* QuizSnap — shared form field system (dashboard & admin) */

/* ── Buttons (used alongside forms) ───────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.125rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    min-height: 2.75rem;
    touch-action: manipulation;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}
.btn-primary {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.btn-primary:hover {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}
.btn-secondary {
    background-color: #fff;
    color: #374151;
    border-color: #d1d5db;
}
.btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}
.btn-danger {
    background-color: #dc2626;
    color: #fff;
}
.btn-danger:hover {
    background-color: #b91c1c;
}

/* ── Card shell ───────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ── Form layout ──────────────────────────────────────────────── */
.qs-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.qs-form--compact {
    gap: 1rem;
}

.qs-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    background: linear-gradient(180deg, #fafbfc 0%, #ffffff 2.5rem);
}
.qs-section__header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: 0.25rem;
}
.qs-section__title {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #374151;
}
.qs-section__desc {
    font-size: 0.875rem;
    line-height: 1.45;
    color: #6b7280;
}
.qs-section__grid {
    display: grid;
    gap: 1.25rem;
}
@media (min-width: 640px) {
    .qs-section__grid--2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.qs-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
}
.qs-field--full {
    grid-column: 1 / -1;
}

.qs-label {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
}
.qs-label__optional {
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
}
.qs-label__required {
    color: #ef4444;
    font-weight: 700;
}

.qs-hint {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #6b7280;
    margin-top: 0.125rem;
}
.qs-error {
    font-size: 0.8125rem;
    line-height: 1.35;
    color: #dc2626;
    margin-top: 0.125rem;
}

/* ── Controls (input, select, textarea) ───────────────────────── */
.qs-control,
.input,
.form-field-input,
select.qs-control,
select.input,
select.form-field-input {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: #111827;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.625rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}
textarea.qs-control,
textarea.input {
    min-height: 6.5rem;
    resize: vertical;
}
select.qs-control,
select.input,
select.form-field-input {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 1.125rem;
}
.qs-control::placeholder,
.input::placeholder,
.form-field-input::placeholder {
    color: #9ca3af;
}
.qs-control:hover:not(:disabled):not([readonly]),
.input:hover:not(:disabled):not([readonly]),
.form-field-input:hover:not(:disabled):not([readonly]) {
    border-color: #9ca3af;
}
.qs-control:focus,
.input:focus,
.form-field-input:focus,
select.qs-control:focus,
select.input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.qs-control:disabled,
.qs-control[readonly],
.input:disabled,
.input[readonly] {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}
.qs-control--error,
.input.border-danger-500,
.qs-control.is-invalid {
    border-color: #f87171;
    background-color: #fef2f2;
}
.qs-control--error:focus,
.qs-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

input[type="file"].qs-control,
input[type="file"].form-field-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}
input[type="file"].qs-control::file-selector-button,
input[type="file"].form-field-input::file-selector-button {
    margin-right: 0.75rem;
    padding: 0.375rem 0.875rem;
    border: 0;
    border-radius: 0.5rem;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}
input[type="file"].qs-control::file-selector-button:hover,
input[type="file"].form-field-input::file-selector-button:hover {
    background: #dbeafe;
}

/* ── File upload ──────────────────────────────────────────────── */
.qs-file {
    position: relative;
}
.qs-file__input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.qs-file__drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 7rem;
    padding: 1.25rem 1rem;
    border: 1.5px dashed #d1d5db;
    border-radius: 0.75rem;
    background: #f9fafb;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
.qs-file__drop:hover,
.qs-file:focus-within .qs-file__drop {
    border-color: #93c5fd;
    background: #eff6ff;
}
.qs-file__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background: #dbeafe;
    color: #2563eb;
}
.qs-file__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}
.qs-file__subtitle {
    font-size: 0.8125rem;
    color: #6b7280;
}
.qs-file__name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #2563eb;
    word-break: break-all;
}
.qs-file__preview {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.qs-file__preview img {
    height: 3rem;
    width: auto;
    max-width: 8rem;
    object-fit: contain;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 0.25rem;
}

/* ── Form actions bar ─────────────────────────────────────────── */
.qs-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f3f4f6;
    margin-top: 0.25rem;
}

/* ── Page intro ───────────────────────────────────────────────── */
.qs-page-intro {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: #4b5563;
    max-width: 42rem;
}
.qs-page-intro a {
    color: #2563eb;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.qs-page-intro a:hover {
    color: #1d4ed8;
}

@media (max-width: 768px) {
    .qs-control,
    .input,
    .form-field-input,
    select.qs-control,
    select.input {
        min-height: 3rem;
        font-size: 1rem;
    }
    .btn {
        min-height: 3rem;
    }
}
