/**
 * NEFDHA Comprehensive Form Styles
 * Extended form components and controls for all applications
 * Created: 2025-01-10
 */

/* ============================================================================
   GLASS MORPHISM FORM CARDS
   ============================================================================ */

.form-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--radius-2xl);
    box-shadow:
        0 8px 32px 0 rgba(31, 38, 135, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.18) inset;
    padding: clamp(2rem, 5vw, 3rem);
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.form-card:hover {
    box-shadow:
        0 12px 48px 0 rgba(31, 38, 135, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.25) inset;
    transform: translateY(-2px);
}

.form-card-sm {
    max-width: 440px;
}

.form-card-md {
    max-width: 600px;
}

.form-card-lg {
    max-width: 800px;
}

.form-card-xl {
    max-width: 1000px;
}

/* ============================================================================
   ENHANCED FORM GROUPS & LABELS
   ============================================================================ */

.form-group-enhanced {
    margin-bottom: var(--space-6);
    animation: fadeIn 0.6s ease both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-label-enhanced {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-heading);
    margin-bottom: var(--space-3);
    letter-spacing: 0.01em;
}

.form-label-required::after {
    content: '*';
    color: var(--color-error);
    margin-left: var(--space-1);
}

.form-help-text {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ============================================================================
   INPUT WRAPPERS WITH ICONS
   ============================================================================ */

.input-wrapper {
    position: relative;
}

.input-with-icon {
    padding-left: 3.25rem;
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 1.125rem;
    transition: all 0.3s ease;
    opacity: 0.7;
    pointer-events: none;
}

.form-control:focus ~ .input-icon {
    color: var(--color-primary);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.input-icon-right {
    left: auto;
    right: var(--space-4);
}

.input-with-icon-right {
    padding-right: 3.25rem;
    padding-left: var(--space-4);
}

/* ============================================================================
   ENHANCED FORM CONTROLS
   ============================================================================ */

.form-control-enhanced {
    width: 100%;
    padding: var(--space-4);
    font-size: var(--font-size-base);
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-text-heading);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-body);
}

.form-control-enhanced:hover {
    border-color: var(--color-border-hover);
    background: rgba(255, 255, 255, 0.95);
}

.form-control-enhanced:focus {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
    border-color: var(--color-border-focus);
    background: var(--color-white);
    box-shadow:
        0 0 0 4px rgba(var(--color-primary-green-rgb), 0.08),
        0 4px 12px rgba(var(--color-primary-green-rgb), 0.12);
    transform: translateY(-1px);
}

/* For mouse users, use subtler focus */
.form-control-enhanced:focus:not(:focus-visible) {
    outline: none;
}

/* For keyboard users, ensure visible focus ring */
.form-control-enhanced:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

.form-control-enhanced::placeholder {
    color: var(--color-text-muted);
    opacity: 0.8;
}

/* ============================================================================
   VALIDATION STATES
   ============================================================================ */

.form-group.has-error .form-control,
.form-group.has-error .form-control-enhanced {
    border-color: var(--color-error);
}

.form-group.has-error .form-control:focus,
.form-group.has-error .form-control-enhanced:focus {
    box-shadow:
        0 0 0 4px rgba(239, 68, 68, 0.1),
        0 4px 12px rgba(239, 68, 68, 0.15);
}

.form-group.has-success .form-control,
.form-group.has-success .form-control-enhanced {
    border-color: var(--color-success);
}

.form-group.has-success .form-control:focus,
.form-group.has-success .form-control-enhanced:focus {
    box-shadow:
        0 0 0 4px rgba(34, 197, 94, 0.1),
        0 4px 12px rgba(34, 197, 94, 0.15);
}

.form-group.has-warning .form-control,
.form-group.has-warning .form-control-enhanced {
    border-color: var(--color-warning);
}

.form-error-message {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-error);
}

.form-success-message {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-success);
}

/* ============================================================================
   INLINE VALIDATION FEEDBACK
   Real-time validation messages below form fields
   ============================================================================ */

/* Error feedback - shown below invalid fields */
.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-error);
    font-weight: var(--font-weight-medium);
    animation: fadeInSlide 0.2s ease-out;
}

