/* NM621 Modal System - Theme Variables */
:root {
    /* Light theme */
    --nm621-bg-primary: #ffffff;
    --nm621-bg-secondary: #f8f9fa;
    --nm621-bg-tertiary: #f1f3f4;
    --nm621-text-primary: #1f2937;
    --nm621-text-secondary: #6b7280;
    --nm621-border-color: #e5e7eb;
    --nm621-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --nm621-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --nm621-blue-primary: #4f8df5;
    --nm621-blue-hover: #3b7ce8;
    --nm621-overlay-bg: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] {
    /* Dark theme */
    --nm621-bg-primary: #2d3748;
    --nm621-bg-secondary: #374151;
    --nm621-bg-tertiary: #4b5563;
    --nm621-text-primary: #f9fafb;
    --nm621-text-secondary: #d1d5db;
    --nm621-border-color: #4b5563;
    --nm621-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --nm621-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --nm621-blue-primary: #4f8df5;
    --nm621-blue-hover: #6ba3f7;
    --nm621-overlay-bg: rgba(0, 0, 0, 0.6);
}

/* Modal Animation Keyframes */
@keyframes nm621-modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes nm621-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* NM621 Modal Container */
.nm621-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--nm621-overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

    .nm621-modal.uk-open {
        opacity: 1;
        visibility: visible;
    }

/* Modal Dialog */
.nm621-modal .uk-modal-dialog {
    position: relative;
    background: var(--nm621-bg-primary);
    border-radius: 12px;
    box-shadow: var(--nm621-shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: nm621-modalSlideIn 0.2s ease;
    margin: 0;
}

/* Modal Header */
.nm621-modal .uk-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--nm621-border-color);
    background: var(--nm621-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nm621-modal .uk-modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--nm621-text-primary);
    line-height: 1.2;
}

/* Modal Body */
.nm621-modal .uk-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.nm621-modal .uk-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--nm621-border-color);
    background: var(--nm621-bg-secondary);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Close Button */
.nm621-modal .uk-modal-close-default {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--nm621-text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
}

    .nm621-modal .uk-modal-close-default:hover {
        color: var(--nm621-text-primary);
    }

/* Form Elements */
.nm621-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--nm621-text-primary);
    font-size: 0.875rem;
}

