/* ========================================
   MODAL STYLES
   Progress Modals, Delete Modals, General Modals
   ======================================== */

/* Modal System */
.modal {
    display: none;
    position: fixed;
    /* Ensure Bootstrap modal sits above its backdrop (which is ~1050) */
    z-index: 1065;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Prevent backdrop clicks from closing modal - users must use X or Cancel */
.modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    z-index: -1;
}

/* Explicitly set Bootstrap backdrop below modal */
.modal-backdrop {
    z-index: 1050 !important;
}

.modal-content {
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    animation: slideIn 0.3s ease;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f1f5f9;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--valerin-red-light) 0%, #ffffff 100%);
    border-bottom: 3px solid var(--valerin-red);
}

.modal-header h3 {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #f1f5f9;
    color: #374151;
}

.close-btn {
    font-size: 24px;
    font-weight: bold;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    color: var(--text);
    background: var(--border);
}

.modal-body {
    padding: 24px;
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.modal-footer button {
    min-width: 100px;
}

/* Progress Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.progress-modal {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: modalSlideIn 0.3s ease-out;
}

.progress-modal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.progress-modal .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.progress-modal .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.progress-modal .modal-body {
    padding: 32px;
}

.progress-container {
    margin-bottom: 24px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

.status-text {
    text-align: center;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 500;
}

.time-remaining {
    text-align: center;
    font-size: 0.875rem;
    color: var(--muted);
    font-style: italic;
}

/* Progress Modal - Prevent accidental closing */
#progressModal {
    pointer-events: auto;
}

#progressModal .modal-content {
    pointer-events: auto;
}

#progressModal .close-btn {
    transition: opacity 0.3s ease;
}

#progressModal .close-btn[style*="display: none"] {
    opacity: 0;
    pointer-events: none;
}

/* Delete Project Modal Styles */
.project-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.delete-project-modal {
    max-width: 600px;
    width: 90vw;
}

.danger-header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-radius: 12px 12px 0 0;
}

.danger-header .danger-icon {
    color: #fef2f2;
}

.danger-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    color: white;
}

.delete-warning-content {
    padding: 24px;
}

.warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.warning-icon {
    color: #dc2626;
    flex-shrink: 0;
}

.warning-text h4 {
    margin: 0 0 8px 0;
    color: #dc2626;
    font-size: 18px;
    font-weight: 700;
}

.warning-text p {
    margin: 0 0 12px 0;
    color: #7f1d1d;
    font-weight: 600;
}

.project-to-delete {
    background: #dc2626;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    margin: 8px 0;
}

.deletion-impact {
    background: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.deletion-impact h5 {
    margin: 0 0 16px 0;
    color: #92400e;
    font-size: 16px;
    font-weight: 700;
}

.impact-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.impact-list li {
    padding: 8px 0;
    color: #92400e;
    font-weight: 500;
    border-bottom: 1px solid #fde68a;
}

.impact-list li:last-child {
    border-bottom: none;
}

.final-warning {
    margin-bottom: 24px;
}

.warning-box {
    background: #dc2626;
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.warning-box h5 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 700;
}

.warning-box p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.confirmation-required {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}

/* AI Findings Review Styles */
.ai-review-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.ai-review-header {
    text-align: center;
    margin-bottom: 32px;
    padding: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    color: white;
}

.ai-review-header h1 {
    margin: 0 0 8px 0;
    font-size: 2.5rem;
    font-weight: 700;
}

.subtitle {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.confidence-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.summary-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
}

.summary-card.high-confidence {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.summary-card.low-confidence {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.summary-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 16px;
}

.summary-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.summary-content p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.findings-sections {
    margin-bottom: 32px;
}

.findings-section {
    margin-bottom: 32px;
}

.findings-section h2 {
    margin: 0 0 24px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

.findings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
}

.finding-card {
    background: var(--card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.finding-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.finding-card.high-confidence-card {
    border-left: 4px solid var(--success);
}

.finding-card.low-confidence-card {
    border-left: 4px solid var(--warning);
}

.finding-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.finding-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.finding-content {
    margin-bottom: 16px;
}

.finding-content > div {
    margin-bottom: 12px;
}

.finding-content label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.current-value .current {
    color: var(--muted);
    font-style: italic;
}

.suggested-value .suggested {
    color: var(--primary);
    font-weight: 500;
}

.ai-context p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.4;
}

.source-text .source {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    background: var(--bg);
    padding: 8px 12px;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.finding-actions {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 32px;
    background: var(--bg);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.create-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.btn-create {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 1.1rem;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-create:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.create-note {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
    text-align: center;
}

.creation-notice {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.notice-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.notice-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.notice-content p {
    margin: 0;
    font-size: 0.95rem;
    opacity: 0.9;
    line-height: 1.5;
}

/* Flash messages */
.flash {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.flash li {
    padding: 16px 20px;
    margin-bottom: 12px;
    border-radius: 8px;
    font-weight: 500;
    border-left: 4px solid;
}

.flash li.success {
    background: #f0fdf4;
    color: #166534;
    border-left-color: #22c55e;
}

.flash li.error {
    background: #fef2f2;
    color: #dc2626;
    border-left-color: #ef4444;
}

.flash li.info {
    background: #eff6ff;
    color: #1d4ed8;
    border-left-color: #3b82f6;
}

/* Collapsible */
.collapsible h2 {
    cursor: pointer;
    margin-top: 0;
}

.collapsible h2::after {
    content: "";
}

.collapsible.open {
}

/* Task suggestion chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.chip {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

.chip:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Section titles */
.section-title {
    margin: 18px 2px 10px;
    font-size: 20px;
    color: var(--text);
    font-weight: 600;
}