.invalid-feedback i {
    margin-right: var(--space-1);
}

/* Show feedback when field is invalid */
.is-invalid ~ .invalid-feedback,
.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback {
    display: block;
}

/* Valid feedback - shown below valid fields */
.valid-feedback {
    display: none;
    width: 100%;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-success);
    font-weight: var(--font-weight-medium);
    animation: fadeInSlide 0.2s ease-out;
}

.valid-feedback i {
    margin-right: var(--space-1);
}

/* Show valid feedback when field is valid */
.is-valid ~ .valid-feedback,
.was-validated .form-control:valid ~ .valid-feedback,
.was-validated .form-select:valid ~ .valid-feedback {
    display: block;
}

/* Fade in animation for feedback messages */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Invalid field styling */
.form-control.is-invalid,
.form-select.is-invalid,
.form-control-enhanced.is-invalid,
textarea.is-invalid,
input.is-invalid {
    border-color: var(--color-error) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23EF4444' viewBox='0 0 16 16'%3E%3Cpath d='M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z'/%3E%3Cpath d='M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
.form-control-enhanced.is-invalid:focus,
textarea.is-invalid:focus,
input.is-invalid:focus {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
    outline: 2px solid var(--color-error);
    outline-offset: 2px;
}

/* Valid field styling */
.form-control.is-valid,
.form-select.is-valid,
.form-control-enhanced.is-valid,
textarea.is-valid,
input.is-valid {
    border-color: var(--color-success) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2310B981' viewBox='0 0 16 16'%3E%3Cpath d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus,
.form-control-enhanced.is-valid:focus,
textarea.is-valid:focus,
input.is-valid:focus {
    border-color: var(--color-success) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
    outline: 2px solid var(--color-success);
    outline-offset: 2px;
}

/* Textarea validation - position icon differently */
textarea.is-invalid,
textarea.is-valid {
    background-position: top calc(0.375em + 0.1875rem) right calc(0.375em + 0.1875rem);
}

/* Select dropdown validation */
.form-select.is-invalid,
.form-select.is-valid {
    background-position: right calc(2.25em + 0.1875rem) center, right calc(0.375em + 0.1875rem) center;
}

/* Checkbox and radio validation */
.form-check-input.is-invalid {
    border-color: var(--color-error);
}

.form-check-input.is-invalid ~ .form-check-label {
    color: var(--color-error);
}

.form-check-input.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Radio group validation */
.form-check-group.is-invalid {
    padding: var(--space-3);
    border: 2px solid var(--color-error);
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.05);
}

/* Field group validation states */
.form-group.has-error .form-label,
.form-group.has-error .admin-form-label {
    color: var(--color-error);
}

.form-group.has-success .form-label,
.form-group.has-success .admin-form-label {
    color: var(--color-success);
}

/* Shake animation for invalid fields */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.form-control.shake,
.form-select.shake {
    animation: shake 0.4s ease-in-out;
}

/* ============================================================================
   SELECT DROPDOWNS
   ============================================================================ */

.form-select {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-10) var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
    font-family: var(--font-body);
    line-height: var(--line-height-normal);
    color: var(--color-text-heading);
    background-color: var(--color-surface-default);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    background-size: 16px 12px;
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base) var(--ease-out);
    cursor: pointer;
    appearance: none;
}

.form-select:focus {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-green-rgb), 0.1);
}

.form-select:focus:not(:focus-visible) {
    outline: none;
}

.form-select:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

.form-select:disabled {
    background-color: var(--color-surface-muted);
    cursor: not-allowed;
}

/* ============================================================================
   CUSTOM CHECKBOXES & RADIOS
   ============================================================================ */

.form-check-custom {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    cursor: pointer;
}

.form-check-input-custom {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-base);
    background-color: var(--color-white);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.2s ease;
}

.form-check-input-custom:hover {
    border-color: var(--color-border-hover);
}

