/* Production-Ready Modal Styles */

.modal-overlay {
    display: none;
    position: fixed;
    z-index: 9998;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease-in-out;
}

.modal-overlay.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.data-modal {
    position: fixed;
    z-index: 9999;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background-color: var(--card-bg);
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--card-shadow);
    max-width: 90%;
    width: 100%;
    max-height: 90vh;
    display: none;
    flex-direction: column;
    animation: slideIn 0.3s ease-in-out;
    border: 1px solid var(--border-color);
}

.data-modal.show {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
}

@keyframes slideIn {
    from {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .data-modal {
        max-width: 95%;
        left: 50%;
        top: 50%;
        max-height: 95vh;
    }
}

/* Modal Header */
.data-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    border-radius: 12px 12px 0 0;
}

.data-modal-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.data-modal-header h5 i {
    margin-right: 0.75rem;
    font-size: 1.5rem;
}

.data-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #fff;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.data-modal-close:hover {
    opacity: 1;
}

/* Modal Body */
.data-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    color: var(--primary-text);
    min-height: 0;
    max-height: 100%;
}

/* Ensure scrollbar doesn't cause layout shift */
.data-modal-body::-webkit-scrollbar {
    width: 8px;
}

.data-modal-body::-webkit-scrollbar-track {
    background: var(--secondary-bg);
    border-radius: 4px;
}

.data-modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.data-modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Modal Footer */
.data-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    border-radius: 0 0 12px 12px;
    flex-wrap: wrap;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    flex-direction: column;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1rem;
    color: var(--primary-text);
    font-weight: 500;
}

/* Completion State */
.completion-state {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    min-height: 200px;
    text-align: center;
}

.completion-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.completion-icon.success {
    color: #2ecc71;
}

.completion-icon.error {
    color: #e74c3c;
}

.completion-message {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-text);
}

.completion-details {
    font-size: 0.9rem;
    color: var(--primary-text);
    opacity: 0.8;
    margin-bottom: 1rem;
}

/* Data Table in Modal */
.modal-data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.modal-data-table thead {
    background-color: var(--secondary-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    color: var(--primary-text);
}

.modal-data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-text);
}

.modal-data-table tbody tr:hover {
    background-color: var(--secondary-bg);
}

/* Export Buttons */
.export-button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.btn-export-excel {
    background-color: #27ae60;
    color: #fff;
}

.btn-export-excel:hover {
    background-color: #229954;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

.btn-export-pdf {
    background-color: #e74c3c;
    color: #fff;
}

.btn-export-pdf:hover {
    background-color: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-export-csv {
    background-color: #3498db;
    color: #fff;
}

.btn-export-csv:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Drill-down Details */
.drill-down-section {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: var(--secondary-bg);
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.drill-down-section h6 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: #3498db;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.drill-down-section h6 i {
    margin-right: 0.5rem;
}

.drill-down-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.drill-down-item:last-child {
    border-bottom: none;
}

.drill-down-label {
    font-weight: 600;
    color: var(--primary-text);
}

.drill-down-value {
    color: var(--primary-text);
    opacity: 0.85;
}

/* Responsive Design */
@media (max-width: 576px) {
    .data-modal {
        max-width: 98%;
        max-height: 98vh;
    }

    .data-modal-header,
    .data-modal-body,
    .data-modal-footer {
        padding: 1rem;
    }

    .data-modal-header h5 {
        font-size: 1rem;
    }

    .export-button-group {
        gap: 0.25rem;
    }

    .btn-export {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Status Badges in Modal */
.status-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.success {
    background-color: rgba(46, 204, 113, 0.2);
    color: #27ae60;
}

.status-badge.pending {
    background-color: rgba(241, 196, 15, 0.2);
    color: #f39c12;
}

.status-badge.error {
    background-color: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.status-badge.info {
    background-color: rgba(52, 152, 219, 0.2);
    color: #3498db;
}

/* Animation for modal transitions */
@media (prefers-reduced-motion: no-preference) {
    .data-modal,
    .modal-overlay {
        transition: all 0.3s ease-in-out;
    }
}
