@import './utopia.css';
@import './theme.css';

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

:root[data-theme="light"] ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

:root[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

body {
    background-color: var(--body-bg);
    color: var(--text-primary);
    font-family: Arial, sans-serif;
}

body.modal-open {
    overflow: hidden;
    padding-right: 8px;
}

.main-content {
    max-width: 100%;
    padding: var(--space-m);
    min-height: 100dvh;
    background-color: var(--body-bg);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.live-stream {
    background-color: var(--main-bg);
    padding: var(--space-m);
    border-radius: var(--radius-xs);
    gap: var(--space-m);
    width: 100%;
    display: grid;
    flex-grow: 1;
    grid-template-columns: 1fr minmax(300px, 25%);
    border: 1px solid var(--border-color);
}

@media (max-width: 1024px) {
    .live-stream {
        grid-template-columns: 1fr;
    }
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--radius-2xs);
    background-color: var(--main-bg);
    position: relative;
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: var(--red-color);
    border-radius: 50%;
    position: relative;
}

.live-dot::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    top: -4px;
    left: -4px;
    position: absolute;
    background-color: var(--red-color);
    border-radius: 50%;
    opacity: 0.5;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.25;
    }

    100% {
        opacity: 0.5;
    }
}

.live-text {
    font-size: var(--step--1);
    text-transform: uppercase;
}

.viewer-count {
    font-size: var(--step-0);
}

.user__count {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
}

.stream-actions {
    display: flex;
    gap: var(--space-s);
}

.action-button {
    background: var(--light-bg);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-2xs);
    border-radius: var(--radius-2xs);
    padding: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.action-button svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.action-button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--light-bg-hover);
    border-radius: var(--radius-2xs);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.2s ease-in-out;
}

.action-button:hover::after {
    opacity: 1;
}

.stream-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-m);
    justify-content: space-between;
    border: 1px solid var(--border-color-dark);
    background-color: var(--sidebar-bg);
    border-radius: var(--radius-xs);
    padding: var(--space-m);
}

.stream-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-xs);
    background: var(--sidebar-bg);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.stream-player video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.stream-title {
    color: var(--accent-color);
}

:root[data-theme="light"] .stream-title {
    color: var(--green-color);
}

.chat-sidebar {
    background-color: var(--sidebar-bg);
    border-radius: 12px;
    padding: var(--space-m);
    border: 1px solid var(--border-color-dark);
    display: flex;
    max-height: calc(100vh - (var(--space-m) * 3));
    flex-direction: column;
    gap: var(--space-m);
}

.chat-messages {
    overflow-y: auto;
}

.video-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
}

.chat-header {
    font-size: var(--step-0);
    background-color: var(--light-bg);
    padding: var(--space-xs);
    border-radius: var(--radius-2xs);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-active {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
}

.chat-header-active svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-m);
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-s);
    height: 400px;
}

.message {
    padding: var(--space-s);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    background-color: var(--light-bg);
    border-radius: var(--radius-2xs);
    flex-direction: column;
    gap: var(--space-2xs);
    transform-origin: top;
    will-change: transform, opacity;
    margin-bottom: var(--space-xs);
}

.message:last-child {
    margin-bottom: 0;
}

.message-author {
    font-weight: bold;
    flex-grow: 1;
    margin-left: var(--space-2xs);
}

.message-text {
    font-size: var(--step--1);
    color: var(--text-secondary);
}

.message-time {
    font-size: var(--step--2);
    color: var(--text-secondary);
    align-self: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
}

.avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
    margin-right: var(--space-xs);
}

.user-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.message:hover .user-avatar {
    border-color: var(--accent-color);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--green-color);
    border: 2px solid var(--sidebar-bg);
}

.online-indicator.offline {
    background-color: var(--border-color);
}

.online-indicator:not(.offline)::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--green-color);
    opacity: 0.5;
    animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.5);
        opacity: 0;
    }

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

.sound-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    z-index: 10;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.sound-overlay svg {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    color: white;
    margin-right: 8px;
}

.sound-overlay span {
    font-size: 14px;
    white-space: wrap;
}

.copy-notification {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--sidebar-bg);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: fadeInOut 2s ease-in-out;
    pointer-events: none;
}

.copy-notification::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--sidebar-bg);
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

[data-theme="light"] {
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.7);
    --body-bg: #FFFFFF;
    --main-bg: #F5F5F5;
    --sidebar-bg: #FFFFFF;
    --light-bg: #f1f1f1;
    --light-bg-hover: #e1e1e1;
    --border-color: rgba(0, 0, 0, 0.05);
}