.form-check-input-custom:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.form-check-input-custom:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 4px;
    height: 10px;
    border: solid var(--color-white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-check-input-custom:focus {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(var(--color-primary-green-rgb), 0.1);
}

.form-check-input-custom:focus:not(:focus-visible) {
    outline: none;
}

.form-check-input-custom:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* Radio buttons */
.form-check-input-custom[type="radio"] {
    border-radius: var(--radius-full);
}

.form-check-input-custom[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    background-color: var(--color-white);
    border-radius: var(--radius-full);
    border: none;
    transform: none;
}

.form-check-label-custom {
    cursor: pointer;
    user-select: none;
    color: var(--color-text-body);
    line-height: var(--line-height-relaxed);
}

/* ============================================================================
   FILE UPLOAD
   ============================================================================ */

.file-upload-wrapper {
    position: relative;
}

.file-upload-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    border: 2px dashed var(--color-border-default);
    border-radius: var(--radius-lg);
    background-color: var(--color-surface-subtle);
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload-label:hover {
    border-color: var(--color-primary);
    background-color: rgba(var(--color-primary-green-rgb), 0.05);
}

.file-upload-icon {
    font-size: 3rem;
    color: var(--color-primary);
    margin-bottom: var(--space-4);
}

.file-upload-text {
    font-size: var(--font-size-base);
    color: var(--color-text-body);
    margin-bottom: var(--space-2);
}

.file-upload-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ============================================================================
   SEARCH & FILTER FORMS
   ============================================================================ */

.search-form {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.search-input {
    flex: 1;
    padding: var(--space-3) var(--space-4) var(--space-3) 3rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath fill-rule='evenodd' d='M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left var(--space-3) center;
    background-size: 20px 20px;
}

.filter-group {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}

.filter-button {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    border: 2px solid var(--color-border-default);
    border-radius: var(--radius-full);
    background: var(--color-white);
    color: var(--color-text-body);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-button:hover {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-green-rgb), 0.05);
}

.filter-button.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: var(--color-white);
}

/* ============================================================================
   MULTI-STEP FORM INDICATORS
   ============================================================================ */

.form-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-8);
    position: relative;
    flex-wrap: wrap; /* Allow wrapping on narrow screens */
    gap: var(--space-4);
}

.form-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-border-default);
    z-index: 0;
}

.form-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    position: relative;
    z-index: 1;
}

.form-step-number {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-white);
    border: 2px solid var(--color-border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    transition: all 0.3s ease;
}

.form-step.active .form-step-number {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
    box-shadow: 0 0 0 4px rgba(var(--color-primary-green-rgb), 0.1);
}

.form-step.completed .form-step-number {
    background: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-white);
}

.form-step-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    text-align: center;
}

.form-step.active .form-step-label {
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
}

/* ============================================================================
   TRACKER - ALTERNATIVE MULTI-STEP FORM INDICATOR
   Used by: child_enquiry.php, educator_enquiry.php, general_enquiry.php
   ============================================================================ */

.tracker {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 0;
}

/* Background line (gray) */
.tracker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 3px;
    background: #ddd;
    z-index: 0;
    transform: translateY(-50%);
}

/* Progress line (teal) - fills as you progress */
.tracker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    height: 3px;
    background: #20c997; /* Teal - agency color */
    z-index: 1;
    transform: translateY(-50%);
    transition: width 0.3s ease;
    width: 0%; /* Will be updated by JavaScript */
}

.tracker-step {
    text-align: center;
    flex: 1;
    position: relative;
    z-index: 2; /* Bullets above lines */
}

.tracker-step .bullet {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #ddd;
    color: white;
    font-weight: bold;
    font-size: 16px;
    margin: 0 auto;
    transition: background-color 0.3s ease;
    border: 3px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tracker-step.active .bullet {
    background: #0dcaf0; /* Cyan - agency color */
}

.tracker-step.completed .bullet {
    background: #20c997; /* Teal - agency color */
}

/* ============================================================================
   INLINE FORMS
   ============================================================================ */

.form-inline {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
}

/* ============================================================================
   FORM ACTIONS
   ============================================================================ */

.form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border-default);
}

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

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

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

