/* MineCast Styles - Terminal Style Chat */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a0a;
    color: #00ff00;
    line-height: 1.6;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
}

.container {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
}

/* Video Section - Full Screen */
.video-section {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
}

.video-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Stream Status */
.stream-status {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    border: 1px solid rgba(0, 255, 0, 0.3);
    box-shadow: 0 0 3px rgba(0, 255, 0, 0.2);
    z-index: 10;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    animation: pulse 2s infinite;
}

.status-indicator.live {
    background: #00ff00;
    box-shadow: 0 0 10px #00ff00;
}

.status-indicator.offline {
    background: #ff0000;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Messages Overlay - Fixed Position, Terminal Style */
.chat-messages-overlay {
    position: fixed;
    right: 20px;
    bottom: 150px;
    width: 450px;
    max-height: calc(100vh - 250px);
    max-height: calc(100dvh - 250px);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.chat-message {
    color: #00ff00;
    padding: 4px 0;
    margin-bottom: 2px;
    font-size: 14px;
    text-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
    animation: slideInFromBottom 0.3s ease-out, fadeOutSlow 2s ease-out 598s forwards;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.chat-message.system {
    color: #00ff00;
    font-style: italic;
    opacity: 0.7;
}

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

@keyframes fadeOutSlow {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.chat-message .username {
    color: #00ff00;
    font-weight: bold;
    margin-right: 8px;
    text-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
    display: inline;
}

.chat-message .text {
    color: #00ff00;
    display: inline;
}

.chat-message .timestamp {
    color: #00ff00;
    opacity: 0.5;
    font-size: 11px;
    margin-left: 8px;
    display: inline;
}

.chat-message img {
    max-width: 300px;
    max-height: 200px;
    margin-top: 4px;
    display: block;
    border: 1px solid rgba(0, 255, 0, 0.3);
    box-shadow: none;
}

/* Chat Input Overlay - Fixed Position */
.chat-input-overlay {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 450px;
    z-index: 100;
    pointer-events: auto;
}

/* Join Overlay */
.join-overlay {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
}

.join-overlay input {
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 4px;
    color: #00ff00;
    font-size: 14px;
    width: 200px;
}

.join-overlay input:focus,
.chat-input-box input[type="text"]:focus {
    outline: none;
    box-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
}

.join-overlay input::placeholder,
.chat-input-box input[type="text"]::placeholder {
    color: rgba(0, 255, 0, 0.4);
}

.btn-join {
    padding: 10px 20px;
    background: rgba(0, 255, 0, 0.2);
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 4px;
    color: #00ff00;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-join:hover {
    background: rgba(0, 255, 0, 0.3);
    box-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
}

.btn-join:active {
    transform: scale(0.98);
}

/* Chat Input Box */
.chat-input-box {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    width: 100%;
}

.chat-input-box input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 0, 0.3);
    border-radius: 4px;
    color: #00ff00;
    font-size: 14px;
    min-width: 250px;
}

.btn-icon {
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid rgba(0, 255, 0, 0.3);
    color: #00ff00;
    width: 38px;
    height: 38px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
}

.btn-join:hover {
    background: rgba(0, 255, 0, 0.3);
    box-shadow: 0 0 3px rgba(0, 255, 0, 0.4);
}

.btn-leave {
    background: rgba(255, 0, 0, 0.1);
    border-color: rgba(255, 0, 0, 0.3);
    color: #ff0000;
}

.btn-leave:hover {
    background: rgba(255, 0, 0, 0.2);
    box-shadow: 0 0 3px rgba(255, 0, 0, 0.4);
}

/* Mini Image Preview */
.image-preview-mini {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.9);
    padding: 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 0, 0.3);
}

.image-preview-mini img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 0, 0.3);
}

.btn-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: rgba(255, 0, 0, 1);
    box-shadow: 0 0 3px rgba(255, 0, 0, 0.4);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-messages-overlay {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        bottom: 120px;
        bottom: max(120px, calc(120px + env(safe-area-inset-bottom)));
        max-height: 50vh;
        max-height: 50dvh;
    }

    .chat-input-overlay {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        bottom: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        width: 90%;
        max-width: 400px;
    }

    .chat-input-box {
        max-width: none;
    }

    .chat-input-box input[type="text"] {
        min-width: 0;
        font-size: 14px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .join-overlay {
        flex-direction: column;
        width: 100%;
    }

    .join-overlay input {
        width: 100%;
    }

    .stream-status {
        font-size: 12px;
        padding: 6px 12px;
        top: 10px;
        left: 10px;
    }

    .chat-message {
        font-size: 13px;
    }

    .chat-message img {
        max-width: 100%;
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .chat-input-overlay {
        width: 95%;
        max-width: 350px;
    }

    .chat-input-box input[type="text"],
    .join-overlay input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 8px 12px;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
    }
}

/* Landscape orientation - Hide chat input for full-screen viewing */
@media (max-width: 768px) and (orientation: landscape) {
    .chat-input-overlay {
        display: none !important;
    }

    .chat-messages-overlay {
        bottom: 20px;
        bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Portrait orientation - Show chat input */
@media (max-width: 768px) and (orientation: portrait) {
    .chat-input-overlay {
        display: block;
    }
}

/* Fullscreen mode - hide everything */
body.fullscreen-mode .chat-messages-overlay,
body.fullscreen-mode .chat-input-overlay,
body.fullscreen-mode .stream-status {
    display: none !important;
}

/* Prevent iOS bounce scroll and enable minimal UI */
@supports (-webkit-touch-callout: none) {
    body {
        overscroll-behavior: none;
    }

    /* Encourage Safari to hide toolbars */
    .video-section {
        min-height: 100vh;
        min-height: 100svh; /* Small viewport height - accounts for toolbar */
    }
}
