/* Create Transaction Form Styles */
.create-txn-form {
    max-width: 100%;
    padding: 0;
}

.create-txn-form .form-label {
    text-transform: none !important;
}

/* Form validation summary */
.create-txn-form .form-validation-summary {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: none;
}

.create-txn-form .form-validation-summary.show {
    display: block;
}

.create-txn-form .form-validation-summary h6 {
    color: #dc2626;
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.create-txn-form .form-validation-summary ul {
    margin: 0;
    padding-left: 1.25rem;
    list-style-type: disc;
}

.create-txn-form .form-validation-summary li {
    color: #dc2626;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.create-txn-form .form-group {
    margin-bottom: 1.5rem;
}

.create-txn-form .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
}

.create-txn-form .form-label.required::after {
    content: ' *';
    color: #ef4444;
    font-weight: bold;
}

.create-txn-form .form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    background-color: #ffffff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.create-txn-form .form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.create-txn-form .form-control:invalid {
    border-color: #ef4444;
}

.create-txn-form .form-control:invalid:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.create-txn-form .form-error {
    display: none;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #ef4444;
    font-weight: 500;
}

.create-txn-form .form-fields-group {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.create-txn-form .form-group-title {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.create-txn-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.create-txn-form .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.create-txn-form .btn-primary {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}

.create-txn-form .btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.create-txn-form .btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.create-txn-form .btn-secondary {
    background-color: #6b7280;
    border-color: #6b7280;
    color: #ffffff;
}

.create-txn-form .btn-secondary:hover {
    background-color: #4b5563;
    border-color: #4b5563;
}

.create-txn-form .btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.25);
}

.create-txn-form select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
}

.create-txn-form input[type="date"] {
    position: relative;
}

.create-txn-form input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3e%3c/svg%3e");
    background-size: 1.25rem;
    cursor: pointer;
}

/* Success message styles */
.create-txn-form .alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.create-txn-form .alert-success {
    color: #065f46;
    background-color: #d1fae5;
    border-color: #a7f3d0;
}

/* Modal adjustments for the form */
#create-txn-modal .modal-dialog {
    max-width: 700px;
    width: 90%;
}

#create-txn-modal .brand-modal-body {
    padding: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .create-txn-form .form-actions {
        flex-direction: column;
    }

    .create-txn-form .btn {
        width: 100%;
        justify-content: center;
    }

    #create-txn-modal .modal-dialog {
        max-width: 95%;
        margin: 1rem;
        width: auto;
    }
}

/* Create Transaction Form - Mobile Responsive Styles */