/* ============================================================================
   AUTHENTICATION FORMS
   ============================================================================ */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.auth-logo {
    width: 100%;
    max-width: 300px;
    height: auto;
    margin: 0 auto var(--space-8);
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.08));
    animation: fadeInDown 0.6s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-title {
    text-align: center;
    font-size: clamp(1.5rem, 4vw, 1.875rem);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-heading);
    margin-bottom: var(--space-8);
    letter-spacing: -0.02em;
    animation: fadeIn 0.6s ease 0.2s both;
}

.auth-subtitle {
    text-align: center;
    font-size: var(--font-size-base);
    color: var(--color-text-muted);
    margin-bottom: var(--space-6);
}

.auth-links {
    text-align: center;
    margin-top: var(--space-6);
}

.auth-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: color 0.2s ease;
}

.auth-link:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.remember-me {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

/* ============================================================================
   BULK ACTIONS (for CMS)
   ============================================================================ */

.bulk-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-4);
    background: var(--color-surface-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}

.bulk-actions-select {
    min-width: 200px;
}

.bulk-actions-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ============================================================================
   ADMIN FORM ELEMENTS - MODERN DESIGN
   ============================================================================ */

/* Admin Form Groups */
.admin-form-group {
    margin-bottom: var(--space-5);
}

.admin-form-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-3);
    letter-spacing: 0.01em;
}

.admin-form-label i {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Admin Form Inputs - Modern Floating Effect */
.admin-form-input,
.admin-form-select {
    width: 100%;
    padding: var(--space-4);
    font-size: var(--font-size-base);
    font-family: var(--font-body);
    color: var(--color-text-primary);
    background: var(--color-bg-primary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.admin-form-input:hover,
.admin-form-select:hover {
    border-color: var(--color-purple-light);
    background: var(--color-bg-secondary);
}

.admin-form-input:focus,
.admin-form-select:focus {
    outline: 2px solid var(--color-purple);
    outline-offset: 2px;
    border-color: var(--color-purple);
    background: var(--color-bg-primary);
    box-shadow:
        0 0 0 4px rgba(139, 92, 246, 0.1),
        0 4px 12px rgba(139, 92, 246, 0.15);
}

.admin-form-input:focus:not(:focus-visible),
.admin-form-select:focus:not(:focus-visible) {
    outline: none;
}

.admin-form-input:focus-visible,
.admin-form-select:focus-visible {
    outline: 2px solid var(--color-purple);
    outline-offset: 2px;
    transform: translateY(-1px);
}

.admin-form-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

/* Textarea specific */
.admin-form-input[type="textarea"],
textarea.admin-form-input {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* Select dropdown with modern arrow */
.admin-form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B5CF6' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    background-size: 16px 12px;
    padding-right: var(--space-10);
    cursor: pointer;
}

/* Admin Form Help Text */
.admin-form-help {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-style: italic;
}

/* Admin Form Row - Side by side inputs */
.admin-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

/* Admin Form Divider */
.admin-form-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-8) 0 var(--space-6);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-form-divider::before,
.admin-form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-border) 50%, transparent);
}

/* Admin Form Actions */
.admin-form-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 2px solid var(--color-border);
}

/* ============================================================================
   MODERN BUTTON STYLES
   ============================================================================ */

/* Base Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-body);
    line-height: 1;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
}

/* Admin Primary Button - Purple */
.btn-admin-primary {
    background: linear-gradient(135deg, var(--color-purple) 0%, #7C3AED 100%);
    color: white;
    border-color: var(--color-purple);
    box-shadow:
        0 2px 4px rgba(139, 92, 246, 0.2),
        0 4px 12px rgba(139, 92, 246, 0.15);
}

.btn-admin-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-admin-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    border-color: #7C3AED;
    box-shadow:
        0 4px 8px rgba(139, 92, 246, 0.3),
        0 8px 24px rgba(139, 92, 246, 0.25);
    transform: translateY(-2px);
}

.btn-admin-primary:hover::before {
    opacity: 1;
}

