/**
 * TNG Clean CV / Resume Modal Popup Window (2028 Best Practice)
 * Provides a distraction-free, floating executive window on top of any page.
 */

/* Backdrop Overlay */
.tng-cv-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(15, 23, 42, 0.70);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.tng-cv-modal-backdrop.is-active {
    opacity: 1;
    visibility: visible;
}

/* Modal Window Container */
.tng-cv-modal-window {
    width: 100%;
    max-width: 980px;
    height: 90vh;
    max-height: 960px;
    background: #f8fafc;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.45),
                0 0 0 1px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(16px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.tng-cv-modal-backdrop.is-active .tng-cv-modal-window {
    transform: scale(1) translateY(0);
}

/* Modal Titlebar / Header */
.tng-cv-modal-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: nowrap;
    z-index: 10;
    flex-shrink: 0;
}

.tng-cv-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.98rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.tng-cv-modal-title svg {
    flex-shrink: 0;
}

.tng-cv-modal-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    margin-left: auto;
}

/* Segmented Toggle Pills */
.tng-cv-seg-group {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.tng-cv-seg-btn {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tng-cv-seg-btn:hover {
    color: #0f172a;
}

.tng-cv-seg-btn.is-active {
    background: #ffffff;
    color: #ea580c;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Modal Action Buttons */
.tng-cv-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    border: 1px solid transparent;
    white-space: nowrap;
}

.tng-cv-action-btn.btn-print {
    background: #0f172a;
    color: #ffffff;
}

.tng-cv-action-btn.btn-print:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.tng-cv-action-btn.btn-newtab {
    background: #ffffff;
    color: #475569;
    border-color: #cbd5e1;
}

.tng-cv-action-btn.btn-newtab:hover {
    color: #0f172a;
    background: #f8fafc;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.tng-cv-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.tng-cv-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: scale(1.08);
}

.tng-cv-close-btn:active {
    background: #cbd5e1;
    transform: scale(0.96);
}

.tng-cv-close-btn svg {
    display: block;
    pointer-events: none;
}

/* Modal Body / Iframe Area */
.tng-cv-modal-body {
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #f8fafc;
}

.tng-cv-iframe {
    width: 100%;
    height: 100%;
    min-height: 100%;
    border: none;
    background: #f8fafc;
    display: block;
}

/* Loading Spinner */
.tng-cv-loading {
    position: absolute;
    inset: 0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ea580c;
    font-size: 0.95rem;
    font-weight: 600;
    gap: 10px;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.tng-cv-loading.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.tng-cv-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(234, 88, 12, 0.2);
    border-top-color: #ea580c;
    border-radius: 50%;
    animation: tng-cv-spin 0.8s linear infinite;
}

@keyframes tng-cv-spin {
    to { transform: rotate(360deg); }
}

/* Profile Card Action Button */
.tng-cv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 14px;
    background: #ffffff;
    color: #ea580c !important;
    border: 1px solid rgba(234, 88, 12, 0.3);
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.tng-cv-btn:hover {
    background: #fff7ed;
    border-color: #ea580c;
    color: #c2410c !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.15);
}

.tng-cv-btn svg {
    stroke: currentColor;
    flex-shrink: 0;
}

/* Mobile Responsiveness & iOS Safe-Area Optimization */
@media (max-width: 768px) {
    .tng-cv-modal-backdrop {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .tng-cv-modal-window {
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        transform: translateY(100%);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .tng-cv-modal-backdrop.is-active .tng-cv-modal-window {
        transform: translateY(0);
    }

    .tng-cv-modal-header {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        row-gap: 8px;
        column-gap: 8px;
        align-items: center;
        padding-top: max(14px, env(safe-area-inset-top, 14px));
        padding-bottom: 9px;
        padding-left: max(8px, env(safe-area-inset-left, 8px));
        padding-right: max(8px, env(safe-area-inset-right, 8px));
    }

    .tng-cv-modal-title {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        font-size: 0.88rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .tng-cv-close-btn {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        justify-self: end;
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .tng-cv-modal-controls {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        margin-left: 0;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 3px;
        flex-wrap: nowrap;
    }

    .tng-cv-seg-group {
        padding: 2px;
        border-radius: 7px;
        flex-shrink: 0;
    }

    .tng-cv-seg-btn {
        padding: 4px 6px;
        font-size: 0.72rem;
        border-radius: 5px;
    }

    .tng-cv-action-btn {
        padding: 4px 6px;
        font-size: 0.72rem;
        border-radius: 6px;
        gap: 3px;
        flex-shrink: 0;
    }

    .tng-cv-action-btn svg {
        width: 12px;
        height: 12px;
    }

    .tng-cv-modal-body {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

