/**
 * App Frame Component
 * Creates a fake app window that mimics the ormeo.lens application
 * Used to embed interactive demos on marketing pages
 */

/* ========================================
   App Frame Container
   ======================================== */
.app-frame {
    --frame-radius: 12px;
    --frame-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --frame-border: 1px solid var(--border-primary, #e5e5e5);

    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    height: 600px;
    margin: 0 auto;
    background: var(--bg-secondary, #ffffff);
    border: var(--frame-border);
    border-radius: var(--frame-radius);
    box-shadow: var(--frame-shadow);
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Responsive heights */
@media (max-width: 768px) {
    .app-frame {
        height: 550px;
        --frame-radius: 8px;
    }
}

@media (max-width: 480px) {
    .app-frame {
        height: 520px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* ========================================
   Title Bar (mimics OS window)
   ======================================== */
.app-frame__titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 38px;
    padding: 0 12px;
    background: var(--bg-tertiary, #f5f4f2);
    border-bottom: 1px solid var(--border-primary, #e5e5e5);
    flex-shrink: 0;
}

.app-frame__titlebar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Fake window controls (macOS style) */
.app-frame__window-controls {
    display: flex;
    gap: 6px;
}

.app-frame__window-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-secondary, #d4d4d4);
}

.app-frame__window-dot--close {
    background: #ff5f57;
}

.app-frame__window-dot--minimize {
    background: #ffbd2e;
}

.app-frame__window-dot--maximize {
    background: #28ca42;
}

/* Hide window controls on mobile */
@media (max-width: 480px) {
    .app-frame__window-controls {
        display: none;
    }
}

.app-frame__title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #525252);
    margin-left: 8px;
}

.app-frame__titlebar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========================================
   Navigation Bar
   ======================================== */
.app-frame__navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: var(--bg-secondary, #ffffff);
    border-bottom: 1px solid var(--border-primary, #e5e5e5);
    flex-shrink: 0;
}

.app-frame__brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-frame__logo {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #5b9a8b 0%, #4a9d7c 100%);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.app-frame__brand-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1f1f1f);
}

.app-frame__nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-frame__nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #525252);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.app-frame__nav-item:hover {
    background: var(--bg-hover, #f0efed);
    color: var(--text-primary, #1f1f1f);
}

.app-frame__nav-item.is-active {
    background: var(--bg-tertiary, #f5f4f2);
    color: var(--text-primary, #1f1f1f);
}

.app-frame__nav-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.app-frame__nav-item.is-active svg {
    opacity: 1;
}

/* Hide nav text on small screens */
@media (max-width: 600px) {
    .app-frame__nav-item span {
        display: none;
    }

    .app-frame__nav-item {
        padding: 8px 10px;
    }
}

.app-frame__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-frame__action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary, #f5f4f2);
    border: 1px solid var(--border-primary, #e5e5e5);
    border-radius: 6px;
    color: var(--text-secondary, #525252);
    cursor: pointer;
    transition: all 0.15s ease;
}

.app-frame__action-btn:hover {
    background: var(--bg-hover, #f0efed);
    color: var(--text-primary, #1f1f1f);
}

.app-frame__action-btn svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Content Area
   ======================================== */
.app-frame__content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-tertiary, #f5f4f2);
}

/* ========================================
   Custom Scrollbars for Demos
   Forces scrollbars to be visible on macOS
   ======================================== */

/* WebKit (Chrome, Safari, Edge) */
.app-frame__content ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.app-frame__content ::-webkit-scrollbar-track {
    background: var(--bg-tertiary, #f5f4f2);
    border-radius: 4px;
}

.app-frame__content ::-webkit-scrollbar-thumb {
    background: var(--border-secondary, #c4c4c4);
    border-radius: 4px;
    border: 2px solid var(--bg-tertiary, #f5f4f2);
}

.app-frame__content ::-webkit-scrollbar-thumb:hover {
    background: var(--text-quaternary, #a3a3a3);
}

/* Firefox */
.app-frame__content * {
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary, #c4c4c4) var(--bg-tertiary, #f5f4f2);
}

/* Dark theme scrollbars */
[data-theme="dark"] .app-frame__content ::-webkit-scrollbar-track {
    background: var(--bg-tertiary, #242424);
}

[data-theme="dark"] .app-frame__content ::-webkit-scrollbar-thumb {
    background: var(--border-secondary, #525252);
    border-color: var(--bg-tertiary, #242424);
}

[data-theme="dark"] .app-frame__content ::-webkit-scrollbar-thumb:hover {
    background: var(--text-quaternary, #737373);
}

[data-theme="dark"] .app-frame__content * {
    scrollbar-color: var(--border-secondary, #525252) var(--bg-tertiary, #242424);
}

/* Fullscreen modal scrollbars */
.app-frame-fullscreen .app-frame__content ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.app-frame-fullscreen .app-frame__content ::-webkit-scrollbar-thumb {
    border-width: 2px;
}

/* ========================================
   Status Bar (optional footer)
   ======================================== */
.app-frame__statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 28px;
    padding: 0 12px;
    background: var(--bg-tertiary, #f5f4f2);
    border-top: 1px solid var(--border-primary, #e5e5e5);
    font-size: 11px;
    color: var(--text-tertiary, #737373);
    flex-shrink: 0;
}

.app-frame__statusbar-left,
.app-frame__statusbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-frame__status-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.app-frame__status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4a9d7c;
}

.app-frame__status-dot--warning {
    background: #c9a857;
}

.app-frame__status-dot--error {
    background: #c75555;
}

/* Hide status bar on mobile */
@media (max-width: 480px) {
    .app-frame__statusbar {
        display: none;
    }
}

/* ========================================
   Dark Theme
   ======================================== */
[data-theme="dark"] .app-frame {
    --frame-border: 1px solid #3f3f3f;
    --frame-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .app-frame__window-dot {
    background: #525252;
}

/* ========================================
   Fullscreen Button (positioned outside app-frame)
   ======================================== */
.app-frame-wrapper {
    position: relative;
}

.app-frame__fullscreen-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-primary, #e5e5e5);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #525252);
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    transition: all 0.15s ease;
    z-index: 50;
}

.app-frame__fullscreen-btn:hover {
    background: var(--accent-primary, #5b9a8b);
    border-color: var(--accent-primary, #5b9a8b);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(91, 154, 139, 0.3);
}

.app-frame__fullscreen-btn svg {
    width: 14px;
    height: 14px;
}

/* On mobile, position inside frame at top-right */
@media (max-width: 768px) {
    .app-frame__fullscreen-btn {
        top: 8px;
        right: 8px;
        padding: 6px 10px;
        font-size: 11px;
    }

    .app-frame__fullscreen-btn span {
        display: none;
    }
}

/* ========================================
   Interaction Overlay (tap to interact)
   ======================================== */
.app-frame__interaction-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.app-frame__interaction-overlay.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-frame__interaction-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 32px;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-primary, #e5e5e5);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.app-frame__interaction-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary, #5b9a8b);
    animation: app-frame-hand-wave 1s ease-in-out infinite;
}

.app-frame__interaction-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes app-frame-hand-wave {
    0%, 100% {
        transform: translateX(-8px) rotate(-5deg);
    }
    50% {
        transform: translateX(8px) rotate(5deg);
    }
}

.app-frame__interaction-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #525252);
}

/* When content is interactive, allow pointer events */
.app-frame__content.is-interactive {
    /* Demo container becomes interactive */
}

/* Dark theme adjustments */
[data-theme="dark"] .app-frame__interaction-overlay {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .app-frame__interaction-content {
    background: var(--bg-tertiary, #242424);
    border-color: var(--border-primary, #3f3f3f);
}

/* ========================================
   Fullscreen Modal (with app-frame shell)
   ======================================== */
.app-frame-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.app-frame-fullscreen.is-open {
    opacity: 1;
    visibility: visible;
}

.app-frame-fullscreen__backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay, rgba(0, 0, 0, 0.6));
    backdrop-filter: blur(4px);
}

.app-frame-fullscreen__container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    max-height: calc(100vh - 48px);
    transform: scale(0.96) translateY(20px);
    transition: transform 0.3s ease;
}

.app-frame-fullscreen.is-open .app-frame-fullscreen__container {
    transform: scale(1) translateY(0);
}

/* App frame inside fullscreen gets special styling */
.app-frame-fullscreen .app-frame {
    width: 100%;
    height: 100%;
    max-width: none;
    --frame-radius: 16px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.3);
}

/* Close button floats outside the app-frame */
.app-frame-fullscreen__close {
    position: absolute;
    top: -12px;
    right: -12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-primary, #e5e5e5);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #525252);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.15s ease;
    z-index: 10;
}

.app-frame-fullscreen__close:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3);
}

.app-frame-fullscreen__close svg {
    width: 16px;
    height: 16px;
}

/* Dark theme */
[data-theme="dark"] .app-frame-fullscreen__backdrop {
    background: rgba(0, 0, 0, 0.75);
}

[data-theme="dark"] .app-frame-fullscreen__close {
    background: var(--bg-tertiary, #242424);
    border-color: var(--border-primary, #3f3f3f);
}

[data-theme="dark"] .app-frame-fullscreen__close:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #ffffff;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .app-frame__interaction-content {
        padding: 20px 24px;
    }

    .app-frame__interaction-icon {
        width: 40px;
        height: 40px;
    }

    .app-frame__interaction-text {
        font-size: 13px;
    }

    .app-frame-fullscreen {
        padding: 0;
    }

    .app-frame-fullscreen__container {
        max-height: 100vh;
    }

    .app-frame-fullscreen .app-frame {
        --frame-radius: 0;
        border: none;
    }

    .app-frame-fullscreen__close {
        top: 8px;
        right: 8px;
        padding: 8px;
    }

    .app-frame-fullscreen__close span {
        display: none;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .app-frame__interaction-icon {
        animation: none;
    }

    .app-frame-fullscreen,
    .app-frame-fullscreen__container,
    .app-frame__interaction-overlay {
        transition: none;
    }
}