.nm621-form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--nm621-border-color);
    border-radius: 6px;
    background: var(--nm621-bg-primary);
    color: var(--nm621-text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

    .nm621-form-input:focus {
        outline: none;
        border-color: var(--nm621-blue-primary);
        box-shadow: 0 0 0 3px rgba(79, 141, 245, 0.1);
    }

    .nm621-form-input::placeholder {
        color: var(--nm621-text-secondary);
    }

.nm621-form-group {
    margin-bottom: 1.25rem;
}

    .nm621-form-group:last-child {
        margin-bottom: 0;
    }

/* Buttons */
.nm621-btn {
    padding: 0.625rem 1.25rem;
    border: 1px solid var(--nm621-border-color);
    border-radius: 6px;
    background: var(--nm621-bg-primary);
    color: var(--nm621-text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .nm621-btn:hover {
        background: var(--nm621-bg-secondary);
        border-color: var(--nm621-text-secondary);
    }

    .nm621-btn:active {
        transform: translateY(1px);
    }

.nm621-btn-primary {
    background: var(--nm621-blue-primary);
    border-color: var(--nm621-blue-primary);
    color: white;
}

    .nm621-btn-primary:hover {
        background: var(--nm621-blue-hover);
        border-color: var(--nm621-blue-hover);
    }

/* Modal Sizes */
.nm621-modal-small .uk-modal-dialog {
    max-width: 400px;
}

.nm621-modal-medium .uk-modal-dialog {
    max-width: 600px;
}

.nm621-modal-large .uk-modal-dialog {
    max-width: 800px;
}

/* Alert States */
.nm621-alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.nm621-alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.nm621-alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.nm621-alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Loading State */
.nm621-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nm621-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--nm621-border-color);
    border-top-color: var(--nm621-blue-primary);
    border-radius: 50%;
    animation: nm621-spin 0.6s linear infinite;
}

/* Responsive */
@media (max-width: 640px) {
    .nm621-modal .uk-modal-dialog {
        width: 95%;
        margin: 1rem;
    }

    .nm621-modal .uk-modal-header,
    .nm621-modal .uk-modal-body,
    .nm621-modal .uk-modal-footer {
        padding: 1rem;
    }

    .nm621-modal .uk-modal-footer {
        flex-direction: column;
    }

        .nm621-modal .uk-modal-footer .nm621-btn {
            width: 100%;
        }
}

/* Dark Mode Adjustments */
[data-theme="dark"] .nm621-alert-success {
    background: #064e3b;
    color: #a7f3d0;
    border-color: #065f46;
}

[data-theme="dark"] .nm621-alert-error {
    background: #7f1d1d;
    color: #fecaca;
    border-color: #991b1b;
}

[data-theme="dark"] .nm621-alert-info {
    background: #1e3a8a;
    color: #bfdbfe;
    border-color: #1e40af;
}

/* NM621 Segmented Control */
.nm621-segmented {
    display: inline-flex;
    background: var(--nm621-bg-secondary);
    border: 1px solid var(--nm621-border-color);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.nm621-segment {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--nm621-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

    .nm621-segment:hover {
        color: var(--nm621-text-primary);
        background: rgba(0, 0, 0, 0.05);
    }

    .nm621-segment.active,
    .nm621-segment-selected {
        background: var(--nm621-bg-primary);
        color: var(--nm621-blue-primary);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

/* NM621 Switch/Toggle */
.nm621-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

    .nm621-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.nm621-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--nm621-border-color);
    transition: 0.2s;
    border-radius: 24px;
}

    .nm621-switch-slider::before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        transition: 0.2s;
        border-radius: 50%;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }

.nm621-switch input:checked + .nm621-switch-slider {
    background-color: var(--nm621-blue-primary);
}

.nm621-switch input:checked + .nm621-switch-slider::before {
    transform: translateX(20px);
}

/* NM621 Checkbox and Radio */
.nm621-checkbox,
.nm621-radio {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 0.5rem;
}

    .nm621-checkbox input,
    .nm621-radio input {
        position: absolute;
        opacity: 0;
        cursor: pointer;
        height: 0;
        width: 0;
    }

.nm621-checkbox-mark,
.nm621-radio-mark {
    height: 18px;
    width: 18px;
    background-color: var(--nm621-bg-primary);
    border: 2px solid var(--nm621-border-color);
    transition: all 0.2s ease;
}

.nm621-checkbox-mark {
    border-radius: 4px;
}

.nm621-radio-mark {
    border-radius: 50%;
}

.nm621-checkbox:hover .nm621-checkbox-mark,
.nm621-radio:hover .nm621-radio-mark {
    border-color: var(--nm621-blue-primary);
}

.nm621-checkbox input:checked ~ .nm621-checkbox-mark,
.nm621-radio input:checked ~ .nm621-radio-mark {
    background-color: var(--nm621-blue-primary);
    border-color: var(--nm621-blue-primary);
}

.nm621-checkbox-mark::after,
.nm621-radio-mark::after {
    content: "";
    position: absolute;
    display: none;
}

.nm621-checkbox input:checked ~ .nm621-checkbox-mark::after,
.nm621-radio input:checked ~ .nm621-radio-mark::after {
    display: block;
}

.nm621-checkbox .nm621-checkbox-mark::after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.nm621-radio .nm621-radio-mark::after {
    left: 6px;
    top: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
}

/* NM621 Select Dropdown */
.nm621-select {
    position: relative;
    display: inline-block;
    width: 100%;
}

    .nm621-select select {
        width: 100%;
        padding: 0.625rem 2.5rem 0.625rem 0.875rem;
        border: 1px solid var(--nm621-border-color);
        border-radius: 6px;
        background: var(--nm621-bg-primary);
        color: var(--nm621-text-primary);
        font-size: 0.875rem;
        cursor: pointer;
        appearance: none;
        transition: border-color 0.2s ease;
    }

        .nm621-select select:focus {
            outline: none;
            border-color: var(--nm621-blue-primary);
            box-shadow: 0 0 0 3px rgba(79, 141, 245, 0.1);
        }

    .nm621-select::after {
        content: "";
        position: absolute;
        top: 50%;
        right: 0.875rem;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 5px solid var(--nm621-text-secondary);
        pointer-events: none;
    }

/* NM621 Badge */
.nm621-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
    border-radius: 9999px;
    background: var(--nm621-bg-secondary);
    color: var(--nm621-text-secondary);
    border: 1px solid var(--nm621-border-color);
}

.nm621-badge-primary {
    background: var(--nm621-blue-primary);
    color: white;
    border-color: var(--nm621-blue-primary);
}

