/* CASTRUM - Form Component System
----------------------------------------
* Centralized form styles for consistent UI
*/

/* Form Variables */
:root {
    --form-field-gap: 1rem;
    --form-label-margin: 0.5rem;
    --input-padding: 0.5rem;
    --input-border-width: 1px;
    --input-border-radius: 0;
    --input-focus-outline-width: 1px;
}

/* Form Container */
.form {
    width: 100%;
}

/* Form Grid */
.form-grid {
    display: grid;
    gap: var(--form-field-gap);
    grid-template-columns: 1fr;
}

.form-grid-2 {
    display: grid;
    gap: var(--form-field-gap);
    grid-template-columns: repeat(2, 1fr);
}

.form-grid-3 {
    display: grid;
    gap: var(--form-field-gap);
    grid-template-columns: repeat(3, 1fr);
}

.form-grid-4 {
    display: grid;
    gap: var(--form-field-gap);
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 768px) {
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Form Field */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--form-label-margin);
}

.form-field-inline {
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

/* Form Label */
.form-label,
.form-field label {
    font-size: var(--font-size-label);
    font-weight: var(--font-weight-medium);
    color: var(--text-color);
    margin-bottom: var(--form-label-margin);
}

.form-label-required::after {
    content: ' *';
    color: var(--color-danger);
}

/* Form Input */
.form-input,
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="datetime-local"],
.form-field textarea,
.form-field select {
    width: 100%;
    padding: var(--input-padding);
    font-size: var(--font-size-input);
    font-family: var(--font-primary);
    color: var(--input-text);
    background-color: var(--input-bg);
    border: var(--input-border-width) solid var(--border-color);
    border-radius: var(--input-border-radius);
    transition: border-color 0.2s, outline 0.2s;
}

.form-input:focus,
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: var(--input-focus-outline-width) solid var(--color-secondary);
    outline-offset: calc(var(--input-focus-outline-width) * -1);
    border-color: var(--color-secondary);
}

.form-input:disabled,
.form-field input:disabled,
.form-field textarea:disabled,
.form-field select:disabled {
    background-color: var(--input-bg-disabled);
    color: var(--text-color-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Textarea */
textarea.form-input,
.form-field textarea {
    resize: vertical;
    min-height: 80px;
}

/* Select */
select.form-input,
.form-field select {
    cursor: pointer;
}

/* Checkbox styles moved to checkboxes.css */

/* Radio buttons */
.form-radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-radio input[type="radio"] {
    width: auto;
    margin: 0;
}

/* Form Group */
.form-group {
    margin-bottom: var(--form-field-gap);
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-actions-left {
    justify-content: flex-start;
}

.form-actions-center {
    justify-content: center;
}

.form-actions-between {
    justify-content: space-between;
}

/* Form Help Text */
.form-help {
    font-size: var(--font-size-xs);
    color: var(--text-color-muted);
    margin-top: 0.25rem;
}

/* Form Error */
.form-error {
    font-size: var(--font-size-xs);
    color: var(--color-danger);
    margin-top: 0.25rem;
}

.form-field.has-error input,
.form-field.has-error textarea,
.form-field.has-error select {
    border-color: var(--color-danger);
}

.form-field.has-error input:focus,
.form-field.has-error textarea:focus,
.form-field.has-error select:focus {
    outline-color: var(--color-danger);
}

/* Input Sizes */
.form-input-sm {
    padding: 0.375rem;
    font-size: var(--font-size-sm);
}

.form-input-lg {
    padding: 0.625rem;
    font-size: var(--font-size-base);
}

/* Dark Mode */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-field input,
[data-theme="dark"] .form-field textarea,
[data-theme="dark"] .form-field select {
    background-color: var(--input-bg);
    color: var(--input-text);
    border-color: var(--border-color);
}
