/* IMPORTS */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

/* CSS VARIABLES */

@property --admin-color {
  syntax: '<color>';
  inherits: true;
  initial-value: #FF006E;
}

@property --bot-color {
  syntax: '<color>';
  inherits: true;
  initial-value: #00D9FF;
}

@keyframes admincolor {
  from { --admin-color: #FF006E; }
  to   { --admin-color: magenta; }
}

@keyframes botcolor {
  from { --bot-color: #00D9FF; }
  to   { --bot-color: #00FF88; }
}

:root {
    /* Colors */
    --primary-bg: black;
    --primary-text: white;
    --secondary-color: rgb(75, 59, 255);
    --white-transparent: rgba(255, 255, 255, 0.2);
    animation: admincolor 1s linear infinite alternate, botcolor 1.5s linear infinite alternate;
    --user-color: #2c4751;
    --message-bg: rgba(0, 0, 0, 0.2);

    /* Shadows */
    --shadow-color: rgba(0, 0, 0, 0.65);
    --text-shadow: 0 0 0.5em var(--shadow-color);
    --text-shadow-sm: 0 0 0.2em var(--shadow-color);

    /* Borders */
    --border: 0.1rem solid var(--white-transparent);
    --border-radius: 0.25rem;

    /* Dimensions */
    --ui-height: 2rem;
    --input-width: 20rem;
    --unmute-btn-size: 6rem;

    /* Spacing */
    --gap: 0.25rem;
    --padding: 0.5rem;
    --margin-lg: 2rem;

    /* Typography */
    --font-primary: "Inter", sans-serif;
    --font-mono: "Roboto Mono", monospace;
    --font-weight: 600;
    --font-size-sm: 0.75rem;

    /* Transitions */
    --transition: all 0.2s ease;
}

/* RESET & BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    background: var(--primary-bg);
    color: var(--primary-text);
    font-family: var(--font-primary);
    font-optical-sizing: auto;
    font-size: 1em;
    font-weight: var(--font-weight);
}

/* Form elements inherit font */
input,
textarea,
select,
button {
    font-family: inherit;
}

/* UTILITY CLASSES */
[hidden] {
    display: none !important;
}

.flex-fill {
    flex: 1;
}


/* VIDEO CONTAINER - Inner container that holds Plyr */

#video-container {
    display: flex;
    width: 100%;
    height: 100%;
}

#video-container video {
    max-height: 100vh;
    width: 100vw;
    max-width: 100vw;
}

.plyr__video-wrapper {
    max-height: 100%;
    height: auto !important;
}

/* Custom unmute button */
#custom-unmute-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--primary-text);
    z-index: 2;
    user-select: none;
}

#custom-unmute-btn .material-symbols-sharp {
    font-size: max(8em,20vw);
    font-variation-settings:
        'FILL' 0,
        'wght' 700,
        'GRAD' 0,
        'opsz' 48;
}

/* OVERLAY SCREENS */
#info {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    font-size: max(2em, 4vw);
    padding: 1em 2em;
    text-align: center;
    text-shadow: var(--text-shadow);
}

/* UI SYSTEM */

/* UI Zones - Top and Bottom bars */
#zonetop,
#zonebot {
    position: fixed;
    left: var(--margin-lg);
    right: var(--margin-lg);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: var(--gap);
    justify-content: space-between;
}

#zonetop div, #zonebot div {
    text-shadow: var(--text-shadow);
}

#zonetop {
    top: var(--margin-lg);
}

#zonebot {
    bottom: var(--margin-lg);
}

.zone {
    display: flex;
    gap: var(--gap);
}

.zone:has(.module:not([hidden])), .ui-group:has(.module:not([hidden])) {
    flex:1;
}

.module {
    flex:1;
}

#zonebr, #zonetr, #zonebr .ui-group, #zonetr .ui-group {
    justify-content:flex-end;
}

#zonetr, #zonebr {
    flex-direction: row-reverse;
}

/* Enable pointer events for direct children */
#zonetop>*,
#zonebot>* {
    pointer-events: auto;
}

/* UI Groups */
.ui-group {
    display: flex;
    align-items: center;
    gap: var(--gap);
    min-width: 0;
}

/* UI Buttons */
.ui-button {
    min-width: var(--ui-height);
    height: var(--ui-height);
    padding: 0 var(--padding);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    border-radius: var(--border-radius);
    user-select: none;
    font-weight: var(--font-weight);
    transition: var(--transition);
    border: var(--border);
    background: transparent;
    color: var(--primary-text);
    gap: var(--padding);
}

.ui-button:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.ui-button:active {
    transform: scale(0.95);
}

/* UI Info Display */
.ui-info {
    height: var(--ui-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    border-radius: var(--border-radius);
    user-select: none;
    font-family: var(--font-mono);
    border: var(--border);
    background: transparent;
    color: var(--primary-text);
    min-width: var(--ui-height);
}

/* UI Input */
.ui-input {
    height: var(--ui-height);
    padding: var(--padding);
    background: transparent;
    color: var(--primary-text);
    border: var(--border);
    border-radius: var(--border-radius);
    font-weight: var(--font-weight);
    font-size: var(--font-size-sm);
    outline: none;
    resize: none;
    overflow: hidden;
    transition: var(--transition);
    min-width: 0;    /* daralabilsin, taşma olmasın */
    width: 100%;
    max-width: var(--input-width)
}

/* Placeholder styling */
.ui-input::placeholder {
    color: var(--white-transparent);
    opacity: 1;
}

/* UI Text Elements */
.ui-btn-text,
.ui-info-text {
    font-weight: var(--font-weight);
}

.ui-btn-icon {
    font-size: 1em !important;
}

/* Timecode specific */
#infoTimecode {
    border: none;
}