/* ===== DESKTOP STYLES (Default) ===== */
.create-txn-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--bg-primary, #ffffff);
    border-radius: var(--container-border-radius, 20px);
    box-shadow: var(--box-shadow, 0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Form validation summary */
.form-validation-summary {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border-left: 4px solid #ff4757;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.form-validation-summary.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.form-validation-summary h6 {
    margin: 0 0 0.75rem 0;
    font-weight: 600;
    font-size: 1rem;
}

.form-validation-summary ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.form-validation-summary li {
    margin-bottom: 0.5rem;
    padding-left: 1.25rem;
    position: relative;
    font-size: 0.875rem;
}

.form-validation-summary li:before {
    content: '•';
    position: absolute;
    left: 0;
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
}

.form-validation-summary li:last-child {
    margin-bottom: 0;
}

/* Form groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark, #21243D);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-label.required:after {
    content: ' *';
    color: #ff4757;
    font-weight: bold;
}

/* Form field groups */
.form-fields-group {
    background: var(--bg-secondary, #fafbfd);
    border: 1px solid var(--border-light, rgba(45, 91, 229, 0.08));
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.form-fields-group:hover {
    border-color: var(--border-medium, rgba(45, 91, 229, 0.15));
    box-shadow: 0 2px 8px rgba(45, 91, 229, 0.1);
}

.form-group-title {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--brand-blue, #2D5BE5);
    border-bottom: 2px solid var(--brand-blue, #2D5BE5);
    padding-bottom: 0.5rem;
}

/* Form controls */
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-medium, rgba(45, 91, 229, 0.15));
    border-radius: 8px;
    background: var(--bg-primary, #ffffff);
    color: var(--text-dark, #21243D);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 44px; /* Touch-friendly minimum */
}

.form-control:focus {
    border-color: var(--brand-blue, #2D5BE5);
    box-shadow: 0 0 0 3px rgba(45, 91, 229, 0.15);
    outline: none;
}

.form-control:disabled {
    background-color: var(--neutral-gray-light, #F5F7FA);
    color: var(--text-muted, #6c757d);
    cursor: not-allowed;
}

/* Form select styling */
.form-control select,
select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* AutoNumeric input styling */
.auto-numeric {
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

/* Datepicker styling */
.datepicker {
    cursor: pointer;
}

.datepicker:read-only {
    background-color: var(--bg-primary, #ffffff);
    cursor: pointer;
}

/* Form error styling */
.form-error {
    display: none;
    color: #ff4757;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

.form-error.show {
    display: block;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light, rgba(45, 91, 229, 0.08));
}

.form-actions .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    min-height: 44px; /* Touch-friendly */
    min-width: 120px;
}

.form-actions .btn-secondary {
    background: var(--neutral-gray, #E7E6EB);
    color: var(--text-dark, #21243D);
    border: 1px solid var(--border-medium, rgba(45, 91, 229, 0.15));
}

.form-actions .btn-secondary:hover {
    background: var(--neutral-gray-dark, #C5C4C9);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.form-actions .btn-primary {
    background: var(--brand-gradient, linear-gradient(135deg, #2D5BE5 0%, #1E46C2 100%));
    color: white;
    box-shadow: 0 4px 12px rgba(45, 91, 229, 0.3);
}

.form-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(45, 91, 229, 0.4);
}

/* Success/Error alert styling */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: linear-gradient(135deg, #2ed573 0%, #26d65c 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(46, 213, 115, 0.3);
}

.alert-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

/* ===== MOBILE STYLES (576px and below) ===== */
@media (max-width: 576px) {
    /* Form container - full screen on mobile */
    .create-txn-form {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 1rem;
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Validation summary adjustments */
    .form-validation-summary {
        padding: 0.875rem 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }

    .form-validation-summary h6 {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
    }

    .form-validation-summary li {
        font-size: 0.8125rem;
        margin-bottom: 0.375rem;
    }

    /* Form groups - reduced spacing */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-label {
        font-size: 0.8125rem;
        margin-bottom: 0.375rem;
        letter-spacing: 0.3px;
    }

    /* Form field groups - mobile optimized */
    .form-fields-group {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }

    .form-group-title {
        font-size: 1rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.375rem;
    }

    /* Form controls - mobile optimized */
    .form-control {
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 48px; /* Larger touch target */
        border-radius: 8px;
        -webkit-appearance: none; /* Remove iOS styling */
    }

    /* Select dropdown - mobile optimized */
    .form-control select,
    select.form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 48px;
        padding-right: 3rem; /* More space for dropdown arrow */
    }

    /* AutoNumeric - mobile specific */
    .auto-numeric {
        font-size: 18px; /* Larger for better readability */
        font-weight: 600;
        text-align: left;
    }

    /* Datepicker - mobile optimized */
    .datepicker {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 48px;
    }

    /* Form actions - stack vertically on mobile */
    .form-actions {
        flex-direction: column-reverse; /* Primary button on top */
        gap: 0.75rem;
        margin-top: 1.5rem;
        padding-top: 1rem;
        position: sticky;
        bottom: 0;
        background: var(--bg-primary, #ffffff);
        border-top: 2px solid var(--border-light, rgba(45, 91, 229, 0.08));
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
        padding-bottom: 1rem;
        z-index: 100;
    }

    .form-actions .btn {
        width: 100%;
        min-height: 48px; /* Larger touch target */
        font-size: 16px;
        padding: 0.875rem 1rem;
        font-weight: 600;
    }

    /* Alert styling - mobile */
    .alert {
        padding: 0.875rem 1rem;
        border-radius: 8px;
        margin-bottom: 0.75rem;
        font-size: 0.875rem;
    }

    /* Improved focus states for mobile */
    .form-control:focus {
        box-shadow: 0 0 0 3px rgba(45, 91, 229, 0.25);
        border-color: var(--brand-blue, #2D5BE5);
        outline: 2px solid transparent;
    }

    /* Touch feedback for buttons */
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    /* Hide form field group hover effects on mobile */
    .form-fields-group:hover {
        border-color: var(--border-light, rgba(45, 91, 229, 0.08));
        box-shadow: none;
    }
}

/* ===== SMALL MOBILE STYLES (480px and below) ===== */
@media (max-width: 480px) {
    .create-txn-form {
        padding: 0.75rem;
    }

    .form-fields-group {
        padding: 0.75rem;
    }

    .form-control {
        padding: 0.75rem;
        font-size: 16px;
    }

    .form-group-title {
        font-size: 0.9375rem;
    }

    .form-actions {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
    }
}

/* ===== LANDSCAPE MOBILE ORIENTATION ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .create-txn-form {
        padding: 0.75rem;
        min-height: auto;
    }

    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-fields-group {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .form-actions {
        position: relative; /* Remove sticky positioning in landscape */
        margin-top: 1rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .form-group-title {
        margin-bottom: 0.5rem;
        padding-bottom: 0.25rem;
    }
}

/* ===== HIGH CONTRAST MODE SUPPORT ===== */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 2px;
    }

    .form-control:focus {
        border-width: 3px;
        box-shadow: none;
    }

    .btn {
        border-width: 2px;
    }
}

/* ===== REDUCED MOTION SUPPORT ===== */
@media (prefers-reduced-motion: reduce) {
    .form-validation-summary,
    .form-control,
    .btn,
    .form-fields-group {
        transition: none;
    }

    .btn:active {
        transform: none;
    }
}

/* ===== CUSTOM DATEPICKER STYLES FOR MOBILE ===== */
@media (max-width: 576px) {
    .flatpickr-calendar {
        font-size: 16px; /* Prevent zoom on iOS */
        max-width: 100vw;
        width: 100vw;
    }

    .flatpickr-day {
        height: 44px; /* Touch-friendly */
        line-height: 44px;
        width: 44px;
        font-size: 14px;
    }

    .flatpickr-current-month {
        font-size: 16px;
        padding: 8px 0;
    }

    .flatpickr-weekday {
        font-size: 12px;
        font-weight: 600;
        padding: 8px 0;
    }

    .flatpickr-months .flatpickr-month {
        height: 44px;
    }

    .flatpickr-prev-month,
    .flatpickr-next-month {
        width: 44px;
        height: 44px;
        line-height: 44px;
    }
}

/* ===== AUTONUMERIC MOBILE OPTIMIZATIONS ===== */
@media (max-width: 576px) {
    /* Ensure AutoNumeric inputs are properly styled on mobile */
    .auto-numeric:focus {
        font-size: 18px; /* Larger text when focused for better visibility */
        font-weight: 600;
    }

    /* Prevent text selection issues on mobile */
    .auto-numeric {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
        -webkit-touch-callout: default;
    }
}

/* ===== MODAL FORM SPECIFIC STYLES ===== */
.modal .create-txn-form {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    max-width: none;
    width: 100%;
    margin: 0;
}

@media (max-width: 576px) {
    .modal .create-txn-form {
        min-height: auto;
    }

    .modal .form-actions {
        position: relative; /* Don't stick in modal */
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }
}
