/* css/biliard.css */

.biliard-body {
    background: radial-gradient(circle at center, #f8f9fa 0%, #dcdde1 100%);
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.biliard-body::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(rgba(0,0,0,0.03) 1.5px, transparent 1.5px);
    background-size: 30px 30px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

body.dark-theme.biliard-body {
    background: radial-gradient(circle at center, #1a2a3a 0%, #0d151d 100%);
}

body.dark-theme.biliard-body::before {
    background-image: radial-gradient(rgba(255,255,255,0.03) 1.5px, transparent 1.5px);
}

.biliard-wrapper {
    position: relative;
    z-index: 5;
    padding-top: 130px;
}

/* Glass panels for UI - Dynamic Theme Support */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, color 0.4s ease;
}

body.dark-theme .glass-panel {
    background: rgba(13, 21, 29, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Text and Input Overrides for Dynamic Theme (Global for Biliard) */
.biliard-wrapper .text-white {
    color: #2c3e50 !important;
    transition: color 0.4s ease;
}
.biliard-wrapper .text-white-50 {
    color: rgba(44, 62, 80, 0.7) !important;
    transition: color 0.4s ease;
}

body.dark-theme .biliard-wrapper .text-white {
    color: #ffffff !important;
}
body.dark-theme .biliard-wrapper .text-white-50 {
    color: rgba(255, 255, 255, 0.5) !important;
}

.biliard-wrapper .btn-outline-light {
    color: #2c3e50 !important;
    border-color: #2c3e50 !important;
    transition: all 0.4s ease;
}
.biliard-wrapper .btn-outline-light.active,
.biliard-wrapper .btn-outline-light:hover {
    background-color: #2c3e50 !important;
    color: #ffffff !important;
}

body.dark-theme .biliard-wrapper .btn-outline-light {
    color: #ffffff !important;
    border-color: #ffffff !important;
}
body.dark-theme .biliard-wrapper .btn-outline-light.active,
body.dark-theme .biliard-wrapper .btn-outline-light:hover {
    background-color: #ffffff !important;
    color: #2c3e50 !important;
}

/* Specific Game UI Contrast Fixes */
#turn-indicator {
    transition: color 0.4s ease;
}

body.dark-theme #turn-indicator.text-white-50 {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Labels below the table (Efect/Putere) */
.strike-label, .power-text {
    color: #2c3e50;
    transition: color 0.4s ease;
}

body.dark-theme .strike-label, 
body.dark-theme .power-text {
    color: #ffffff;
    opacity: 0.7;
}

.power-bar-container {
    background: rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(44, 62, 80, 0.2);
    transition: background 0.4s ease, border-color 0.4s ease;
}

body.dark-theme .power-bar-container {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#setup-screen .form-select {
    background-color: #ffffff !important;
    color: #2c3e50 !important;
    border-color: #d1d9e6 !important;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

body.dark-theme #setup-screen .form-select {
    background-color: #212529 !important;
    color: #ffffff !important;
    border-color: #495057 !important;
}

#online-lobby .alert-info {
    background-color: rgba(13, 202, 240, 0.1) !important;
    color: #0c5460 !important;
    border-color: rgba(13, 202, 240, 0.2) !important;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

body.dark-theme #online-lobby .alert-info {
    background-color: rgba(13, 202, 240, 0.2) !important;
    color: #ffffff !important;
    border-color: rgba(13, 202, 240, 0.3) !important;
}

/* Player Info Badges */
.ball-type-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #2c3e50;
    background-color: transparent;
    transition: border-color 0.4s ease;
}

body.dark-theme .ball-type-indicator {
    border-color: #ffffff;
}

.ball-solid {
    background-color: #ff3333;
}

.ball-stripe {
    background: repeating-linear-gradient(0deg,
            white,
            white 30%,
            #3333ff 30%,
            #3333ff 70%,
            white 70%,
            white 100%);
}

.ball-eight {
    background-color: black;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.ball-eight::after {
    content: "8";
}

.ball-unknown {
    background-color: rgba(255, 255, 255, 0.2);
    border-style: dashed;
}

/* Dynamic Power Bar */
.power-bar-container {
    height: 40px;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    touch-action: none;
}

.power-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 100% !important;
    background: linear-gradient(to right, #4ade80, #facc15, #ef4444);
    transition: width 0.1s ease-out;
}

/* Biliard Table Styling */
.table-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* Wooden Outer Cushion */
.biliard-cushion-outer {
    position: relative;
    width: 100%;
    background: linear-gradient(45deg, #3d1c04, #572a08, #3d1c04);
    border-radius: 30px;
    padding: 30px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9), 0 15px 30px rgba(0, 0, 0, 0.7);
    border: 4px solid #1c0a00;
}

body.dark-theme .biliard-cushion-outer {
    background: linear-gradient(45deg, #1c1c1c, #333333, #1c1c1c);
    border: 4px solid #000000;
}

@media (max-width: 768px) {
    .biliard-cushion-outer {
        padding: 15px;
        border-radius: 20px;
    }
}

/* Red inner rails */
.biliard-cushion-inner {
    width: 100%;
    height: auto;
    background: linear-gradient(to bottom, #751515, #9c1f1f);
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 1);
    position: relative;
    display: flex;
    padding: 20px;
    /* Thickness of the red rails */
}

body.dark-theme .biliard-cushion-inner {
    background: linear-gradient(to bottom, #333333, #4d4d4d);
}

/* The Canvas itself (Blue Cloth) */
.biliard-cloth {
    aspect-ratio: 2 / 1;
    background-color: #2a7cc7;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.35) 100%);
    border-radius: 4px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6);
}

body.dark-theme .biliard-cloth {
    background-color: #1a4f82;
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.6) 100%);
}

#biliard-canvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
    background-color: transparent;
}

