/* Modal Dialog System CSS */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-backdrop.modal-show {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s ease;
}

.modal-dialog.modal-show {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

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

.modal-form .form-group {
    margin-bottom: 20px;
}

.modal-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
}

.modal-form input,
.modal-form textarea,
.modal-form select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-form input:focus,
.modal-form textarea:focus,
.modal-form select:focus {
    outline: none;
    border-color: #8B5FBF;
    box-shadow: 0 0 0 3px rgba(139, 95, 191, 0.1);
}

.modal-form input.error,
.modal-form textarea.error,
.modal-form select.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #8B5FBF 0%, #7FB069 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 95, 191, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.btn-outline {
    background: transparent;
    color: #8B5FBF;
    border: 2px solid #8B5FBF;
}

.btn-outline:hover {
    background: #8B5FBF;
    color: white;
}

/* Video Viewer Styles */
.video-viewer {
    min-height: 300px;
}

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.05), rgba(127, 176, 105, 0.05));
    border: 2px dashed var(--primary-purple, #8B7EC8);
    border-radius: 12px;
    text-align: center;
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.video-info h3 {
    color: var(--text-primary, #333);
    font-size: 18px;
    font-weight: 600;
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.video-container video {
    display: block;
    width: 100%;
}

.video-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

/* Video modal specific styles */
.video-modal {
    max-width: 95vw;
}

.video-modal .modal-body {
    padding: 20px;
}

/* Responsive video */
@media (max-width: 768px) {
    .video-modal {
        width: 95vw !important;
        max-height: 95vh;
    }

    .video-container video {
        max-height: 50vh;
    }

    .video-info h3 {
        font-size: 16px;
    }
}

/* ========================================================================
   Quick Insight Modal Styles
   ======================================================================== */

.quick-insight-backdrop {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.quick-insight-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.quick-insight-modal {
    width: 500px;
    max-width: 90vw;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.quick-insight-backdrop.show .quick-insight-modal {
    transform: translateY(0);
    opacity: 1;
}

.quick-insight-modal .modal-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quick-insight-modal .modal-icon {
    font-size: 24px;
}

.quick-insight-modal .modal-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.quick-insight-modal .form-group {
    margin-bottom: 16px;
}

.quick-insight-modal label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #374151;
}

.quick-insight-modal textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-insight-modal textarea:focus {
    outline: none;
    border-color: #8B5FBF;
    box-shadow: 0 0 0 3px rgba(139, 95, 191, 0.1);
}

.quick-insight-modal .char-counter {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #9ca3af;
    text-align: right;
}

.quick-insight-modal .context-info {
    margin: 16px 0;
    padding: 12px;
    background: linear-gradient(135deg, rgba(139, 95, 191, 0.05), rgba(127, 176, 105, 0.05));
    border-left: 3px solid #8B5FBF;
    border-radius: 4px;
}

.quick-insight-modal .context-info small {
    color: #6b7280;
    font-size: 13px;
}

.quick-insight-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.quick-insight-modal .save-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
    font-weight: 500;
}

.quick-insight-modal .save-status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.quick-insight-modal .save-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.quick-insight-modal .save-status.info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Quick Insight Button (for navigation) */
#quick-insight-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8B5FBF 0%, #7FB069 100%);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(139, 95, 191, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quick-insight-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 95, 191, 0.4);
}

#quick-insight-btn:active {
    transform: translateY(0);
}

/* Tooltip for Quick Insight button */
#quick-insight-btn::before {
    content: "Quick Insight";
    position: absolute;
    right: 100%;
    margin-right: 12px;
    background: #374151;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#quick-insight-btn:hover::before {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .quick-insight-modal {
        width: 95vw;
    }

    #quick-insight-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    #quick-insight-btn::before {
        display: none; /* Hide tooltip on mobile */
    }
}

/* ========================================================================
   AI Insight Card Styles
   ======================================================================== */

.ai-insight-card {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 600px;
    max-width: 90vw;
    background: white;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

.ai-insight-card.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.ai-insight-card.hide {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
}

.ai-insight-card .insight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 12px;
    border-bottom: 2px solid #f3f4f6;
}

