/* ==========================================================================
   Virtual Bouncy Balls Tool - Zhween Brand Styling
   ========================================================================== */

/* Override min-height from base template to prevent gap */
.tool-page-wrapper:has(.vbb-container) {
    min-height: 0 !important;
}

.tool-content-area:has(.vbb-container) {
    min-height: 0 !important;
}

.vbb-container {
        --primary-color: #15aebf;
        --primary-light: #4ecdc4;
        --primary-dark: #0e9bb2;
        --secondary-color: #ff6b35;
        --secondary-light: #ff8c5a;
        --accent-color: #ffd93d;
        --success-color: #00b894;
        --danger-color: #e17055;
        --warning-color: #fdcb6e;
        --white: #ffffff;
        --gray-100: #f1f3f4;
        --gray-200: #e9ecef;
        --gray-300: #dee2e6;
        --gray-400: #ced4da;
        --gray-500: #adb5bd;
        --gray-600: #6c757d;
        --gray-700: #495057;
        --gray-800: #343a40;
        --text-primary: #2d3748;
        --text-secondary: #4a5568;
        --radius-lg: 0.75rem;
        --radius-xl: 1rem;
        --radius-2xl: 1.25rem;
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
        --bg-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    }

    .vbb-wrapper {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 95vh;
        padding: 0;
        gap: 0;
        background: #1a8a9d;
        align-items: center;
        overflow: hidden;
        position: relative;
    }

    .vbb-game-container {
        position: relative;
        width: 100%;
        height: 100%;
        flex: 1;
        background: #1a8a9d;
        overflow: hidden;
        cursor: crosshair;
        min-height: 400px;
    }

    /* Top overlay - controls, mic status and volume */
    .vbb-top-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        z-index: 100;
        pointer-events: none;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
    }

    .vbb-top-overlay > * {
        pointer-events: auto;
    }

    .vbb-top-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .vbb-mic-status {
        padding: 0.5rem 1rem;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-radius: var(--radius-lg);
        font-size: 0.8125rem;
        font-weight: 600;
        transition: all 0.3s ease;
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--white);
        white-space: nowrap;
    }

    .vbb-mic-status.active {
        background: rgba(0, 184, 148, 0.4);
        border-color: var(--success-color);
        color: #7dffcc;
    }

    .vbb-mic-status.inactive {
        background: rgba(225, 112, 85, 0.4);
        border-color: var(--danger-color);
        color: #ffb8a8;
    }

    .vbb-volume-row {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
    }

    .vbb-volume-meter {
        flex: 1;
        height: 8px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-full);
        overflow: hidden;
    }

    .vbb-volume-bar {
        height: 100%;
        width: 0%;
        background: var(--bg-gradient);
        border-radius: var(--radius-full);
        transition: width 0.05s linear;
    }

    .vbb-watermark {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 200px;
        opacity: 0.08;
        pointer-events: none;
        z-index: 1;
        filter: brightness(2);
    }

    .vbb-ball {
        position: absolute;
        border-radius: 50%;
        cursor: pointer;
        z-index: 10;
        will-change: left, top, transform;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    }

    .vbb-ball:hover {
        filter: brightness(1.1);
        transform: scale(1.1);
    }

    .vbb-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.375rem;
    }

    .vbb-btn {
        padding: 0.5rem 0.75rem;
        border-radius: var(--radius-full);
        font-weight: 600;
        font-size: 0.8125rem;
        transition: all 0.2s ease;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        cursor: pointer;
    }

    .vbb-btn-secondary {
        background: rgba(255, 255, 255, 0.2);
        color: var(--white);
    }

    .vbb-btn-secondary:hover {
        background: rgba(255, 255, 255, 0.35);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        color: var(--white);
    }

    .vbb-btn-add {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-light);
    }

    .vbb-btn-add:hover {
        background: var(--primary-dark);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(21, 174, 191, 0.4);
        color: white;
    }

    .vbb-btn-mic-off {
        background: var(--danger-color);
        color: white;
        border-color: #ff8a75;
    }

    .vbb-btn-mic-off:hover {
        background: #c9604a;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(225, 112, 85, 0.4);
        color: white;
    }

    .vbb-btn-mic-on {
        background: var(--success-color);
        color: white;
        border-color: #4dd4b4;
    }

    .vbb-btn-mic-on:hover {
        background: #009d7a;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 184, 148, 0.4);
        color: white;
    }

    .vbb-stats {
        display: flex;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    .vbb-stat-card {
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 0.25rem 0.625rem;
        border-radius: var(--radius-lg);
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        gap: 0.375rem;
    }

    .vbb-stat-value {
        font-size: 0.875rem;
        font-weight: 700;
        color: var(--white);
    }

    .vbb-stat-label {
        font-size: 0.625rem;
        color: rgba(255, 255, 255, 0.6);
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    @keyframes vbb-ball-create {
        0% { transform: scale(0); opacity: 0; }
        100% { transform: scale(1); opacity: 1; }
    }

    .vbb-ball.created {
        animation: vbb-ball-create 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    @keyframes vbb-ball-remove {
        0% { transform: scale(1); opacity: 1; }
        100% { transform: scale(0); opacity: 0; }
    }

    .vbb-ball.removing {
        animation: vbb-ball-remove 0.3s ease-in forwards;
    }

    [dir="rtl"] .vbb-wrapper {
        direction: rtl;
    }

    /* Mobile styles - compact layout */
    @media (max-width: 600px) {
        .vbb-wrapper {
            padding: 0;
            min-height: 85vh;
        }

        .vbb-game-container {
            min-height: 80vh;
            max-height: none;
            height: 100%;
        }

        .vbb-top-overlay {
            padding: 0.5rem;
            gap: 0.35rem;
        }

        .vbb-top-row {
            gap: 0.35rem;
            flex-direction: column;
            align-items: center;
        }

        /* Hide mic status text on mobile - keep it minimal */
        .vbb-mic-status {
            font-size: 0.625rem;
            padding: 0.25rem 0.5rem;
            display: none;
        }

        /* Two-row button layout */
        .vbb-controls {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 0.3rem;
            width: 100%;
            max-width: 320px;
        }

        /* First row: Enable spans 2 columns, +10 spans 1 */
        .vbb-btn#vbbMicBtn {
            grid-column: span 2;
        }

        /* Smaller buttons with icon + text on mobile */
        .vbb-btn {
            padding: 0.4rem 0.5rem;
            font-size: 0.7rem;
            min-width: auto;
            border-radius: 0.5rem;
            gap: 0.25rem;
            justify-content: center;
        }

        /* Show both icon and text on mobile */
        .vbb-btn span:first-child { display: inline !important; }
        .vbb-btn span:nth-child(2) { display: inline !important; }
        .vbb-btn span { color: inherit !important; visibility: visible !important; }

        /* Volume row - single line */
        .vbb-volume-row {
            flex-wrap: nowrap;
            gap: 0.5rem;
            width: 100%;
            max-width: 320px;
        }

        .vbb-volume-meter {
            height: 6px;
            min-width: 80px;
        }

        .vbb-stats {
            gap: 0.375rem;
        }

        .vbb-stat-card {
            padding: 0.2rem 0.4rem;
            border-radius: 0.375rem;
        }

        .vbb-stat-value { font-size: 0.7rem; }
        .vbb-stat-label { font-size: 0.5rem; }
    }

    /* Extra small screens */
    @media (max-width: 400px) {
        .vbb-wrapper {
            min-height: 80vh;
        }

        .vbb-game-container {
            min-height: 75vh;
            max-height: none;
        }

        .vbb-top-overlay { padding: 0.375rem; }

        .vbb-controls {
            max-width: 280px;
        }

        .vbb-btn {
            padding: 0.35rem 0.4rem;
            font-size: 0.625rem;
        }

        .vbb-volume-row {
            max-width: 280px;
        }

        .vbb-volume-meter {
            min-width: 60px;
        }

        .vbb-stat-card {
            padding: 0.15rem 0.35rem;
        }

        .vbb-stat-value { font-size: 0.65rem; }
    }

    /* Fullscreen mode - tool-page-wrapper is the fullscreen element */
    .tool-page-wrapper:fullscreen .vbb-wrapper,
    .tool-page-wrapper:-webkit-full-screen .vbb-wrapper,
    .tool-page-wrapper:-moz-full-screen .vbb-wrapper {
        min-height: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
    }

    .tool-page-wrapper:fullscreen .vbb-game-container,
    .tool-page-wrapper:-webkit-full-screen .vbb-game-container,
    .tool-page-wrapper:-moz-full-screen .vbb-game-container {
        min-height: 100% !important;
        max-height: 100% !important;
        height: 100% !important;
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    .tool-page-wrapper:fullscreen .tool-content-area,
    .tool-page-wrapper:-webkit-full-screen .tool-content-area,
    .tool-page-wrapper:-moz-full-screen .tool-content-area {
        min-height: 100% !important;
        height: 100% !important;
        flex: 1 1 100% !important;
    }

    @media (prefers-reduced-motion: reduce) {
        .vbb-ball.created, .vbb-ball.removing { animation: none; }
    }
