/* Email container and dropdown styles */
.email-container {
    position: relative;
}

.email-input {
    padding-right: 45px;
    transition: border-color 0.2s ease-in-out;
}

.email-input:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.email-dropdown {
    position: absolute;
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    z-index: 1000;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.email-option {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.email-option:hover {
    background-color: #f8f9fa;
}

.email-option:last-child {
    border-bottom: none;
}

.email-container:focus-within .email-dropdown,
.email-container:hover .email-dropdown {
    opacity: 1;
    visibility: visible;
}

/* Icon button styles */
.btn-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: background-color 0.3s ease, transform 0.2s ease, color 0.2s ease;
}

.btn-icon:hover {
    background-color: rgba(13, 253, 61, 0.1);
    transform: translateY(-50%) scale(1.05);
}

.btn-icon:active {
    transform: translateY(-50%) scale(0.95);
}

.btn-icon .fa-spinner {
    position: absolute;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-icon.sending .fa-paper-plane {
    opacity: 0;
}

.btn-icon.sending .fa-spinner {
    opacity: 1;
}

/* Modern email modal styles */
.email-modal .modal-content {
    border-radius: 12px;
    overflow: hidden;
}

.btn-close {
    position: absolute;
    right: 15px;
    top: 15px;
    z-index: 2;
    background: none;
    border: none;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    transition: background-color 0.3s ease, color 0.2s ease, transform 0.2s ease;
}

.btn-close:hover {
    background-color: rgba(108, 117, 125, 0.1);
    color: #343a40;
    transform: rotate(90deg);
}

/* Fix for progress bar in email loading */
.email-loading {
    text-align: center;
    padding: 2rem 0;
    display: none; /* Hide by default */
}

.isGeneratingEmail .email-loading {
    display: block; /* Only show when the isGeneratingEmail class is present */
}

.email-field {
    margin-bottom: 1rem;
}

.email-field input,
.email-field textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.email-field input:focus,
.email-field textarea:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Modern button styles */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 1.5rem;
}

.btn-action {
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}

.btn-action:hover {
    transform: translateY(-2px);
}

.btn-action:active {
    transform: translateY(1px);
}

.btn-cancel {
    background-color: #f8f9fa;
    color: #6c757d;
}

.btn-cancel:hover {
    background-color: #e2e6ea;
    color: #5a6268;
}

.btn-send .fa-spinner {
    position: absolute;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-send.sending .fa-paper-plane {
    opacity: 0;
}

.btn-send.sending .fa-spinner {
    opacity: 1;
}

/* Confirmation modal styles */
.confirmation-modal .modal-content {
    border-radius: 12px;
}

.success-icon {
    font-size: 3.5rem;
    color: #28a745;
    margin-bottom: 1.5rem;
    animation: scale-in 0.4s ease;
}

.btn-confirm {
    background-color: #28a745;
    color: white;
    padding: 8px 24px;
    margin-top: 1rem;
}

.btn-confirm:hover {
    background-color: #218838;
}

/* Animations */
@keyframes scale-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.email-modal .modal-content,
.confirmation-modal .modal-content {
    animation: fade-in 0.3s ease;
}

/* Modal positioning and overflow fixes */
.modal.fade.show {
    overflow-y: auto;
    padding: 1rem 0;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 2rem);
    margin: 1rem auto;
}

.modal-content {
    width: 100%;
    max-height: calc(100vh - 3.5rem);
    overflow-y: auto;
}

.modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 8rem);
}

/* Ensure emails and document content don't create horizontal overflow */
.email-field textarea,
.email-field input,
.document-container {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure modal appears above other elements */
.email-modal,
.confirmation-modal {
    z-index: 1050;
}

/* Hide spinners and progress bars by default */
.spinner-border {
    display: none;
}

/* Only show spinners when specifically needed */
.isGeneratingEmail .spinner-border {
    display: inline-block;
}

/* Mobile responsiveness improvements */
@media (max-width: 576px) {
    .modal-dialog-centered {
        margin: 0.5rem;
    }

    .modal-content {
        max-height: calc(100vh - 2rem);
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 5rem);
    }
}

@media print {
    #sidebarContainer,
    #thumbnailView,
    .pdf-sidebar {
        display: none !important;
    }
}

/* Apply to the embedded iframe content via an injection technique */
iframe#pdf-iframe {
    width: 100% !important;
    height: 100% !important;
}

/* Item styles */
.rule-item {
    position: relative;
    transition: background-color 0.2s;
}

.rule-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.rule-name {
    max-width: 90%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.3s;
    font-weight: 500;
}

.rule-item:hover .rule-name {
    opacity: 0;
}

/* Text hover effects */
.view-text {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%; /* Take full width of parent */
    height: 100%; /* Take full height of parent */
    display: flex;
    align-items: center; /* Vertical centering */
    padding-left: 12px; /* Match the rule-name padding */
    opacity: 0;
    font-style: italic;
    color: #666;
    transition: all 0.3s ease; /* Smooth transition for all properties */
}

.rule-name {
    max-width: 90%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.3s;
    font-weight: 500;
    position: relative; /* Add this to ensure proper stacking context */
}

