/* ==========================================================================
   Photo Booth.app — macOS Photo Booth Style & Real-Time Camera Effects
   ========================================================================== */

#photobooth-window {
    width: 820px;
    height: 590px;
    min-width: 680px;
    min-height: 480px;
    border-radius: 12px;
    overflow: hidden;
    background: #1c1c1e;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.pb-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100% - 38px);
    background: #141416;
    overflow: hidden;
}

/* Viewfinder Area */
.pb-viewfinder-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    overflow: hidden;
    margin: 8px 12px 4px 12px;
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#pb-video, #pb-preview-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror camera preview like a real mirror */
    transition: filter 0.2s ease;
}

#pb-canvas {
    display: none;
}

/* Flash Animation */
.pb-flash {
    position: absolute;
    inset: 0;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.05s ease-out;
}

.pb-flash.flashing {
    opacity: 1;
    transition: none;
}

/* Countdown Overlay */
.pb-countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 84px;
    font-weight: 800;
    color: #ff3b30;
    text-shadow: 0 4px 20px rgba(0,0,0,0.8), 0 0 30px rgba(255, 59, 48, 0.6);
    opacity: 0;
    pointer-events: none;
    z-index: 45;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
}

.pb-countdown.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Viewfinder Simulation / Warning Overlay */
.pb-sim-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    color: #00e676;
    z-index: 10;
}

.pb-sim-badge i {
    font-size: 8px;
    animation: pbDotBlink 1.5s infinite;
}

@keyframes pbDotBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Controls Bar */
.pb-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px;
    background: #1c1c1e;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pb-modes {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px;
    border-radius: 8px;
}

.pb-mode-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pb-mode-btn.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Big Red Shutter Button */
.pb-shutter-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pb-shutter-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ff453a, #d32f2f);
    border: 3px solid #ffffff;
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.5), inset 0 -2px 5px rgba(0,0,0,0.3);
    cursor: pointer;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    transition: transform 0.1s ease, filter 0.15s ease;
}

.pb-shutter-btn:hover {
    transform: scale(1.06);
    filter: brightness(1.1);
}

.pb-shutter-btn:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

/* Effects Drawer Toggle Button */
.pb-effects-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pb-effects-toggle:hover, .pb-effects-toggle.active {
    background: #007aff;
    border-color: #007aff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

/* Effects Picker Strip */
.pb-effects-grid {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px 14px;
    background: #141416;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pb-effects-grid.open {
    display: grid;
}

.pb-effect-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 6px 4px;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pb-effect-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.pb-effect-card.active {
    border-color: #007aff;
    background: rgba(0, 122, 255, 0.15);
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.3);
}

.pb-effect-thumb {
    width: 44px;
    height: 30px;
    border-radius: 4px;
    background: linear-gradient(135deg, #3b82f6, #ec4899);
}

.pb-effect-name {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* Bottom Photos Tray */
.pb-tray-container {
    height: 84px;
    background: #0e0e10;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
    overflow-x: auto;
}

.pb-tray-empty {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
    width: 100%;
    text-align: center;
}

.pb-thumb-item {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pb-thumb-item:hover {
    transform: scale(1.05);
    border-color: #007aff;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.pb-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Photo Viewer & Save Modal */
.pb-modal {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.pb-modal.open {
    display: flex;
}

.pb-modal-img {
    max-width: 85%;
    max-height: 70%;
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.15);
    margin-bottom: 16px;
}

.pb-modal-actions {
    display: flex;
    gap: 10px;
}

.pb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.pb-btn-save {
    background: #007aff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
}

.pb-btn-save:hover {
    background: #0062cc;
    transform: translateY(-1px);
}

.pb-btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.pb-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.pb-btn-delete {
    background: rgba(255, 59, 48, 0.2);
    color: #ff453a;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.pb-btn-delete:hover {
    background: #ff453a;
    color: #fff;
}
