/* ==========================================
   Toast Notification System
   ========================================== */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 40px);
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 9999px;
    border: 1px solid transparent;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    pointer-events: auto;
    white-space: nowrap;
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
    will-change: transform, opacity;
}

.toast.toast-hiding {
    animation: toastOut 0.3s cubic-bezier(0.4, 0, 1, 1) both;
}

.toast-success {
    background: var(--toast-success);
    border-color: var(--toast-success-border);
    color: #6effc8;
}

.toast-error {
    background: var(--toast-error);
    border-color: var(--toast-error-border);
    color: var(--text-danger-soft);
}

.toast-info {
    background: var(--toast-info);
    border-color: var(--toast-info-border);
    color: #7dd3fc;
}

.toast-warning {
    background: var(--toast-warning);
    border-color: var(--toast-warning-border);
    color: #fde68a;
}

.toast-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.toast-icon svg {
    display: block;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
}

/* ==========================================
   Custom Modal Dialog
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(5, 8, 15, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease both;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay.modal-hiding {
    animation: modalFadeOut 0.2s ease both;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.modal-box {
    background: rgba(12, 18, 36, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(124, 92, 255, 0.12),
        0 0 70px rgba(124, 92, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
    font-family: var(--font-body);
    animation: modalBoxIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-overlay.modal-hiding .modal-box {
    animation: modalBoxOut 0.2s cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes modalBoxIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalBoxOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-icon {
    display: inline-flex;
    flex-shrink: 0;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

.modal-icon svg {
    display: block;
    width: 22px;
    height: 22px;
}

.modal-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

.modal-message {
    margin: 0 0 20px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-input-wrap {
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px !important;
    background: var(--bg-input) !important;
    border: 1px solid var(--border-glass) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    font-family: var(--font-body) !important;
    font-size: 0.9rem !important;
    outline: none !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}

.modal-input:focus {
    border-color: var(--accent-aurora) !important;
    box-shadow: 0 0 0 3px var(--border-focus) !important;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 9px 20px;
    border-radius: 10px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
}

.modal-btn:not(.btn-secondary) {
    background: var(--accent-gradient);
    color: #020617;
    box-shadow: 0 4px 14px rgba(var(--accent-aurora-rgb), 0.25);
}

.modal-btn:not(.btn-secondary):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(var(--accent-aurora-rgb), 0.4);
}

.modal-btn.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
    box-shadow: none;
}

.modal-btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    box-shadow: none;
    transform: none;
}

/* ==========================================
   Iframe Status Overlay (Loading / Error)
   ========================================== */
.iframe-status-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(8, 13, 22, 0.85);
    border-radius: inherit;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.iframe-status-overlay.is-loading,
.iframe-status-overlay.is-error {
    opacity: 1;
    pointer-events: auto;
}

/* Loading Spinner */
.iframe-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--accent-aurora);
    border-radius: 50%;
    animation: spinnerSpin 0.8s linear infinite;
    box-shadow: 0 0 16px rgba(var(--accent-aurora-rgb), 0.2);
}

@keyframes spinnerSpin {
    to { transform: rotate(360deg); }
}

.inline-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spinnerSpin 0.7s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}

.iframe-status-label {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

/* Error State */
.iframe-error-icon {
    font-size: 2rem;
    line-height: 0;
    color: var(--text-warning);
}

.iframe-error-icon svg {
    width: 38px;
    height: 38px;
}

.iframe-error-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-danger-soft);
    margin: 0;
    text-align: center;
}

.iframe-error-msg {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
    max-width: 240px;
    margin: 0;
}

.iframe-retry-btn {
    background: rgba(239, 68, 68, 0.15) !important;
    color: var(--text-danger-soft) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    padding: 6px 16px !important;
    border-radius: 8px !important;
    font-size: 0.75rem !important;
    font-family: var(--font-heading) !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color 0.2s ease, border-color 0.2s ease !important;
}

.iframe-retry-btn:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
}

/* URL validation state styles */
input.url-valid {
    border-color: rgba(var(--accent-aurora-rgb), 0.4) !important;
}

input.url-invalid {
    border-color: rgba(239, 68, 68, 0.5) !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15) !important;
}

