/* vote_manager/static/vote_manager/css/m3_forms.css */

/* M3 Card Style */
.m3-card {
    background-color: var(--md-sys-color-surface); /* 与 .md-card 同层级(2026-09-30: token 化) */
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    color: var(--md-sys-color-on-surface);
}

.m3-card-header h2 {
    font-size: 1.5rem;
    font-weight: 500;
    margin: 0 0 24px 0;
    color: var(--md-sys-color-on-surface);
}

/* M3 Outlined Text Field */
.m3-text-field.outlined {
    position: relative;
    display: block;
    --m3-primary-color: var(--md-sys-color-primary);
    --m3-outline-color: var(--md-sys-color-outline);
    --m3-error-color: var(--md-sys-color-error);
}

.m3-text-field.outlined .label-text {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 1rem;
    color: var(--md-sys-color-on-surface-variant);
    background-color: var(--md-sys-color-surface); /* Match card background */
    padding: 0 4px;
    transition: all 0.2s ease-in-out;
    pointer-events: none;
}

.m3-text-field.outlined input,
.m3-text-field.outlined textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--m3-outline-color);
    border-radius: var(--md-sys-radius-sm, 8px);
    padding: 16px;
    font-size: 1rem;
    background: transparent;
}

.m3-text-field.outlined input:focus,
.m3-text-field.outlined textarea:focus {
    outline: none;
    border: 2px solid var(--m3-primary-color);
    padding: 15px; /* Adjust padding to account for thicker border */
}

.m3-text-field.outlined input:focus + .label-text,
.m3-text-field.outlined input:not([value=""]):not(:placeholder-shown) + .label-text,
.m3-text-field.outlined textarea:focus + .label-text,
.m3-text-field.outlined textarea:not(:empty) + .label-text {
    top: -8px;
    left: 12px;
    font-size: 0.75rem;
    color: var(--m3-primary-color);
}

/* M3 Checkbox */
.m3-checkbox-field {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.m3-checkbox-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--md-sys-color-primary);
    margin: 0;
}

.m3-checkbox-field label {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

/* M3 Buttons:样式统一在 components.css 的 .m3-button(filled/outlined/text)。
   此处只保留表单操作区的布局。 */
.m3-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

/* M3 Error Styling */
.m3-error-container,
.m3-error-list {
    color: var(--md-sys-color-error);
    font-size: 0.8rem;
    padding: 8px 12px;
    background-color: color-mix(in srgb, var(--md-sys-color-error) 8%, transparent);
    border-radius: var(--md-sys-shape-corner-small);
}

.m3-error-list {
    margin-top: 4px;
    padding: 0;
    background-color: transparent;
}

.m3-error-list ul {
    margin: 0;
    padding-left: 1.2em;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-grid-item.full-width {
    grid-column: 1 / -1;
}
.form-settings-box {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-radius-md);
    background-color: var(--md-sys-color-surface-container-lowest);
}
.m3-text-field.outlined input[type="datetime-local"] + .label-text {
    top: -8px;
    left: 12px;
    font-size: 0.75rem;
    color: var(--m3-primary-color, #6750a4);
}
.m3-text-field.outlined select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--m3-outline-color, #79747e);
    border-radius: var(--md-sys-radius-sm, 8px);
    padding: 16px;
    font-size: 1rem;
    background: transparent;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24'%3E%3Cpath fill='%2349454F' d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    cursor: pointer;
}
.m3-text-field.outlined select:focus {
    outline: none;
    border: 2px solid var(--m3-primary-color, #6750a4);
    padding: 15px; /* Adjust padding for thicker border */
}
.m3-text-field.outlined select + .label-text {
    top: -8px;
    left: 12px;
    font-size: 0.75rem;
    color: var(--m3-primary-color, #6750a4);
}
.m3-read-only-field { display: flex; flex-direction: column; gap: 0.25rem; }
.m3-read-only-field .label-text { font-size: 0.75rem; color: var(--m3-on-surface-variant-color, #49454F); }
.status-badge { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.75rem; border-radius: var(--md-sys-radius-md); font-weight: 500; width: fit-content; }
.status-badge.active { background-color: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.status-badge.inactive { background-color: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.status-badge .material-symbols-outlined { font-size: 1.125rem; }
.status-reason { font-size: 0.75rem; color: var(--m3-on-surface-variant-color, #49454F); padding-left: 0.25rem; }

/* --- Styles for the Category Formset --- */
.category-formset {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}
.category-formset-header {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--md-sys-color-on-surface);
}
.category-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--md-sys-radius-sm, 8px);
    background-color: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
}
.category-form-fields {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
}
.category-form-actions {
    display: flex;
    align-items: center;
}
.remove-category-btn {
    --md-sys-color-primary: var(--md-sys-color-error);
}
.category-form.hidden {
    display: none;
}

@media (max-width: 768px) {
    .form-grid, .category-form, .category-form-fields {
        grid-template-columns: 1fr;
    }
    .form-grid-item.full-width {
        grid-column: 1;
    }
}