/**
 * Alston Forms - Minimalist Design System
 * Clean, functional, and accessible form styling
 */

/* ===========================
   CSS Variables & Reset
   =========================== */
:root {
    --alston-primary: #2c3e50;
    --alston-secondary: #3498db;
    --alston-success: #27ae60;
    --alston-error: #e74c3c;
    --alston-warning: #f39c12;

    --alston-bg: #ffffff;
    --alston-bg-alt: #f8f9fa;
    --alston-border: #e0e0e0;
    --alston-text: #333333;
    --alston-text-light: #6c757d;

    --alston-radius: 6px;
    --alston-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --alston-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --alston-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --alston-transition: all 0.2s ease;
}

/* ===========================
   Form Wrapper
   =========================== */
.alston-form-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--alston-bg);
    border-radius: var(--alston-radius);
    box-shadow: var(--alston-shadow-md);
}

/* ===========================
   Form Header
   =========================== */
.alston-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--alston-border);
}

.alston-form-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--alston-primary);
    letter-spacing: -0.025em;
}

/* ===========================
   Form Grid Layout
   =========================== */
.alston-form-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.alston-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.alston-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {

    .alston-grid-2,
    .alston-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   Form Fields
   =========================== */
.alston-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alston-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--alston-text);
    letter-spacing: 0.01em;
}

.alston-required {
    color: var(--alston-error);
    margin-left: 0.25rem;
}

/* ===========================
   Input Elements
   =========================== */
.alston-input,
.alston-select,
.alston-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--alston-text);
    background: var(--alston-bg);
    border: 1px solid var(--alston-border);
    border-radius: var(--alston-radius);
    transition: var(--alston-transition);
    outline: none;
}

.alston-input:focus,
.alston-select:focus,
.alston-textarea:focus {
    border-color: var(--alston-secondary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.alston-input::placeholder,
.alston-textarea::placeholder {
    color: var(--alston-text-light);
}

.alston-input:disabled,
.alston-select:disabled,
.alston-textarea:disabled {
    background: var(--alston-bg-alt);
    cursor: not-allowed;
    opacity: 0.6;
}

.alston-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===========================
   Buttons
   =========================== */
.alston-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--alston-bg);
    background: var(--alston-primary);
    border: none;
    border-radius: var(--alston-radius);
    cursor: pointer;
    transition: var(--alston-transition);
    outline: none;
}

.alston-btn:hover {
    background: #1a252f;
    transform: translateY(-1px);
    box-shadow: var(--alston-shadow-md);
}

.alston-btn:active {
    transform: translateY(0);
}

.alston-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.alston-btn-primary {
    background: var(--alston-secondary);
}

.alston-btn-primary:hover {
    background: #2980b9;
}

.alston-btn-secondary {
    background: transparent;
    color: var(--alston-secondary);
    border: 1px solid var(--alston-secondary);
}

.alston-btn-secondary:hover {
    background: var(--alston-secondary);
    color: var(--alston-bg);
}

.alston-btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--alston-error);
    border: none;
    border-radius: var(--alston-radius);
    cursor: pointer;
    transition: var(--alston-transition);
}

.alston-btn-icon:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ===========================
   Form Actions
   =========================== */
.alston-form-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--alston-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ===========================
   Loading Spinner
   =========================== */
.alston-spinner {
    width: 20px;
    height: 20px;
    animation: alston-spin 1s linear infinite;
}

.alston-spinner circle {
    stroke: currentColor;
    stroke-linecap: round;
    animation: alston-dash 1.5s ease-in-out infinite;
}

@keyframes alston-spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes alston-dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }

    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* ===========================
   Form Messages
   =========================== */
.alston-form-message {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--alston-radius);
    font-size: 0.9375rem;
}

.alston-form-message.success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--alston-success);
    border: 1px solid var(--alston-success);
}

.alston-form-message.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--alston-error);
    border: 1px solid var(--alston-error);
}

/* ===========================
   Form Sections
   =========================== */
.alston-form-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--alston-border);
}

.alston-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.alston-section-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--alston-primary);
}

/* ===========================
   Table Styling
   =========================== */
.alston-table-wrapper {
    overflow-x: auto;
    border-radius: var(--alston-radius);
    border: 1px solid var(--alston-border);
}

.alston-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--alston-bg);
}

.alston-table thead {
    background: var(--alston-bg-alt);
}

.alston-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--alston-text);
    border-bottom: 2px solid var(--alston-border);
}

.alston-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--alston-border);
}

.alston-table tbody tr:last-child td {
    border-bottom: none;
}

.alston-table tbody tr:hover {
    background: var(--alston-bg-alt);
}

/* Table inputs */
.alston-table .alston-input,
.alston-table .alston-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .alston-form-wrapper {
        padding: 1.5rem;
    }

    .alston-form-title {
        font-size: 1.5rem;
    }

    .alston-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .alston-form-actions {
        flex-direction: column;
    }

    .alston-btn {
        width: 100%;
    }
}

/* ===========================
   Accessibility
   =========================== */
.alston-input:invalid:not(:placeholder-shown),
.alston-select:invalid:not(:placeholder-shown),
.alston-textarea:invalid:not(:placeholder-shown) {
    border-color: var(--alston-error);
}

.alston-input:valid:not(:placeholder-shown),
.alston-select:valid:not(:placeholder-shown),
.alston-textarea:valid:not(:placeholder-shown) {
    border-color: var(--alston-success);
}

/* Focus visible for keyboard navigation */
.alston-btn:focus-visible,
.alston-input:focus-visible,
.alston-select:focus-visible,
.alston-textarea:focus-visible {
    outline: 2px solid var(--alston-secondary);
    outline-offset: 2px;
}

/* ===========================
   Header Logo
   =========================== */
.alston-form-header-logo {
    display: flex;
    align-items: center;
}

.alston-form-header-logo img {
    max-height: 40px;
    width: auto;
    opacity: 0.9;
    transition: var(--alston-transition);
}

.alston-form-header-logo img:hover {
    opacity: 1;
}

/* ===========================
   Signature Pad
   =========================== */
.alston-signature-container {
    background: #fff;
    border: 1px solid var(--alston-border);
    border-radius: var(--alston-radius);
    padding: 10px;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 0.5rem;
}

.alston-signature-pad {
    width: 100%;
    height: 180px;
    background: #fff;
    cursor: crosshair;
    touch-action: none;
    border: 1px dashed #ccc;
}

.alston-clear-signature {
    position: absolute;
    bottom: 15px;
    right: 15px;
    padding: 4px 10px !important;
    font-size: 11px !important;
    height: auto !important;
    min-height: auto !important;
}

.alston-signature-field {
    margin-bottom: 1.5rem;
}