/* AI Live Simulator - Style Sheet */

:root {
    --primary-color: #fe2c55; /* Douyin Pink */
    --secondary-color: #25f4ee; /* Douyin Cyan */
    --bg-dark-opacity: rgba(0, 0, 0, 0.4);
    --bg-light-opacity: rgba(255, 255, 255, 0.15);
    --glass-blur: blur(16px);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    background-color: #0b0c10;
    font-family: var(--font-main);
    color: #ffffff;
    overflow: hidden;
}

/* Device wrapper for desktop framing, responsive full-bleed for mobile */
.app-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (min-width: 480px) {
    .app-wrapper {
        background: radial-gradient(circle at top left, #1f1c2c, #08070d);
    }
    .live-container {
        width: 410px;
        height: 840px;
        border-radius: 40px;
        border: 12px solid #2a2d35;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
        position: relative;
        overflow: hidden;
    }
}

@media (max-width: 479px) {
    .live-container {
        width: 100%;
        height: 100%;
        position: relative;
        overflow: hidden;
    }
}

/* Background video/gradient styling */
.video-bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.webcam-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror camera */
    transition: opacity 0.5s ease;
}

.video-fallback-gradient {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #180d2b 0%, #0d0614 50%, #040108 100%);
    position: relative;
    overflow: hidden;
}

.fallback-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(254, 44, 85, 0.15) 0%, rgba(37, 244, 238, 0.05) 50%, transparent 100%);
    animation: rotateGlow 20s linear infinite;
}

@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Canvas Overlay for floatings */
.animation-overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Live UI Container Overlay */
.live-ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    padding-top: calc(env(safe-area-inset-top) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
    pointer-events: none; /* Let clicks pass through to sub-elements */
}

/* Let header and footer receive pointer events */
.live-header, .middle-arena, .live-footer, .settings-card, .gift-selection-panel {
    pointer-events: auto;
}

/* TOP HEADER */
.live-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.host-profile-card {
    background-color: var(--bg-dark-opacity);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--bg-light-opacity);
    padding: 3px 12px 3px 4px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.host-avatar-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 1.5px solid var(--primary-color);
}

.host-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.host-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.host-name {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.like-count {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.7);
}

.follow-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.follow-btn:active {
    transform: scale(0.85);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.contributor-list {
    display: flex;
    align-items: center;
}

.viewer-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.6);
    margin-right: -8px;
    object-fit: cover;
}

.viewer-count-badge {
    background-color: var(--bg-dark-opacity);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--bg-light-opacity);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

/* MIDDLE ARENA */
.middle-arena {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
}

/* PK split screens */
.pk-split-container {
    width: 100%;
    height: 220px;
    display: flex;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-color: #000;
}

.pk-video-box {
    width: 50%;
    height: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.self-video {
    background-color: #1a1a24;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.opponent-video {
    background: linear-gradient(135deg, #110e20 0%, #17112d 100%);
}

.pk-user-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.opponent-avatar-wrapper {
    position: relative;
    width: 70px;
    height: 70px;
}

.opponent-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--secondary-color);
}

.connecting-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 2px dashed var(--secondary-color);
    animation: rotateRing 8s linear infinite;
}

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

.opponent-name-tag {
    position: absolute;
    bottom: 12px;
    background-color: var(--secondary-color);
    color: #000;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(37, 244, 238, 0.4);
}

/* PK Progress status bar */
.pk-status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 12px;
    background-color: var(--secondary-color); /* opponent score bar (blue) */
    display: flex;
}

.pk-progress {
    height: 100%;
    background-color: var(--primary-color); /* self score bar (red) */
    transition: width 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.pk-score-left, .pk-score-right {
    position: absolute;
    top: -18px;
    font-size: 10px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 1px 5px;
    border-radius: 3px;
}

.pk-score-left {
    left: 8px;
    color: var(--primary-color);
}

.pk-score-right {
    right: 8px;
    color: var(--secondary-color);
}

/* Slide Banner for Large Gifts */
.gift-banner-overlay {
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
    pointer-events: none;
}

.gift-slide-card {
    background: linear-gradient(90deg, rgba(254, 44, 85, 0.85) 0%, rgba(254, 44, 85, 0) 100%);
    backdrop-filter: blur(4px);
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
    padding: 4px 20px 4px 6px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    align-self: flex-start;
    animation: slideInGift 4s ease-in-out forwards;
    transform: translateX(-100%);
}

@keyframes slideInGift {
    0% { transform: translateX(-100%); opacity: 0; }
    8% { transform: translateX(0); opacity: 1; }
    90% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(-100%); opacity: 0; }
}

.gift-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #ffffff;
    object-fit: cover;
}

.gift-announce-text {
    font-size: 11px;
    display: flex;
    flex-direction: column;
}

.gift-username {
    font-weight: 600;
    color: #fff;
}

.gift-action-desc {
    color: #ffe81f;
    font-weight: 700;
}

.gift-mini-icon {
    font-size: 20px;
    animation: popIcon 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite alternate;
}

@keyframes popIcon {
    from { transform: scale(0.8) rotate(-5deg); }
    to { transform: scale(1.2) rotate(10deg); }
}

/* BOTTOM AREA */
.live-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* Subtitle for host voice input */
.speech-subtitle-box {
    background-color: rgba(254, 44, 85, 0.85);
    backdrop-filter: var(--glass-blur);
    padding: 6px 12px;
    border-radius: 12px;
    align-self: flex-start;
    font-size: 12px;
    max-width: 90%;
    box-shadow: 0 4px 15px rgba(254, 44, 85, 0.3);
    animation: fadeIn 0.3s ease;
}