/* ==========================================
   Live URL Row (QR button layout)
   ========================================== */
.live-url-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-url-row .url-input-wrapper {
    flex: 1;
    min-width: 0;
}

.qr-btn {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
}

.qr-btn:hover,
.qr-btn.active {
    color: var(--accent-aurora);
    background: rgba(var(--accent-aurora-rgb), 0.08);
}

/* ==========================================
   QR Code Popup
   ========================================== */
.qr-popup {
    position: fixed;
    top: calc(var(--header-height) + 20px);
    right: 20px;
    z-index: 5000;
    width: 240px;
    background: rgba(12, 18, 36, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transform-origin: top right;
    animation: qrPopupIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.qr-popup.qr-popup-hiding {
    animation: qrPopupOut 0.2s ease both;
}

@keyframes qrPopupIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes qrPopupOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

.qr-popup-label {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.qr-image-wrap {
    width: 180px;
    height: 180px;
    background: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qr-image-wrap img {
    border-radius: 8px;
}

.qr-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--accent-aurora);
    border-radius: 50%;
    animation: spinnerSpin 0.8s linear infinite;
}

.qr-url-text {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
    line-height: 1.4;
    max-width: 200px;
}

.close-qr-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    box-shadow: none;
    transition: color 0.2s;
}

.close-qr-btn:hover {
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

/* ==========================================
   More Tools Popup (declutters the canvas toolbar)
   ========================================== */
.tools-popup,
.tools-popup * {
    pointer-events: auto !important;
}

.tools-popup {
    position: fixed;
    bottom: calc(90px + env(safe-area-inset-bottom)); /* clears the 25px-offset, ~44px-tall floating toolbar (also grown by the safe-area inset) */
    left: 50%;
    transform: translateX(-50%);
    z-index: 130; /* above the toolbar (120) so it reads as anchored to it */
    max-width: calc(100vw - 24px);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 16px 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transform-origin: bottom center;
    animation: toolsPopupIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.tools-popup.tools-popup-hiding {
    animation: toolsPopupOut 0.18s ease both;
}

@keyframes toolsPopupIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.96); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes toolsPopupOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    to { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.97); }
}

.tools-popup-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tools-popup-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.tools-popup-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.tools-popup .toolbar-btn,
.tools-popup .toolbar-select {
    white-space: nowrap;
}

/* Scroll Sync's manual toggle is hidden: cross-origin sync silently no-ops without a
   helper script pasted into the target site, which isn't practical for a real "live"
   production site. Visual Diff still drives the underlying logic programmatically to
   align same-origin views, so the button/handler stay in the DOM, just not shown. */
#scroll-sync-btn {
    display: none !important;
}

/* ==========================================
   Overlay Opacity Control
   ========================================== */
.overlay-opacity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
}

.overlay-opacity-label {
    font-family: var(--font-heading);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.overlay-opacity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 90px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    cursor: pointer;
}

.overlay-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-aurora);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(var(--accent-aurora-rgb), 0.4);
    transition: transform 0.1s ease;
}

.overlay-opacity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Keyboard focus ring — this slider sets outline:none above, so without this a
   keyboard user would have no visible focus indicator on a real, operable control. */
.overlay-opacity-slider:focus-visible {
    outline: 2px solid var(--accent-aurora);
    outline-offset: 4px;
    border-radius: 4px;
}

.overlay-opacity-value {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-aurora);
    min-width: 34px;
    text-align: right;
}

/* ==========================================
   CSS Breakpoint Markers
   ========================================== */
.bp-toggle-btn {
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
}

.bp-toggle-btn:hover {
    color: var(--text-secondary);
}

.bp-toggle-btn.active {
    color: #7dd3fc;
    background: rgba(56, 189, 248, 0.1);
}

.breakpoint-overlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    overflow: hidden;
}

.bp-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(56, 189, 248, 0.5);
    border-left: 1px dashed rgba(56, 189, 248, 0.4);
}

.bp-line::after {
    content: attr(data-bp);
    position: absolute;
    top: 4px;
    left: 4px;
    font-family: var(--font-heading);
    font-size: 0.6rem;
    font-weight: 700;
    color: #7dd3fc;
    background: rgba(5, 8, 15, 0.8);
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.3px;
}
