/* Telegram Mini App Styles - Simplified */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
    padding: 16px;
    min-height: 100vh;
    line-height: 1.4;
}

.loading,
.no-barriers {
    text-align: center;
    padding: 40px 20px;
    color: var(--tg-theme-hint-color, #999999);
}

.error {
    background: #ff4444;
    color: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    text-align: center;
}

.barriers-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.barrier-card {
    background: var(--tg-theme-secondary-bg-color, #f8f9fa);
    border: 1px solid var(--tg-theme-section-separator-color, #e5e5e5);
    border-radius: 16px;
    padding: 20px;
    transition: transform 0.2s ease;
    cursor: pointer;
    position: relative;
}

.barrier-card:active {
    transform: scale(0.98);
}

.open-button {
    background: var(--tg-theme-button-color, #007aff);
    color: var(--tg-theme-button-text-color, #ffffff);
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.1s ease, background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.open-button:active {
    transform: scale(0.95);
}

.open-button:disabled,
.open-button.disabled {
    background: #999999;
    color: #ffffff;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Camera frame styles */
.camera-frame {
    position: relative;
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--tg-theme-section-separator-color, #e5e5e5);
    width: 100%;
    /* Fallback for browsers without aspect-ratio support */
    height: 200px;
    /* Reserve space with 16:9 aspect ratio to prevent layout shift */
    aspect-ratio: 16 / 9;
    /* Loading placeholder */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Reset height when aspect-ratio is supported */
@supports (aspect-ratio: 16 / 9) {
    .camera-frame {
        height: auto;
    }
}

.camera-frame::before {
    content: "📹";
    font-size: 24px;
    opacity: 0.5;
    position: absolute;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.camera-frame.loaded::before {
    opacity: 0;
}

.barrier-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    /* Smooth loading transition */
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 2;
}

.barrier-image.loaded {
    opacity: 1;
}

.barrier-image.streaming {
    border: 2px solid #ff4444;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}



.frame-warning {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 193, 7, 0.9);
    color: #000;
    padding: 4px 6px;
    border-radius: 50%;
    font-size: 14px;
    z-index: 3;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.9; }
    50% { opacity: 0.6; }
    100% { opacity: 0.9; }
}



@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .barriers-grid {
        grid-template-columns: 1fr;
    }

    .barrier-card {
        padding: 16px;
    }

    .camera-frame {
        margin-bottom: 12px;
        border-radius: 8px;
    }

    .barrier-image {
        border-radius: 8px;
    }

    .frame-warning {
        font-size: 12px;
        padding: 3px 5px;
    }
}