.subtitle-label {
    font-weight: bold;
    color: #fff;
    margin-right: 4px;
}

.subtitle-text {
    color: #ffe600;
    font-weight: 600;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Comment section list view */
.comment-scroll-area {
    width: 100%;
    max-height: 180px;
    height: 180px;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar Firefox */
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 80%, rgba(0,0,0,0) 100%);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 80%, rgba(0,0,0,0) 100%);
}

.comment-scroll-area::-webkit-scrollbar {
    display: none; /* Hide Webkit scrollbar */
}

.comment-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 20px;
}

.comment-item {
    background-color: rgba(0, 0, 0, 0.35);
    backdrop-filter: var(--glass-blur);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 16px;
    align-self: flex-start;
    max-width: 90%;
    word-break: break-all;
    animation: slideInComment 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideInComment {
    from { opacity: 0; transform: translateY(12px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.comment-item.system-msg {
    background-color: rgba(255, 187, 0, 0.2);
    border: 0.5px solid rgba(255, 187, 0, 0.3);
}

.comment-item.system-msg .comment-content {
    color: #ffbb00;
    font-weight: 500;
}

/* Level Badges style */
.level-badge {
    display: inline-block;
    padding: 0.5px 5px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 800;
    margin-right: 6px;
    color: #ffffff;
    font-family: var(--font-heading);
}

.level-blue { background: linear-gradient(90deg, #37a2f5 0%, #1f6ff0 100%); }
.level-green { background: linear-gradient(90deg, #3bd16f 0%, #0ebb4d 100%); }
.level-orange { background: linear-gradient(90deg, #f78d3b 0%, #eb5b12 100%); }
.level-red { background: linear-gradient(90deg, #f73b3b 0%, #d41111 100%); }

.comment-user {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-right: 6px;
}

.comment-content {
    color: #ffffff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.host-text-form {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
}

.host-text-form input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border-radius: 19px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background-color: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 13px;
    outline: none;
}

.host-text-form input::placeholder {
    color: rgba(255, 255, 255, 0.48);
}

.host-text-form input:focus {
    border-color: rgba(37, 244, 238, 0.7);
}

.host-text-form button {
    height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: 19px;
    color: #fff;
    background: linear-gradient(90deg, var(--primary-color) 0%, #ff5275 100%);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* Tool Buttons / Actions panel */
.bottom-right-panel {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.action-circle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--bg-dark-opacity);
    backdrop-filter: var(--glass-blur);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, background-color 0.2s;
}

.action-circle-btn:active {
    transform: scale(0.9);
}

.voice-btn {
    background-color: rgba(37, 244, 238, 0.2);
    border-color: rgba(37, 244, 238, 0.4);
}

.voice-status-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #3bd16f;
    box-shadow: 0 0 10px #3bd16f;
}

.pulse-animation {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.4; }
    100% { transform: scale(0.9); opacity: 1; }
}

.gift-btn {
    background-color: rgba(254, 44, 85, 0.2);
    border-color: rgba(254, 44, 85, 0.4);
}

.like-trigger-btn {
    background: linear-gradient(135deg, rgba(254, 44, 85, 0.8) 0%, rgba(254, 114, 44, 0.8) 100%);
    border-color: rgba(255, 255, 255, 0.3);
}

/* SETTINGS MODAL DIALOGUE */
.settings-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    transition: opacity 0.3s ease;
}

.settings-card {
    width: 100%;
    background: rgba(18, 19, 26, 0.92);
    backdrop-filter: var(--glass-blur);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 75%;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 10px;
}

.settings-header h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: bold;
    color: var(--secondary-color);
}

.close-modal-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.close-modal-btn:hover {
    opacity: 1;
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-section {
    background-color: rgba(255, 255, 255, 0.04);
    border: 0.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 10px;
    display: block;
    letter-spacing: 0.5px;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.settings-row:last-child {
    margin-bottom: 0;
}

.hint-text {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.45);
    display: block;
    line-height: 14px;
    margin-top: 4px;
}

/* Form controls styling */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider-round {
    background-color: var(--primary-color);
}

input:checked + .slider-round:before {
    transform: translateX(20px);
}

.styled-select {
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    outline: none;
}

.styled-input {
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    width: 70px;
    text-align: center;
    outline: none;
}

.styled-range {
    width: 120px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.styled-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.primary-action-btn {
    width: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, #ff5275 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 5px;
    transition: opacity 0.2s;
}

.primary-action-btn:active {
    opacity: 0.8;
}

.btn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 5px;
}

.sim-event-btn {
    background-color: rgba(255, 255, 255, 0.08);
    color: white;
    border: 0.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 8px 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sim-event-btn:active {
    background-color: rgba(255, 255, 255, 0.18);
}

/* GIFT PANEL SELECTION */
.gift-selection-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(18, 19, 26, 0.95);
    backdrop-filter: var(--glass-blur);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
    padding: 16px;
    animation: slideUp 0.25s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.gift-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.gift-panel-header h4 {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
}

.panel-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
}

.gift-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.gift-item-card {
    background-color: rgba(255, 255, 255, 0.04);
    border: 0.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.gift-item-card:active {
    background-color: rgba(254, 44, 85, 0.15);
    border-color: var(--primary-color);
}

.gift-icon-container {
    font-size: 24px;
}

.gift-name {
    font-size: 11px;
    font-weight: 600;
}

.gift-price {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.5);
}
