﻿/*
 * AIM Form System
 * Created: March 26, 2026
 * Location: AIM.Shared.UI â€” used by all form components
 *
 * Replaces the repeated inline form patterns found across 90+ components:
 *   - Grid layouts (2-col, 3-col, 4-col)
 *   - Labels (standard, small, required)
 *   - Inputs, selects, textareas
 *   - Form sections with headers
 *   - Toolbar rows (search + filters + actions)
 *   - Alert/status banners
 *
 * Usage:
 *   <div class="aim-form-grid aim-form-grid--3col">
 *     <div class="aim-form-group">
 *       <label class="aim-form-label">Name <span class="aim-required">*</span></label>
 *       <input class="aim-form-control" ... />
 *     </div>
 *   </div>
 */

/* ==========================================================================
 * GRID LAYOUTS â€” responsive column grids for form fields
 * ========================================================================== */

.aim-form-grid {
    display: grid;
    gap: 0.75rem;
}

.aim-form-grid--2col { grid-template-columns: 1fr 1fr; }
.aim-form-grid--3col { grid-template-columns: 1fr 1fr 1fr; }
.aim-form-grid--4col { grid-template-columns: repeat(4, 1fr); }
.aim-form-grid--auto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

@media (max-width: 768px) {
    .aim-form-grid--2col,
    .aim-form-grid--3col,
    .aim-form-grid--4col {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .aim-form-grid--3col,
    .aim-form-grid--4col {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==========================================================================
 * FORM GROUP â€” label + input wrapper
 * ========================================================================== */

.aim-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* ==========================================================================
 * LABELS
 * ========================================================================== */

.aim-form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text-primary);
    display: block;
}

.aim-form-label--sm {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--color-text-primary);
    display: block;
}

.aim-form-label--muted {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    display: block;
}

.aim-required {
    color: var(--color-danger-medium);
    margin-left: 0.1rem;
}

/* ==========================================================================
 * INPUTS, SELECTS, TEXTAREAS
 * ========================================================================== */

.aim-form-control {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    font-size: 0.875rem;
    color: var(--color-text-primary);
    background: var(--main-input-background, var(--surface-raised));
    line-height: 1.5;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.aim-form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 18%, transparent);
}

.aim-form-control:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--color-surface-alt);
}

/* Compact variant â€” tighter padding for dense forms */
.aim-form-control--sm {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

/* Select specific */
select.aim-form-control {
    cursor: pointer;
    appearance: auto;
}

/* Textarea specific */
textarea.aim-form-control {
    min-height: 80px;
    resize: vertical;
}

/* ==========================================================================
 * FORM SECTION â€” bordered card with header for grouping fields
 * ========================================================================== */

.aim-form-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 6px);
    overflow: hidden;
    margin-bottom: 1rem;
}

.aim-form-section__header {
    padding: 0.5rem 0.75rem;
    background: var(--surface-base);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text-primary);
}

.aim-form-section__body {
    padding: 0.75rem;
}

/* ==========================================================================
 * TOOLBAR â€” horizontal bar with filters, search, and action buttons
 * ========================================================================== */

.aim-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.aim-toolbar__group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ==========================================================================
 * BUTTONS
 * ========================================================================== */

.aim-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
    white-space: nowrap;
    line-height: 1.5;
}

.aim-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aim-btn--primary {
    background: var(--color-primary);
    color: var(--surface-raised);
    border-color: var(--color-primary);
}

.aim-btn--primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.aim-btn--secondary {
    background: transparent;
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

.aim-btn--secondary:hover:not(:disabled) {
    background: var(--color-surface-alt);
}

.aim-btn--danger {
    background: var(--color-danger-medium);
    color: var(--surface-raised);
    border-color: var(--color-danger-medium);
}

.aim-btn--danger:hover:not(:disabled) {
    background: var(--color-danger-dark);
}

.aim-btn--sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.aim-btn--ghost {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    padding: 0.3rem 0.5rem;
}

.aim-btn--ghost:hover:not(:disabled) {
    color: var(--color-text-primary);
    background: var(--color-surface-alt);
}

/* ==========================================================================
 * ALERT BANNERS â€” success, error, warning, info
 * ========================================================================== */

.aim-alert {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.aim-alert--success {
    background: var(--color-success-lightest);
    color: var(--color-success-dark);
    border: 1px solid var(--color-success-light);
}

.aim-alert--error {
    background: var(--color-danger-lightest);
    color: var(--color-danger-dark);
    border: 1px solid var(--color-danger-light);
}

.aim-alert--warning {
    background: var(--color-warning-lightest);
    color: var(--color-warning-dark);
    border: 1px solid var(--color-warning-light);
}

.aim-alert--info {
    background: var(--color-info-lightest);
    color: var(--color-info-dark);
    border: 1px solid var(--color-info-light);
}

.aim-alert__close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: inherit;
    opacity: 0.7;
    padding: 0;
}

.aim-alert__close:hover {
    opacity: 1;
}

/* ==========================================================================
 * TAB BAR
 * ========================================================================== */

.aim-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.aim-tab {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.aim-tab:hover {
    color: var(--color-text-primary);
}

.aim-tab--active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ==========================================================================
 * HEADER ROW â€” page/section title with action buttons
 * ========================================================================== */

.aim-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.aim-header-row h2,
.aim-header-row h3,
.aim-header-row h4,
.aim-header-row h5,
.aim-header-row h6 {
    margin: 0;
}

/* ==========================================================================
 * PRINT â€” hide form elements in print
 * ========================================================================== */

@media print {
    .aim-toolbar,
    .aim-tab-bar,
    .aim-btn,
    .aim-alert__close {
        display: none !important;
    }
}