.ai-insight-card .insight-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ai-insight-card .insight-icon {
    font-size: 24px;
    line-height: 1;
}

.ai-insight-card .insight-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.ai-insight-card .fallback-indicator {
    font-size: 12px;
    color: #9ca3af;
    margin-left: 8px;
    cursor: help;
}

.ai-insight-card .insight-dismiss {
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
    line-height: 1;
}

.ai-insight-card .insight-dismiss:hover {
    background-color: #f3f4f6;
    color: #6b7280;
}

.ai-insight-card .insight-content {
    padding: 20px 24px;
    font-size: 15px;
    line-height: 1.6;
    color: #374151;
    position: relative;
}

.ai-insight-card .insight-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px 20px;
}

.ai-insight-card .insight-action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-insight-card .insight-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-insight-card .insight-action-btn.primary {
    background: linear-gradient(135deg, #8B5FBF 0%, #7FB069 100%);
    color: white;
}

.ai-insight-card .insight-action-btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 95, 191, 0.3);
}

.ai-insight-card .insight-action-btn.secondary {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.ai-insight-card .insight-action-btn.secondary:hover:not(:disabled) {
    background: #e5e7eb;
    color: #374151;
}

/* Auto-dismiss timer bar */
.ai-insight-card .insight-timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #f3f4f6;
    overflow: hidden;
}

.ai-insight-card .timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #8B5FBF 0%, #7FB069 100%);
    transform-origin: left;
}

/* Confirmation checkmark animation */
.ai-insight-card .insight-checkmark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 48px;
    color: #7FB069;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55),
                opacity 0.3s ease;
    z-index: 10;
}

.ai-insight-card .insight-checkmark.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ai-insight-card {
        width: 100vw;
        max-width: 100vw;
        border-radius: 16px 16px 0 0;
    }

    .ai-insight-card .insight-header {
        padding: 16px 20px 10px;
    }

    .ai-insight-card .insight-content {
        padding: 16px 20px;
        font-size: 14px;
    }

    .ai-insight-card .insight-actions {
        padding: 12px 20px 16px;
        flex-direction: column;
    }

    .ai-insight-card .insight-action-btn {
        width: 100%;
    }

    .ai-insight-card .insight-icon {
        font-size: 20px;
    }

    .ai-insight-card .insight-title {
        font-size: 15px;
    }
}

/* ========================================================================
   Completion Modal Styles (for celebration)
   ======================================================================== */

.completion-modal-content {
    text-align: center;
    padding: 20px;
    max-width: 500px;
}

.completion-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: celebration-bounce 1s ease;
}

@keyframes celebration-bounce {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.2) rotate(-10deg);
    }
    50% {
        transform: scale(1) rotate(0deg);
    }
    75% {
        transform: scale(1.2) rotate(10deg);
    }
}

.completion-title {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 12px 0;
    background: linear-gradient(135deg, #8B7EC8, #7FB069);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.completion-message {
    font-size: 16px;
    color: #6b7280;
    margin: 0 0 32px 0;
    line-height: 1.6;
}

.completion-next-steps {
    text-align: left;
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.05), rgba(127, 176, 105, 0.05));
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 32px;
}

.completion-next-steps h3 {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 16px 0;
}

.completion-next-steps ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.completion-next-steps li {
    font-size: 15px;
    color: #6b7280;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.completion-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: linear-gradient(135deg, #8B7EC8, #7FB069);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 126, 200, 0.3);
}

.completion-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 126, 200, 0.4);
}

.completion-cta:active {
    transform: translateY(0);
}

/* Reduced motion for completion modal */
@media (prefers-reduced-motion: reduce) {
    .completion-icon {
        animation: none;
    }

    .completion-cta:hover {
        transform: none;
    }
}

/* Short viewport — tighter modals on laptop screens (768px height) */
@media (max-height: 800px) {
    .modal-dialog {
        max-height: 85vh;
    }

    .modal-header {
        padding: 16px 24px 12px;
    }

    .modal-body {
        padding: 16px 24px;
    }

    .modal-footer {
        padding: 12px 24px 16px;
    }

    .video-placeholder {
        padding: 24px 20px;
    }
}
