/**
 * Modal Components CSS
 * Bootstrap 5 modal styling and customizations
 */

/* Modal backdrop customization */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

/* Modal content styling */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Modal header styling */
.modal-header {
    border-bottom: 1px solid var(--bs-border-color);
    padding: 1rem 1.5rem;
    background-color: var(--bs-light);
}

.modal-title {
    font-weight: 600;
    color: var(--bs-dark);
}

/* Modal body styling */
.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* Modal footer styling */
.modal-footer {
    border-top: 1px solid var(--bs-border-color);
    padding: 1rem 1.5rem;
    background-color: var(--bs-light);
}

/* Close button styling */
.btn-close {
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
}

/* Modal size variations */
.modal-sm .modal-dialog {
    max-width: 300px;
}

.modal-lg .modal-dialog {
    max-width: 800px;
}

.modal-xl .modal-dialog {
    max-width: 1140px;
}

/* Full screen modal */
.modal-fullscreen .modal-dialog {
    width: 100vw;
    max-width: none;
    height: 100vh;
    margin: 0;
}

.modal-fullscreen .modal-content {
    height: 100vh;
    border: 0;
    border-radius: 0;
}

/* Scrollable modal body */
.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 2rem);
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}

/* Centered modal */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100vh - 2rem);
}

/* Loading modal styling */
.modal-loading .modal-body {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Search modal specific styling */
.modal-search .modal-header {
    padding: 0.5rem 1rem;
}

.modal-search .modal-header input {
    border: none;
    background: transparent;
    font-size: 1.1rem;
    padding: 0.5rem 0;
}

.modal-search .modal-header input:focus {
    outline: none;
    box-shadow: none;
}

/* Form modal styling */
.modal-form .form-group {
    margin-bottom: 1rem;
}

.modal-form .form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Confirmation modal styling */
.modal-confirmation .modal-body {
    text-align: center;
    padding: 2rem;
}

.modal-confirmation .modal-body .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-confirmation .modal-body .icon.warning {
    color: var(--bs-warning);
}

.modal-confirmation .modal-body .icon.danger {
    color: var(--bs-danger);
}

.modal-confirmation .modal-body .icon.success {
    color: var(--bs-success);
}

.modal-confirmation .modal-body .icon.info {
    color: var(--bs-info);
}

/* Stats modal specific styling */
.modal-stats .chart-container {
    position: relative;
    height: 400px;
    margin: 1rem 0;
}

.modal-stats .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.modal-stats .stat-card {
    background: var(--bs-light);
    padding: 1rem;
    border-radius: 0.375rem;
    text-align: center;
}

.modal-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--bs-primary);
}

.modal-stats .stat-label {
    font-size: 0.875rem;
    color: var(--bs-secondary);
    margin-top: 0.25rem;
}

/* Device form modal styling */
.modal-device-form .form-floating {
    margin-bottom: 1rem;
}

.modal-device-form .quill-editor {
    height: 150px;
    margin-bottom: 1rem;
}

/* Export modal styling */
.modal-export .export-summary {
    background: var(--bs-light);
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.modal-export .export-summary .summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.modal-export .export-summary .summary-item:last-child {
    margin-bottom: 0;
}

.modal-export .export-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Responsive modal adjustments */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-fullscreen-sm-down .modal-dialog {
        width: 100vw;
        max-width: none;
        height: 100vh;
        margin: 0;
    }
    
    .modal-fullscreen-sm-down .modal-content {
        height: 100vh;
        border: 0;
        border-radius: 0;
    }
}

/* Dark theme support */
[data-bs-theme="dark"] .modal-content {
    background-color: var(--bs-dark);
    color: var(--bs-light);
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    background-color: var(--bs-dark);
    border-color: var(--bs-border-color-translucent);
}

[data-bs-theme="dark"] .modal-title {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] .modal-search .modal-header input {
    color: var(--bs-light);
}

[data-bs-theme="dark"] .modal-search .modal-header input::placeholder {
    color: var(--bs-secondary);
}

[data-bs-theme="dark"] .modal-stats .stat-card,
[data-bs-theme="dark"] .modal-export .export-summary {
    background-color: var(--bs-gray-800);
}

/* Animation improvements */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

.modal.show .modal-dialog {
    transform: none;
}

/* Accessibility improvements */
.modal-dialog:focus {
    outline: none;
}

.modal-content:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .modal,
    .modal-backdrop {
        display: none !important;
    }
}