.order-button {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-color);
    color: #0A0E15;
    padding: 15px 30px;
    border-radius: var(--radius-xs);
    border: none;
    cursor: pointer;
    font-size: var(--step-1);
    font-weight: bold;
    z-index: 15000;
    transition: all 0.3s ease;
}

.order-button:hover {
    transform: translateX(-50%) scale(1.05);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: flex-start;
    z-index: 16000;
    overflow-y: auto;
    padding: 20px;
}

.modal-overlay.thank-you-modal {
    align-items: center;
    overflow-y: hidden;
}

.thank-you-page {
    text-align: center;
    padding: var(--space-l);
    margin: 0 !important;
}

.modal-form {
    background: var(--main-bg);
    border-radius: var(--radius-xs);
    padding: var(--space-l);
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-color);
    position: relative;
    margin: auto;
    margin-top: 20px;
    margin-bottom: 20px;
}

.modal-header {
    text-align: center;
    margin-bottom: var(--space-m);
}

.modal-title {
    font-size: var(--step-2);
    color: var(--accent-color);
    margin-bottom: var(--space-xs);
}

:root[data-theme="light"] .modal-title {
    color: var(--green-color);
}

:root[data-theme="light"] .new-price {
    color: var(--green-color);
}

.modal-subtitle {
    font-size: var(--step-1);
    color: var(--text-primary);
    margin-bottom: var(--space-m);
}

.price-block {
    text-align: center;
    margin-bottom: var(--space-m);
}

.discount {
    font-size: var(--step-2);
    color: var(--red-color);
    font-weight: bold;
}

.old-price {
    text-decoration: line-through;
    color: var(--text-secondary);
    font-size: var(--step-1);
}

.new-price {
    font-size: var(--step-3);
    color: var(--accent-color);
    font-weight: bold;
}

.timer-block {
    text-align: center;
    margin-bottom: var(--space-m);
}

.timer {
    font-size: var(--step-2);
    color: var(--text-primary);
    font-weight: bold;
}

.form-group {
    margin-bottom: var(--space-s);
    position: relative;
}

.form-input {
    width: 100%;
    padding: var(--space-s);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xs);
    background: var(--light-bg);
    color: var(--text-primary);
    font-size: var(--step-0);
}

.form-input:focus {
    border-color: var(--accent-color);
    outline: none;
}

.submit-button {
    width: 100%;
    padding: var(--space-s);
    background: var(--accent-color);
    color: #0A0E15;
    border: none;
    border-radius: var(--radius-2xs);
    font-size: var(--step-1);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-button:hover {
    transform: scale(1.02);
}

.form-footer {
    text-align: center;
    margin-top: var(--space-s);
    color: var(--text-secondary);
    font-size: var(--step--1);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.product-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    margin: 0 auto var(--space-m);
    display: block;
}

.productCount {
    color: var(--red-color);
    font-weight: bold;
}

.form-input.phone-input {
    padding-left: 60px;
}

.phone-prefix {
    position: absolute;
    left: var(--space-s);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: var(--step-0);
    pointer-events: none;
}

.mobile-title {
    display: none;
}

@media (max-width: 1280px) {
    .live-stream {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 0;
    }

    .chat-sidebar .stream-title {
        display: none;
    }

    .mobile-title {
        color: var(--accent-color);
        font-size: var(--step-2);
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-m);
        justify-content: space-between;
        border: 1px solid var(--border-color-dark);
        background-color: var(--sidebar-bg);
        border-radius: var(--radius-xs);
        padding: var(--space-m);
        order: 1;
    }

    .stream-player {
        order: 2;
    }

    .stream-header {
        order: 3;
    }


    :root[data-theme="light"] .mobile-title {
        color: var(--green-color);
    }

    .sound-overlay {
        width: calc(100% - (var(--space-s) * 2));
    }

    .live-stream {
        padding: var(--space-s);
    }

    .modal-form {
        width: calc(100% - (var(--space-s) * 2));
    }

    .modal-overlay {
        padding: 0;
    }

    .order-button {
        width: calc(100% - (var(--space-m) * 2));
    }

    .stream-header {
        flex-direction: column;
        align-items: center;
        gap: var(--space-m);
    }


    .user__count {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .chat-container {
        height: calc(100vh - 250px);
        min-height: 400px;
        max-height: 100vh;
        padding: var(--space-s);
    }

    .chat-sidebar {
        max-height: 150vh;
    }

    .message {
        padding: var(--space-xs);
        margin-bottom: var(--space-2xs);
    }
}

.stream-player.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: #000;
    margin: 0;
    padding: 0;
    border-radius: 0;
}

.stream-player.fullscreen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

body.is-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.close-video {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    width: 40px;
    height: 40px;
}

.close-video:hover {
    background: rgba(0, 0, 0, 0.7);
}

.close-video svg {
    width: 20px;
    height: 20px;
}