.btn-admin-primary:active:not(:disabled) {
    box-shadow:
        0 1px 2px rgba(139, 92, 246, 0.2),
        inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Admin Secondary Button - Gray */
.btn-admin-secondary {
    background: #F3F4F6; /* Gray-100 - visible gray background */
    color: #1F2937; /* Gray-800 - dark text */
    border: 2px solid #D1D5DB; /* Gray-300 - visible border */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-admin-secondary:hover:not(:disabled) {
    background: #E5E7EB; /* Gray-200 - darker on hover */
    border-color: #9CA3AF; /* Gray-400 - darker border */
    color: #111827; /* Gray-900 - darker text */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* Success Button - Green */
.btn-success {
    background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%);
    color: white;
    border-color: var(--color-success);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
    transform: translateY(-2px);
}

/* Danger Button - Red */
.btn-danger {
    background: linear-gradient(135deg, var(--color-error) 0%, #DC2626 100%);
    color: white;
    border-color: var(--color-error);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

/* Warning Button - Yellow */
.btn-warning {
    background: linear-gradient(135deg, var(--color-warning) 0%, #F59E0B 100%);
    color: #78350F;
    border-color: var(--color-warning);
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
    transform: translateY(-2px);
}

/* Info Button - Blue */
.btn-info {
    background: linear-gradient(135deg, var(--color-blue) 0%, #2563EB 100%);
    color: white;
    border-color: var(--color-blue);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-info:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

/* Outline Buttons */
.btn-outline-primary {
    background: transparent;
    color: var(--color-purple);
    border-color: var(--color-purple);
}

.btn-outline-primary:hover:not(:disabled) {
    background: var(--color-purple);
    color: white;
}

.btn-outline-secondary {
    background: transparent;
    color: #374151; /* Gray-700 - dark readable text */
    border: 2px solid #D1D5DB; /* Gray-300 - visible border */
}

.btn-outline-secondary:hover:not(:disabled) {
    background: #F3F4F6; /* Gray-100 - light gray fill on hover */
    border-color: #9CA3AF; /* Gray-400 - darker border */
    color: #111827; /* Gray-900 - darker text */
}

/* Ghost Buttons */
.btn-ghost {
    background: transparent;
    color: #374151; /* Gray-700 - visible text */
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: #F3F4F6; /* Gray-100 - visible on hover */
    color: #111827; /* Gray-900 - darker text */
}

/* Button Loading State */
.btn.loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-right-color: transparent;
    animation: buttonSpinner 0.6s linear infinite;
    color: white;
}

.btn-admin-secondary.loading::after,
.btn-outline-primary.loading::after,
.btn-ghost.loading::after {
    color: var(--color-text-primary);
}

@keyframes buttonSpinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button Icon */
.btn i {
    font-size: 1.125em;
}

/* Safety rule: Ensure buttons without specific color classes have visible styling */
.btn:not([class*="btn-admin"]):not([class*="btn-success"]):not([class*="btn-danger"]):not([class*="btn-warning"]):not([class*="btn-info"]):not([class*="btn-outline"]):not([class*="btn-ghost"]) {
    background: #F3F4F6; /* Gray-100 */
    color: #1F2937; /* Gray-800 */
    border-color: #D1D5DB; /* Gray-300 */
}

.btn:not([class*="btn-admin"]):not([class*="btn-success"]):not([class*="btn-danger"]):not([class*="btn-warning"]):not([class*="btn-info"]):not([class*="btn-outline"]):not([class*="btn-ghost"]):hover:not(:disabled) {
    background: #E5E7EB; /* Gray-200 */
    border-color: #9CA3AF; /* Gray-400 */
    color: #111827; /* Gray-900 */
}

/* Button Group */
.btn-group {
    display: inline-flex;
    gap: var(--space-2);
}

.btn-group .btn {
    margin: 0;
}

/* Full Width Button */
.btn-block {
    width: 100%;
    justify-content: center;
}

/* ============================================================================
   ALERT & MESSAGE STYLES
   ============================================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    border: 2px solid;
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.alert i {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--color-blue);
    color: #1E40AF;
}

.alert-info i {
    color: var(--color-blue);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--color-success);
    color: #065F46;
}

.alert-success i {
    color: var(--color-success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--color-warning);
    color: #78350F;
}

.alert-warning i {
    color: var(--color-warning);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-error);
    color: #991B1B;
}

.alert-error i {
    color: var(--color-error);
}

/* ============================================================================
   INPUT STATES & ICONS
   ============================================================================ */

/* Disabled State */
.admin-form-input:disabled,
.admin-form-select:disabled {
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Read-only State */
.admin-form-input:read-only {
    background: var(--color-bg-secondary);
    border-style: dashed;
}

/* Error State */
.admin-form-input.error,
.admin-form-select.error {
    border-color: var(--color-error);
}

.admin-form-input.error:focus,
.admin-form-select.error:focus {
    box-shadow:
        0 0 0 4px rgba(239, 68, 68, 0.1),
        0 4px 12px rgba(239, 68, 68, 0.15);
}

/* Success State */
.admin-form-input.success,
.admin-form-select.success {
    border-color: var(--color-success);
}

.admin-form-input.success:focus,
.admin-form-select.success:focus {
    box-shadow:
        0 0 0 4px rgba(16, 185, 129, 0.1),
        0 4px 12px rgba(16, 185, 129, 0.15);
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .admin-form-row {
        grid-template-columns: 1fr;
    }

    .admin-form-actions {
        flex-direction: column-reverse;
    }

    .admin-form-actions .btn {
        width: 100%;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Form step tracker responsive adjustments */
    .form-step-number {
        width: 32px;
        height: 32px;
        font-size: var(--font-size-sm);
    }

    .form-steps::before {
        top: 16px;
    }

    .form-step-label {
        font-size: var(--font-size-xs);
    }
}

@media (max-width: 640px) {
    .form-card {
        padding: var(--space-6);
    }

    .form-inline {
        flex-direction: column;
    }

    .form-inline .form-group {
        width: 100%;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }

    .search-form {
        flex-direction: column;
    }

    .filter-group {
        flex-direction: column;
    }

    .filter-button {
        width: 100%;
        justify-content: center;
    }

    /* Smaller form step bullets for mobile */
    .form-step-number {
        width: 28px;
        height: 28px;
        font-size: var(--font-size-xs);
    }

    .form-steps::before {
        top: 14px;
    }

    .form-step-label {
        font-size: 0.625rem; /* 10px - extra small for mobile */
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .form-steps {
        gap: var(--space-2);
        margin-bottom: var(--space-6);
    }
}

@media (max-width: 480px) {
    /* Extra small devices - scale down bullets */
    .form-step-number {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .form-steps::before {
        top: 14px;
        height: 2px;
    }

    .form-step-label {
        font-size: 0.625rem; /* 10px */
    }

    .form-steps {
        margin-bottom: var(--space-5);
    }

    .form-step {
        gap: var(--space-1);
    }

    /* Tracker responsive adjustments */
    .tracker::before {
        height: 2px;
    }

    .tracker::after {
        height: 2px;
    }

    .tracker-step .bullet {
        width: 32px;
        height: 32px;
        font-size: 13px;
        border-width: 2px;
    }
}

@media (max-width: 400px) {
    /* Very narrow screens - smaller bullets */
    .form-step-number {
        width: 24px;
        height: 24px;
        font-size: 0.625rem;
    }

    .form-steps::before {
        top: 12px;
        height: 1.5px;
    }

    .form-step-label {
        font-size: 0.5625rem; /* 9px */
    }

    /* Tracker - smaller */
    .tracker-step .bullet {
        width: 28px;
        height: 28px;
        font-size: 12px;
        border-width: 2px;
    }
}

@media (max-width: 360px) {
    /* Ultra-narrow screens - minimal size */
    .form-step-number {
        width: 20px;
        height: 20px;
        font-size: 0.5625rem; /* 9px */
    }

    .form-steps::before {
        top: 10px;
        height: 1px;
    }

    .form-step-label {
        font-size: 0.5rem; /* 8px */
    }

    /* Tracker - minimal size */
    .tracker-step .bullet {
        width: 24px;
        height: 24px;
        font-size: 11px;
        border-width: 1.5px;
    }

    .tracker::before,
    .tracker::after {
        height: 2px;
    }
}