/* CHAT SYSTEM */

/* Chat Messages Container */
#chat-messages {
    /* overflow-y: auto; */ /* Disabled to prevent shake issues */
    display: flex;
    gap: var(--gap);
    flex-direction: column;
    width: var(--input-width);
    bottom: calc(var(--ui-height) + var(--gap));
    right: 0;
    position: absolute;
    z-index: 8; /* Below UI zones (10) */
}

/* Hide scrollbar */
#chat-messages::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* Individual Chat Message */
.chat-message {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    align-items: flex-start;
    border: var(--border);
    border-radius: var(--border-radius);
    padding: var(--padding);
    color: var(--primary-text);
    font-size: var(--font-size-sm);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
    background-color: var(--message-bg);
}

/* Deleted Message State */
.chat-message.deleted {
    opacity: 0.5;
}

.chat-message.deleted .message-text {
    filter: blur(0.25em);
}

.chat-message.deleted .chat-admin-menu .ui-button[data-role="delete"] {
    display: none !important;
}

/* System Messages */
.chat-message.system .message-header {
    display: none;
}

/* Message Header */
.message-header {
    display: flex;
    align-items: center;
    gap: var(--padding);
    flex-wrap: wrap;
}

/* Message Nicknames */
.message-name {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-name.admin {
    color: var(--admin-color);
}

.message-name.bot {
    color: var(--bot-color);
}

.message-name.user {
    color: var(--user-color);
}

/* Message Text */
.message-text {
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
    max-width: 100%;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Admin Controls */
.chat-admin-menu {
    position: absolute;
    top: var(--gap);
    right: var(--gap);
    display: none;
    gap: var(--gap);
    align-items: center;
    pointer-events: auto;
    z-index: 20;
}

.chat-message:hover .chat-admin-menu {
    display: flex;
}

.chat-admin-menu .ui-button {
    min-width: calc(var(--ui-height) * 0.75);
    height: calc(var(--ui-height) * 0.75);
    padding: 0;
}

/* ADMIN MODE */
body.admin #zonebot {
    bottom: 4rem;
}

/* MATERIAL ICONS */
.material-symbols-sharp {
    font-family: 'Material Symbols Sharp' !important;
    font-weight: normal !important;
    font-style: normal !important;
    line-height: 1 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    display: inline-block !important;
    white-space: nowrap !important;
    word-wrap: normal !important;
    direction: ltr !important;
    font-variation-settings:
        'FILL' 0,
        'wght' 700,
        'GRAD' 0,
        'opsz' 20;
}

/* PLYR PLAYER CUSTOMIZATION */
.plyr {
    width:100%;
    margin:auto;
}

.plyr__controls {
    position: fixed !important;
}

/* Subtitle Styling */
.plyr__captions, .plyr__caption {
    font-family: inherit !important;
    font-weight: 500 !important;
    line-height: 1.2em !important;
    font-size: 2.2vw !important;
    transform: none !important;
    padding: 1em !important;
}

.plyr__caption {
    font-family: inherit;
    line-height: inherit;
    padding: 0;
    background: transparent;
    color: var(--primary-text);
    text-shadow: var(--text-shadow-sm);
}

.plyr__caption b {
    font-weight: inherit !important;
}

/* Funimations */

@keyframes shake {
  0% { transform: translate(0.0625em, 0.0625em) rotate(0deg); }
  10% { transform: translate(-0.0625em, -0.125em) rotate(-1deg); }
  20% { transform: translate(-0.1875em, 0em) rotate(1deg); }
  30% { transform: translate(0.1875em, 0.125em) rotate(0deg); }
  40% { transform: translate(0.0625em, -0.0625em) rotate(1deg); }
  50% { transform: translate(-0.0625em, 0.125em) rotate(-1deg); }
  60% { transform: translate(-0.1875em, 0.0625em) rotate(0deg); }
  70% { transform: translate(0.1875em, 0.0625em) rotate(-1deg); }
  80% { transform: translate(-0.0625em, -0.0625em) rotate(1deg); }
  90% { transform: translate(0.0625em, 0.125em) rotate(0deg); }
  100% { transform: translate(0.0625em, -0.125em) rotate(-1deg); }
}

.chat-message.shake {
  animation: shake 0.5s;
  animation-iteration-count: infinite;
  contain: layout; /* Prevent layout shifts from affecting container */
}

/* ============================================ */
/* RESPONSIVE DESIGN - 3 STAGE APPROACH */
/* ============================================ */

/* Stage 1: Mobile (Default - Mobile First) */
/* 320px - 767px */
@media (max-width: 767px) {
    :root {
        --margin-lg: 1rem; /* Test: reduced margin for mobile */
    }
}

/* Stage 2: Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --margin-lg: 1.5rem; /* Test: medium margin for tablet */
    }
}

/* Stage 3: Desktop */
@media (min-width: 1024px) {
    :root {
        --margin-lg: 2rem; /* Original margin for desktop */
    }
}