.rule-item:hover .view-text {
    opacity: 1;
}

/* Status indicators */
.status-icon {
    display: inline-flex;
    align-items: center;
}

.status-icon i {
    margin-right: 0.25rem;
}

/* Action icons */
.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    padding: 0;
}

.validate-icon {
    background-color: rgba(40, 167, 69, 0.2);
    color: #28a745;
}

.validate-icon:hover {
    background-color: #28a745;
    color: white;
}

.correction-icon {
    background-color: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.correction-icon:hover {
    background-color: #ffc107;
    color: white;
}

.rule-details {
    background-color: #f8f9fa;
    border-radius: 0.25rem;
    border-left: 3px solid #dee2e6;
}

.rule-error .rule-details {
    border-left-color: #dc3545;
}

.rule-success .rule-details {
    border-left-color: #28a745;
}

.rule-warning .rule-details {
    border-left-color: #ffc107;
}

/* Group item spacing */
.group-item {
    margin-bottom: 1rem;
}

.group-item:last-child {
    margin-bottom: 0;
}


.rule-section-header {
    margin: 0.75rem 0;
    padding-left: 0.5rem;
    border-left: 4px solid #6c757d;
}

.document-container h6,
.rule-section-header h5 {
    margin: 0;
    font-weight: 600;
    color: #495057;
}

/* Document badge styling */
.document-badge {
    cursor: pointer;
    transition: background-color 0.2s;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.document-badge:hover {
    background-color: #e9ecef;
}

/* PDF Viewer Overlay Styles */
.pdf-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background-color: white;
    z-index: 1050;
    display: none;
    flex-direction: column;
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.2);
}

.pdf-viewer-controls {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
    display: flex;
    justify-content: center;
    align-items: center;
    width: auto;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    padding: 8px 15px;
    transition: opacity 0.3s ease, background-color 0.3s ease;
    opacity: 0.5;
    gap: 15px;
}

.pdf-viewer-controls::after {
    content: "Ctrl+←/→";
    position: absolute;
    bottom: -18px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pdf-viewer-controls:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.7);
}

.pdf-viewer-controls:hover::after {
    opacity: 1;
}

.nav-icon,
.close-icon {
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-icon:hover,
.close-icon:hover {
    transform: scale(1.2);
}

.nav-icon.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.close-icon {
    margin-left: 5px;
    font-size: 14px;
}

.document-counter {
    font-size: 0.8rem;
    color: white;
    padding: 0 5px;
    transition: color 0.3s ease;
}

.pdf-viewer-controls:hover .document-counter {
    color: white;
}

.pdf-viewer-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.pdf-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Hide PDF viewer sidebar/thumbnails */
.pdf-iframe::-webkit-scrollbar {
    display: none;
}

/* Target common PDF viewer elements */
.pdf-viewer-body iframe {
    overflow: hidden !important;
}

/* Media query for mobile layout */
@media (max-width: 1024px) {
    .pdf-viewer-overlay {
        width: 100%;
        height: 100%;
    }
}

/* Item styles */
.document-item, .missing-document {
    position: relative;
    height: 40px;
    transition: background-color 0.2s;
}

.document-item:hover, .missing-document:hover {
    background-color: rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.document-name {
    max-width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.3s;
}

.document-item:hover .document-name,
.missing-document:hover .document-name {
    opacity: 0;
}

/* Text hover effects */
.view-text, .upload-text {
    position: absolute;
    max-width: 90%;
    left: 12px;
    opacity: 0;
    font-style: italic;
    color: #666;
    transform: translateY(5px);
    transition: all 0.3s;
}

.delete-icon {
    transition: all 0.3s ease;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.delete-icon:hover {
    background-color: rgba(220, 53, 69, 0.2);
    transform: scale(1.2);
    box-shadow: 0 0 4px rgba(220, 53, 69, 0.4);
}

.document-item:hover .view-text,
.missing-document:hover .upload-text {
    opacity: 1;
    transform: translateY(0);
}

/* Status indicators */
.status-icon {
    display: inline-flex;
    align-items: center;
}

.status-icon i {
    margin-right: 0.25rem;
}

.status-icon.text-secondary {
    opacity: 0.6;
    color: #999 !important;
}

/* Divider */
.faded-divider {
    height: 1px;
    width: 75%;
    margin: 0 auto;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.2) 15%, rgba(0, 0, 0, 0.2) 85%, transparent);
}

/* Dropzone style */
.dropzone-hover {
    background-color: rgba(40, 167, 69, 0.2) !important;
    border: 2px dashed #28a745 !important;
}

/* Modal styles - simplified */
.document-modal {
    display: none;
    position: fixed;
    z-index: 1050;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    transition: opacity 0.3s;
}

.document-modal-content {
    background-color: #fff;
    margin: 1rem auto;
    width: 95%;
    max-width: 1200px;
    height: 95vh;
    max-height: 95vh;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    position: relative;
}

.document-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.document-modal-close:hover {
    opacity: 1;
}

.document-modal-body {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 0;
}

.document-modal-body iframe,
.document-modal-body img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: 0;
    background: #f5f5f5;
}

.document-modal.active {
    display: block;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}