/**
 * Form Components Extension - Bootstrap 5 Premium Styling
 */

 /* =============================================================================
    CARD STYLING - Form-specific cards
    ============================================================================= */

.form-card,
.modal .card {
    background-color: #ffffff !important;
    border: 1px solid #e5e7eb !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

 /* =============================================================================
    BADGE STYLING - Ensure text is visible
    ============================================================================= */

.form-card .badge,
.modal .badge,
.tpgc-form-container .badge {
    color: #212529 !important;
    background-color: #f8f9fa !important;
}

.form-card .badge.text-bg-light,
.modal .badge.text-bg-light,
.tpgc-form-container .badge.text-bg-light {
    color: #212529 !important;
    background-color: #e9ecef !important;
    border-color: #dee2e6 !important;
}

.form-card .badge.rounded-pill,
.modal .badge.rounded-pill,
.tpgc-form-container .badge.rounded-pill {
    padding-left: 0.75em !important;
    padding-right: 0.75em !important;
}

 /* =============================================================================
    MODAL SCROLLABLE - Make modals scrollable when content is long
    ============================================================================= */

.modal-dialog {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    margin: 1.75rem auto;
}

.modal-dialog-scrollable .modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Fix Bootstrap modal backdrop blur issue - CONSOLIDATED */
.modal-backdrop {
    backdrop-filter: blur(3px) !important;
    -webkit-backdrop-filter: blur(3px) !important;
    background-color: rgba(15, 23, 42, 0.28) !important;
    opacity: 1 !important;
}

[data-bs-theme="dark"] .modal-backdrop {
    background-color: rgba(2, 6, 23, 0.42) !important;
}

/* Ensure modals have proper z-index - SCOPED */
.modal .dropdown-menu {
    z-index: 2050;
}

.modal-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Modal responsive fixes - keep scrolling and footer visible */
.modal-body {
    overflow-x: auto;
    overflow-y: auto;
}

/* Ensure modal footer is always visible */
.modal-footer {
    flex-shrink: 0;
    background-color: #fff;
}

.modal-header {
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .modal-dialog {
        padding: 0.5rem;
    }

    .modal-body {
        overflow-y: auto;
    }

    .modal-body .row > div {
        margin-bottom: 0.5rem;
    }
}

/* Use Bootstrap default form styles - NOW IN forms.css */

/* Form controls - use body background color - NOW IN forms.css */
/* Base form styles moved to: static/css/forms.css */

/* Table cell form controls - full width with proper spacing */
.table td .form-control,
.table td .form-select {
    width: 100%;
    min-width: 100%;
}

.table td .d-flex.flex-column.gap-2 > div {
    width: 100%;
}

.table td .d-flex.flex-column.gap-2 > div + div {
    margin-top: 0.25rem;
}

/* =============================================================================
    SEARCHABLE DROPDOWN - NOW IN searchable-select.css
    Legacy styles removed - see static/css/searchable-select.css
    ============================================================================= */

 /* =============================================================================
    PREMIUM TABLE STYLING
    ============================================================================= */

.table-premium-inner {
    font-size: 0.9rem;
    min-width: 600px;
    color: #495057;
}

.table-premium-inner thead th {
    background-color: #e9ecef;
    color: #495057;
    padding: 0.75rem 1rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    white-space: nowrap;
    border-bottom: 2px solid #dee2e6;
}

.table-premium-inner tbody td {
    color: #495057;
}

.table-premium-inner tbody tr:hover {
    background-color: #e9ecef;
}

 /* =============================================================================
    FORM LAYOUT
    ============================================================================= */

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row > .col,
.form-row > [class*="col-"] {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 0.5rem 0.5rem;
    margin-top: 1rem;
}

/* Responsive form */
@media (max-width: 767px) {
    .form-row {
        gap: 0.75rem;
    }

    .form-actions {
        flex-direction: column;
        padding: 0.75rem;
    }

    .form-actions .btn {
        width: 100%;
    }
}
