/* ========================================
   MODAL SYSTEM - Global Styling
   ======================================== */

/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

/* Modal Container */
.modal-container {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 30px;
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-container.modal-sm {
    width: 400px;
}

.modal-container.modal-lg {
    width: 800px;
}

/* Modal Header */
.modal-header {
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
}

/* Modal Body */
.modal-body {
    margin-bottom: 20px;
}

/* Form Groups in Modals */
.modal-body .form-group {
    margin-bottom: 15px;
}

.modal-body label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #e5e7eb;
}

.modal-body label .required {
    color: #ef4444;
    margin-left: 2px;
}

/* Input Fields in Modals */
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body input[type="month"],
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.modal-body input[type="text"]:focus,
.modal-body input[type="number"]:focus,
.modal-body input[type="date"]:focus,
.modal-body input[type="email"]:focus,
.modal-body input[type="password"]:focus,
.modal-body input[type="month"]:focus,
.modal-body textarea:focus,
.modal-body select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

.modal-body input::placeholder,
.modal-body textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Select Dropdowns - High Contrast Fix */
.modal-body select {
    cursor: pointer;
    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='%23ffffff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.modal-body select option {
    background: #1e293b !important;
    color: #fff !important;
    padding: 10px;
}

/* Force dark background on all select dropdowns globally */
select option {
    background-color: #1e293b !important;
    color: #ffffff !important;
}

select optgroup {
    background-color: #0f172a !important;
    color: #ffffff !important;
}

/* Invoice Selection Area (for payment modals) */
.invoice-selection-area {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.invoice-option {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.invoice-option:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.invoice-option.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Modal Footer */
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-footer .btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #d1d5db;
}

.modal-footer .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Scrollbar Styling for Modals */
.modal-container::-webkit-scrollbar,
.invoice-selection-area::-webkit-scrollbar {
    width: 8px;
}

.modal-container::-webkit-scrollbar-track,
.invoice-selection-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.modal-container::-webkit-scrollbar-thumb,
.invoice-selection-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.modal-container::-webkit-scrollbar-thumb:hover,
.invoice-selection-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Helper Text */
.modal-body .help-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

/* Error State */
.modal-body input.error,
.modal-body select.error {
    border-color: #ef4444;
}

.modal-body .error-message {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 4px;
}