/* Pockets overlays - making them look realistic */
.pocket {
    position: absolute;
    /* Deep black hole gradient, gets fully black in the center */
    background: radial-gradient(circle at center, #000 30%, #0a0a0a 60%, rgba(26, 26, 26, 0.9) 100%);
    box-shadow: inset 0 8px 15px rgba(0, 0, 0, 1), 0 0 5px rgba(0, 0, 0, 0.8);
    /* Set pockets below the canvas (z-index 5) so balls shrink into them visibly */
    z-index: 2;
    pointer-events: none;
    border: 2px solid #222;
    /* Dark plastic or rubber rim */
}

/* Corner pockets */
.p-corner {
    width: 45px;
    height: 45px;
    border-radius: 50%;
}

.p-side {
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.p-tl {
    top: -5px;
    left: -5px;
    transform: translate(-50%, -50%);
}

.p-tr {
    top: -5px;
    right: -5px;
    transform: translate(50%, -50%);
}

.p-bl {
    bottom: -5px;
    left: -5px;
    transform: translate(-50%, 50%);
}

.p-br {
    bottom: -5px;
    right: -5px;
    transform: translate(50%, 50%);
}

.p-tc {
    top: -8px;
    left: 50%;
    transform: translate(-50%, -50%);
}

.p-bc {
    bottom: -8px;
    left: 50%;
    transform: translate(-50%, 50%);
}

.target-pocket {
    box-shadow: 0 0 15px #00ffff, inset 0 0 15px #00ffff !important;
    border: 2px solid #00ffff !important;
    animation: pocketPulse 1.5s infinite alternate !important;
    z-index: 10 !important;
    /* Bring above canvas if needed */
}

@keyframes pocketPulse {
    from {
        box-shadow: 0 0 10px #00ffff, inset 0 0 10px #00ffff;
        transform: translate(var(--tw-translate-x, -50%), var(--tw-translate-y, 50%)) scale(1);
    }

    to {
        box-shadow: 0 0 25px #00ffff, inset 0 0 20px #00ffff;
        transform: translate(var(--tw-translate-x, -50%), var(--tw-translate-y, 50%)) scale(1.1);
    }
}

/* Specific transforms for pulsing elements to maintain position */
.p-tl.target-pocket {
    --tw-translate-x: -50%;
    --tw-translate-y: -50%;
}

.p-tr.target-pocket {
    --tw-translate-x: 50%;
    --tw-translate-y: -50%;
}

.p-bl.target-pocket {
    --tw-translate-x: -50%;
    --tw-translate-y: 50%;
}

.p-br.target-pocket {
    --tw-translate-x: 50%;
    --tw-translate-y: 50%;
}

.p-tc.target-pocket {
    --tw-translate-x: -50%;
    --tw-translate-y: -50%;
}

.p-bc.target-pocket {
    --tw-translate-x: -50%;
    --tw-translate-y: 50%;
}

@media (max-width: 768px) {
    .p-corner {
        width: 22px;
        height: 22px;
        border-width: 1px;
    }

    .p-side {
        width: 18px;
        height: 18px;
        border-width: 1px;
    }

    .p-tl {
        top: -3px;
        left: -3px;
        transform: translate(-50%, -50%);
    }

    .p-tr {
        top: -3px;
        right: -3px;
        transform: translate(50%, -50%);
    }

    .p-bl {
        bottom: -3px;
        left: -3px;
        transform: translate(-50%, 50%);
    }

    .p-br {
        bottom: -3px;
        right: -3px;
        transform: translate(50%, 50%);
    }

    .p-tc {
        top: -4px;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .p-bc {
        bottom: -4px;
        left: 50%;
        transform: translate(-50%, 50%);
    }

    .potted-ui-ball {
        width: 16px !important;
        height: 16px !important;
    }

    .potted-ui-ball span {
        font-size: 0.4rem !important;
        padding: 0 2px !important;
    }
}

/* Potted UI Balls */
.potted-ui-ball {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.new-pot {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.4);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Strike Point UI */
.strike-anchor {
    position: relative;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #fff, #ddd 60%, #999);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    cursor: crosshair;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    touch-action: none;
}

.strike-point {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border: 1px solid white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.8);
}

.strike-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 5px;
    user-select: none;
    -webkit-user-select: none;
}