.nm621-badge-success {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.nm621-badge-warning {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.nm621-badge-danger {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

/* NM621 Progress Bar */
.nm621-progress {
    width: 100%;
    height: 8px;
    background: var(--nm621-bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.nm621-progress-bar {
    height: 100%;
    background: var(--nm621-blue-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* NM621 Tooltip */
.nm621-tooltip {
    position: relative;
    display: inline-block;
}

    .nm621-tooltip .nm621-tooltip-text {
        visibility: hidden;
        min-width: 120px;
        background-color: rgba(0, 0, 0, 0.9);
        color: white;
        text-align: center;
        padding: 0.5rem 0.75rem;
        border-radius: 6px;
        font-size: 0.75rem;
        position: absolute;
        z-index: 1000;
        bottom: 125%;
        left: 50%;
        transform: translateX(-50%);
        opacity: 0;
        transition: opacity 0.2s ease;
    }

        .nm621-tooltip .nm621-tooltip-text::after {
            content: "";
            position: absolute;
            top: 100%;
            left: 50%;
            margin-left: -5px;
            border-width: 5px;
            border-style: solid;
            border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
        }

    .nm621-tooltip:hover .nm621-tooltip-text {
        visibility: visible;
        opacity: 1;
    }

/* NM621 Tabs */
.nm621-tabs {
    border-bottom: 1px solid var(--nm621-border-color);
}

.nm621-tab-list {
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nm621-tab {
    position: relative;
    padding: 1rem 0;
    color: var(--nm621-text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

    .nm621-tab:hover {
        color: var(--nm621-text-primary);
    }

    .nm621-tab.active {
        color: var(--nm621-blue-primary);
        border-bottom-color: var(--nm621-blue-primary);
    }

.nm621-tab-content {
    padding: 1.5rem 0;
}

.nm621-tab-panel {
    display: none;
}

    .nm621-tab-panel.active {
        display: block;
    }

/* NM621 Card */
.nm621-card {
    background: var(--nm621-bg-primary);
    border: 1px solid var(--nm621-border-color);
    border-radius: 8px;
    box-shadow: var(--nm621-shadow);
    overflow: hidden;
}

.nm621-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--nm621-border-color);
}

.nm621-card-body {
    padding: 1.25rem;
}

.nm621-card-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--nm621-border-color);
    background: var(--nm621-bg-secondary);
}

/* NM621 List Group */
.nm621-list-group {
    display: flex;
    flex-direction: column;
    background: var(--nm621-bg-primary);
    border: 1px solid var(--nm621-border-color);
    border-radius: 8px;
    overflow: hidden;
}

.nm621-list-item {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--nm621-border-color);
    color: var(--nm621-text-primary);
    transition: background-color 0.2s ease;
}

    .nm621-list-item:last-child {
        border-bottom: none;
    }

    .nm621-list-item:hover {
        background: var(--nm621-bg-secondary);
    }

    .nm621-list-item.active {
        background: var(--nm621-blue-primary);
        color: white;
    }

/* NM621 Notification */
.nm621-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    min-width: 300px;
    max-width: 400px;
    padding: 1rem;
    background: var(--nm621-bg-primary);
    border: 1px solid var(--nm621-border-color);
    border-radius: 8px;
    box-shadow: var(--nm621-shadow-lg);
    z-index: 1100;
    animation: nm621-slideIn 0.3s ease;
}

@keyframes nm621-slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* NM621 Check Circle Icon */
.nm621-check-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #10b981;
    border-radius: 50%;
    position: relative;
}

    .nm621-check-circle::after {
        content: "✓";
        color: white;
        font-size: 16px;
        font-weight: bold;
    }

/* Size variants */
.nm621-check-circle-sm {
    width: 20px;
    height: 20px;
}

    .nm621-check-circle-sm::after {
        font-size: 12px;
    }

.nm621-check-circle-lg {
    width: 48px;
    height: 48px;
}

.nm621-check-circle-lg::after {
    font-size: 24px;
}

/* Modern Progress Indicator */
.modern-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modern-progress-overlay.active {
    opacity: 1;
    visibility: visible;
}

.progress-card {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-light, #e5e7eb);
    border-radius: 20px;
    padding: 2.5rem 3rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    max-width: 400px;
    width: 90%;
}

.modern-progress-overlay.active .progress-card {
    transform: scale(1);
}

.progress-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-glow 2s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.progress-icon::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

.progress-icon span {
    color: white;
    font-size: 1.5rem;
    position: relative;
    z-index: 2;
}

.progress-title {
    color: var(--text-primary, #1f2937);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-subtitle {
    color: var(--text-secondary, #6b7280);
    font-size: 0.95rem;
    margin: 0 0 1.5rem 0;
    line-height: 1.4;
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary, #4f46e5);
    opacity: 0.3;
    animation: dot-pulse 1.5s ease-in-out infinite;
}

.progress-dot:nth-child(1) {
    animation-delay: 0s;
}

.progress-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.progress-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    border-radius: 2px;
    width: 0%;
    animation: progress-fill 2s ease-in-out infinite;
}

.progress-status {
    color: var(--text-tertiary, #9ca3af);
    font-size: 0.85rem;
    font-style: italic;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

@keyframes dot-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes progress-fill {
    0% {
        width: 0%;
    }
    50% {
        width: 60%;
    }
    100% {
        width: 85%;
    }
}

/* Elegant AI Summary Spinner */
.ai-summary-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 2rem;
}

.ai-spinner {
    position: relative;
    width: 48px;
    height: 48px;
}

.ai-spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
    border-top-color: var(--accent-primary, #4f46e5);
    animation: ai-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.ai-spinner-ring:nth-child(2) {
    width: 36px;
    height: 36px;
    top: 6px;
    left: 6px;
    border-top-color: var(--accent-secondary, #7c3aed);
    animation-delay: -0.4s;
    animation-duration: 1s;
}

.ai-spinner-ring:nth-child(3) {
    width: 24px;
    height: 24px;
    top: 12px;
    left: 12px;
    border-top-color: var(--nm621-blue-primary, #4f8df5);
    animation-delay: -0.8s;
    animation-duration: 0.8s;
}

@keyframes ai-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.ai-spinner-text {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary, #6b7280);
    animation: ai-pulse 1.5s ease-in-out infinite;
    text-align: center;
}

@keyframes ai-pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}