/* Modal System CSS for UDCMRI Platform v2 */
/* app/static/css/v2/modal-system.css */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

/* Enhanced Referral Selection UI Styles */
.existing-referral-mode {

    margin-bottom: 1px !important;
}



.mode-toggle-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.mode-toggle-buttons .btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid;
}

.mode-toggle-buttons .btn.active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.existing-referral-selection {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.new-referral-form {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

/* Service Orders Enhancements */
.service-order-container.existing-service {
    background: rgba(72, 187, 120, 0.05);
    border: 1px solid rgba(72, 187, 120, 0.2);
    border-left: 4px solid #48bb78;
}

.existing-service-badge {
    background: #48bb78;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.existing-service-display {
    background: rgba(72, 187, 120, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.service-info {
    line-height: 1.6;
    color: #2d3748;
}

.service-info strong {
    color: #1a202c;
}

.existing-service-readonly {
    opacity: 0.9;
}

.existing-service-readonly input[readonly],
.existing-service-readonly textarea[readonly],
.existing-service-readonly select[disabled] {
    background-color: #f7fafc;
    border-color: #e2e8f0;
    color: #4a5568;
    cursor: not-allowed;
}

/* Field State Indicators */
.field-prefilled {
    background-color: rgba(72, 187, 120, 0.1);
    border-color: rgba(72, 187, 120, 0.3);
}

.field-empty {
    background-color: rgba(237, 242, 247, 0.5);
    border-color: #e2e8f0;
}

.field-partial {
    background-color: rgba(237, 137, 54, 0.1);
    border-color: rgba(237, 137, 54, 0.3);
}

.field-prefilled:focus {
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.2);
    border-color: #48bb78;
}

/* Responsive Design for Referral Selection */
@media (max-width: 768px) {
    .mode-toggle-buttons {
        flex-direction: column;
    }

    .existing-referral-mode {
        padding: 0px;
    }

    .service-order-container.existing-service {
        padding: 15px;
    }
}

/* Modal Content Container */
.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.modal-header h2,
.modal-header h3 {
    color: #2d3748;
    font-weight: 700;
    font-size: 1.5rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #718096;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

/* Modal Body */
.modal-body {
    margin-bottom: 25px;
    line-height: 1.6;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    gap: 15px;
    margin-top: 15px;

    border-top: 2px solid rgba(102, 126, 234, 0.1);
    justify-content: flex-end;
}



/* Referral Modal Specific Styles */
.referral-modal-content {
    max-width: 800px;
}

/* Patient Modal Specific Styles */
.patient-modal-content {
    max-width: 600px;
}

/* Tablet Control Modal Specific Styles */
#tabletControlModal .modal-content {
    border: none;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

#tabletControlModal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: none;
    padding: 1.5rem;
}

#tabletControlModal .modal-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#tabletControlModal .tablet-icon {
    font-size: 1.5rem;
}

#tabletControlModal .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

#tabletControlModal .btn-close:hover {
    opacity: 1;
}

#tabletControlModal .modal-body {
    padding: 1.5rem;
    background: #f8f9fa;
}

#tabletControlModal .session-status {
    background: white;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #e2e8f0;
}

#tabletControlModal .status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

#tabletControlModal .status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

#tabletControlModal .status-dot.status-active {
    background: #48bb78;
}

#tabletControlModal .status-dot.status-inactive {
    background: #cbd5e0;
}

#tabletControlModal .status-dot.status-error {
    background: #f56565;
}

#tabletControlModal .section-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1rem;
}

#tabletControlModal .search-results {
    position: relative;
    margin-top: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

#tabletControlModal .search-results.show-results {
    display: block;
}

#tabletControlModal .search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    transition: background 0.2s;
}

#tabletControlModal .search-result-item:hover {
    background: #f7fafc;
}

#tabletControlModal .search-result-item:last-child {
    border-bottom: none;
}

#tabletControlModal .patient-name {
    font-weight: 600;
    color: #2d3748;
}

#tabletControlModal .patient-details {
    font-size: 0.875rem;
    color: #718096;
    margin-top: 4px;
}

#tabletControlModal .patient-details span {
    margin-right: 15px;
}

#tabletControlModal .selected-patient .patient-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    border: 2px solid #667eea;
    border-left: 5px solid #667eea;
}

#tabletControlModal .mode-options {
    display: grid;
    gap: 10px;
}

#tabletControlModal .mode-option {
    background: white;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

#tabletControlModal .mode-option:hover {
    border-color: #667eea;
    background: #f7fafc;
}

#tabletControlModal .mode-option input[type="radio"] {
    display: none;
}

#tabletControlModal .mode-option input[type="radio"]:checked+label {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#tabletControlModal .mode-option label {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    cursor: pointer;
    margin: 0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#tabletControlModal .mode-icon {
    font-size: 1.5rem;
    min-width: 30px;
}

#tabletControlModal .mode-title {
    font-weight: 600;
    font-size: 1rem;
}

#tabletControlModal .mode-description {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: 2px;
}

#tabletControlModal .services-list {
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    max-height: 150px;
    overflow-y: auto;
}

#tabletControlModal .service-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

#tabletControlModal .service-item:last-child {
    border-bottom: none;
}

#tabletControlModal .service-item input[type="checkbox"] {
    margin: 0;
}

#tabletControlModal .service-item label {
    flex: 1;
    margin: 0;
    cursor: pointer;
}

#tabletControlModal .service-name {
    font-weight: 600;
    color: #2d3748;
}

#tabletControlModal .service-details {
    font-size: 0.875rem;
    color: #718096;
    margin-top: 2px;
}

#tabletControlModal .service-details span {
    margin-right: 15px;
}

#tabletControlModal .modal-footer {
    background: #f8f9fa;
    border-top: 1px solid #e2e8f0;
    padding: 1.5rem;
    justify-content: space-between;
    align-items: center;
}

#tabletControlModal .tablet-url-info {
    display: flex;
    align-items: center;
    gap: 5px;
}

#tabletControlModal .loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}



/* Responsive tablet modal */
@media (max-width: 768px) {
    #tabletControlModal .mode-options {
        grid-template-columns: 1fr;
    }

    #tabletControlModal .modal-footer {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    #tabletControlModal .tablet-url-info {
        order: 1;
    }
}


/* Loading State in Modals */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #718096;
}

.modal-loading .loading-spinner {
    font-size: 2rem;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

/* Error State in Modals */
.modal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #e53e3e;
    text-align: center;
}

.modal-error .error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* Modal Form Styles */
.modal-form .form-group {
    margin-bottom: 20px;
}

.modal-form .form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
}

.modal-form .form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    font-size: 1rem;
}

.modal-form .form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Modal Buttons */
.modal-footer .btn {
    flex: 1;
    max-width: fit-content;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }

    .modal-content {
        padding: 20px;
        border-radius: 15px;
        max-height: 95vh;
    }

    .modal-header {
        margin-bottom: 20px;
        padding-bottom: 10px;
    }

    .modal-header h2,
    .modal-header h3 {
        font-size: 1.25rem;
    }

    .modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    .modal-footer .btn {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 15px;
        border-radius: 12px;
    }

    .modal-header h2,
    .modal-header h3 {
        font-size: 1.1rem;
    }
}

/* Accessibility */
.modal-overlay[aria-hidden="true"] {
    display: none;
}

.modal-content:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modal-content {
        background: white;
        border: 2px solid #000;
    }

    .modal-header {
        border-bottom-color: #000;
    }

    .modal-footer {
        border-top-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .modal-overlay,
    .modal-content,
    .modal-close {
        animation: none;
        transition: none;
    }
}