/* === MLP Evening: Main Styles === */

/* === 0. Variables (Elements of Harmony) === */
:root {
    --primary-color: #6d2f8e;        /* Twilight Dark */
    --accent-color: #ce93d8;         /* Twilight Light */
    --focus-color: #ba68c8;          /* Focus/Border */
    --bg-dark: #2b2b3b;              /* Panels */
    --bg-darker: rgba(30, 20, 50, 0.42); /* Translucent */
    --text-main: #eee;
    --text-muted: #aaa;
    --danger: #ff5252;
    --success: #4caf50;
    --warning: #f1c40f;
    --main-font: 'Open Sans', 'Segoe UI', Tahoma, sans-serif;
}

/* === 1. Base Reset & Layout === */
*, *::before, *::after {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Open Sans', 'Segoe UI', Tahoma, sans-serif;
    /* Основной фон сайта */
    background: url(../img/bg.jpg) no-repeat center center fixed #2B1F43;
    background-size: cover;
    color: var(--text-main);
}

/* Scrollbar Magic (WebKit) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--focus-color);
}

/* Headings with Magic Font */
h1, h2, h3, h4, h5, h6, .logo-font {
    font-family: 'Philosopher', sans-serif;
}

/* Layout: Player (No Scroll) */
body.player-layout {
    overflow: hidden;
}

/* Layout: Dashboard (Scroll) */
body.dashboard-layout {
    overflow-y: auto;
    padding: 20px;
}

/* === 2. Player Structure (Flexbox Magic) === */
.player-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    padding: 12px; 
    gap: 12px;
}

.video-container {
    flex: 3; /* Видео занимает 3 части (75%) */
    display: flex;
    flex-direction: column;
    padding: 0;
    min-width: 0;
}

.player-container .chat-container {
    flex: 1; /* Чат занимает 1 часть (25%) */
    min-width: 320px;
    max-width: 450px;
}

/* Header */
.header {
    flex: 1; /* Занимает все свободное пространство сверху */
    min-height: 60px;
    display: flex;
    align-items: center; /* Логотип по центру вертикально */
    justify-content: space-between;
    padding: 0 10px;
    color: white;
    margin-bottom: 10px;
}

.header .logo {
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

/* Menu (Fallback if needed) */
.header .menu {
    display: flex;
    gap: 20px;
}
.header .menu a {
    color: white;
    text-decoration: none;
    font-size: 16px;
}

/* Video Content */
.video-content {
    flex: 0 0 auto; /* Не растягиваться */
    width: 100%;
    aspect-ratio: 16 / 9; /* Фиксированная пропорция */
    margin-top: auto; /* Прижимает видео к низу контейнера */
    
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    
    /* Decoration */
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

.video-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .player-container { 
        flex-direction: column; 
        padding: 0; 
        gap: 0;
    }
    .header { 
        flex: 0 0 auto; /* На мобилках шапка не растягивается */
        height: auto; 
        padding: 10px 15px; 
        margin-bottom: 0; 
        min-height: auto; 
    }
    .header .logo { height: 30px; font-size: 20px; }
    .video-container { flex: 0 0 auto; width: 100%; }
    .video-content { 
        width: 100%; 
        aspect-ratio: 16/9; 
        border-radius: 0;
        border: none;
        margin-top: 0; /* Сброс прижимания */
    }
    .chat-container { 
        flex: 1; 
        height: auto; 
        min-height: 0; 
        border-radius: 0 !important; 
        border: none !important; 
    }
}

/* === 3. Utilities === */
.hidden { display: none !important; }

/* === 4. Flash Messages === */
.flash-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 9999;
    font-weight: bold;
    color: white;
    cursor: pointer;
    text-align: center;
    min-width: 300px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

.flash-message.alert-success {
    background-color: var(--success);
    background: linear-gradient(135deg, var(--success), #8bc34a);
}

.flash-message.alert-danger {
    background-color: var(--danger);
    background: linear-gradient(135deg, #f44336, #e91e63);
}

/* === 5. Buttons (Dark Glass Theme) === */
.btn, .btn-primary, .btn-danger, .btn-warning, .btn-return, .btn-home {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    transition: all 0.2s;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.btn-primary { 
    background: linear-gradient(135deg, #7b1fa2, #4a148c);
    color: white; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-primary:hover { 
    background: linear-gradient(135deg, #8e24aa, #6a1b9a);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

.btn-outline-primary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
    box-shadow: none;
}
.btn-outline-primary:hover {
    background: rgba(206, 147, 216, 0.15);
    color: #fff;
    border-color: #e1bee7;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Outline Variants for Profile/Modals */
.btn-outline-danger {
    background: transparent;
    border: 1px solid #ff8a80;
    color: #ff8a80;
    box-shadow: none;
}
.btn-outline-danger:hover {
    background: rgba(244, 67, 54, 0.15);
    color: #fff;
    border-color: var(--danger);
    transform: translateY(-1px);
}

.btn-outline-warning {
    background: transparent;
    border: 1px solid #ffd54f;
    color: #ffd54f;
    box-shadow: none;
}
.btn-outline-warning:hover {
    background: rgba(255, 213, 79, 0.15);
    color: #fff;
    border-color: #ffca28;
    transform: translateY(-1px);
}

/* Profile Modal Footer */
.profile-actions-footer {
    margin-top: 25px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 20px;
    display: flex;
    gap: 15px;
}
.profile-actions-footer form, 
.profile-actions-footer a {
    flex: 1; /* Растягиваем кнопки поровну */
}
.profile-actions-footer .btn {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-danger { background: linear-gradient(135deg, #e74c3c, #c0392b); color: white; }
.btn-danger:hover { background: linear-gradient(135deg, var(--danger), #d32f2f); transform: translateY(-1px); }

.btn-warning { background: linear-gradient(135deg, #f1c40f, #f39c12); color: #333; }
.btn-warning:hover { background: linear-gradient(135deg, #f39c12, #e67e22); transform: translateY(-1px); }

.btn-block { display: block; width: 100%; }

/* === 6. Forms (Dark Theme) === */
.form-group { margin-bottom: 20px; text-align: left; }
.form-label { display: block; margin-bottom: 5px; color: #bbb; font-weight: 600; }

.form-input, input[type="text"], input[type="number"], input[type="password"], input[type="email"] {
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid rgba(186, 104, 200, 0.5);
    border-radius: 6px; 
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    transition: all 0.2s;
}

/* Form Focus States */
.form-input:focus, input:focus {
    outline: none;
    border-color: var(--focus-color);
    background-color: rgba(0,0,0,0.5);
    box-shadow: 0 0 10px rgba(186, 104, 200, 0.2);
}

/* === Custom Select (JS Replacement) === */
.custom-select-wrapper {
    position: relative;
    font-family: inherit;
    width: 100%;
    margin-bottom: 10px; /* Same as inputs */
}

.custom-select-wrapper select {
    display: none; /* Hide original select */
}

.select-selected {
    background-color: rgba(0,0,0,0.3);
    border: 1px solid rgba(186, 104, 200, 0.5);
    border-radius: 6px;
    color: #fff;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    font-size: 14px;
    position: relative;
}

/* Arrow */
.select-selected:after {
    position: absolute;
    content: "";
    top: 50%;
    right: 15px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-color: var(--accent-color) transparent transparent transparent;
    transform: translateY(-25%);
    transition: transform 0.2s;
}

/* Arrow Rotate on Open */
.select-selected.select-arrow-active:after {
    border-color: transparent transparent var(--accent-color) transparent;
    transform: translateY(-75%);
}

.select-selected:hover {
    background-color: rgba(0,0,0,0.4);
    border-color: var(--focus-color);
}

.select-items {
    position: absolute;
    background-color: var(--bg-dark);
    border: 1px solid var(--focus-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    z-index: 9999;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0,0,0,0.2);
}

/* Hide items when closed */
.select-hide {
    display: none;
}

.select-items div {
    color: var(--text-main);
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.1s;
}

.select-items div:last-child {
    border-bottom: none;
}

.select-items div:hover, .same-as-selected {
    background-color: var(--primary-color);
    color: #fff;
}

/* Fix rounding when open */
.select-selected.select-arrow-active {
    border-radius: 6px 6px 0 0;
    border-bottom-color: transparent;
}

/* Password Toggle Wrapper */
.password-wrapper {
    position: relative;
    display: block;
}
.password-wrapper input {
    padding-right: 40px !important;
}
.password-toggle-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 5px;
    color: var(--text-muted);
    z-index: 2;
    transition: color 0.2s;
}
.password-toggle-btn:hover { color: #fff; }
.password-toggle-btn:focus { outline: none; }

/* === 7. Color Picker UI === */
.color-picker-ui {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 2;
}
.color-swatch.active { border-color: #fff; transform: scale(1.1); }
.color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255,255,255,0.9);
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.manual-input-wrapper { display: flex; align-items: center; gap: 10px; }
.color-manual-input {
    width: 100px;
    padding: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
    background: rgba(0,0,0,0.3);
    color: #fff;
}
.color-manual-preview {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    background-color: transparent;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

/* === 8. Modals (Glassmorphism) === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--bg-dark);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.1);
    width: 100%;
    max-width: 350px;
    position: relative;
    text-align: center;
    color: #eee;
    
    /* Mobile Scroll Fix */
    max-height: 90vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.close-modal, .close-modal-profile {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #888;
}
.close-modal:hover, .close-modal-profile:hover { color: #fff; }

.modal-title {
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--accent-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.modal-desc {
    font-size: 0.95em;
    color: #ccc;
    text-align: center;
    margin-bottom: 20px;
}
.modal-subtitle {
    font-size: 0.9em;
    color: #eee;
    margin-bottom: 10px;
    font-weight: bold;
}

.auth-separator {
    margin-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
    text-align: center;
    color: #aaa;
    font-size: 0.9em;
}

.auth-separator-text {
    margin-bottom: 15px;
    display: block;
}

.auth-switch-link {
    display: block;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: bold;
    margin-top: 15px;
    font-size: 0.95em;
    transition: color 0.2s;
}
.auth-switch-link:hover {
    color: #fff;
    text-decoration: underline;
    text-shadow: 0 0 5px rgba(206, 147, 216, 0.4);
}
.auth-switch-link.secondary { color: #aaa; font-weight: normal; }
.auth-switch-link.secondary:hover { color: #ccc; }

.forgot-link {
    font-size: 0.85em;
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.2s;
}
.forgot-link:hover { color: #fff; text-decoration: underline; }

.error-msg {
    color: var(--danger);
    margin-top: 10px;
    font-size: 0.9em;
}

/* === 9. Global Smart Lightbox === */
#global-lightbox {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.lightbox-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
    position: relative;
}
.lightbox-content:active { cursor: grabbing; }

#global-lightbox-img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    transition: transform 0.1s ease-out; /* Fast for drag */
    user-select: none;
    pointer-events: auto;
    transform-origin: center center;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

/* Controls */
.lightbox-close-btn {
    position: absolute;
    top: 20px; right: 20px;
    background: none; border: none;
    color: white; font-size: 40px;
    cursor: pointer;
    z-index: 10010;
    line-height: 1;
    text-shadow: 0 0 10px black;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.lightbox-close-btn:hover { opacity: 1; }

.lightbox-controls {
    position: absolute;
    bottom: 20px;
    display: flex;
    gap: 15px;
    background: rgba(0,0,0,0.5);
    padding: 10px 20px;
    border-radius: 30px;
    z-index: 10010;
    align-items: center;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.1);
}
.lightbox-controls button {
    background: none; border: 1px solid rgba(255,255,255,0.3);
    color: white;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.lightbox-controls button:hover { background: rgba(255,255,255,0.2); }
#lightbox-zoom-level { color: #ccc; font-size: 14px; min-width: 40px; text-align: center; font-weight: bold; }

/* === 10. Error Pages === */
.error-page { overflow: auto; }
.error-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    text-align: center;
    padding: 20px;
}
.error-content {
    background: rgba(30, 20, 50, 0.8);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
    max-width: 600px;
    width: 100%;
    color: #eee;
}
.error-image {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}
.error-content h1 { color: var(--accent-color); margin-bottom: 15px; }
.error-content p { font-size: 1.1em; margin-bottom: 25px; color: #aaa; }

/* === 11. Online Users Tooltip === */
.online-tooltip {
    position: absolute;
    background: rgba(30, 20, 50, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    width: 200px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 9000;
    display: none;
    cursor: default;
    color: #eee;
    backdrop-filter: blur(5px);
}
.online-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid rgba(30, 20, 50, 0.95);
}
.online-tooltip-header {
    font-size: 0.85em;
    font-weight: bold;
    color: #aaa;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
    margin-bottom: 5px;
}
.online-user-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.online-user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'Philosopher', sans-serif;
}
.online-user-item:hover {
    background: rgba(255,255,255,0.1);
}
.online-user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.2);
}
.online-guest-count {
    margin-top: 8px;
    padding-top: 5px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85em;
    color: #888;
    text-align: center;
}

/* === 12. Profile Modal Tabs === */
.profile-tabs {
    display: flex;
    margin-bottom: 20px;
    background: rgba(0,0,0,0.1);
    padding: 4px;
    border-radius: 8px;
    gap: 5px;
}

.profile-tab-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.profile-tab-btn:hover {
    color: #eee;
    background: rgba(255,255,255,0.05);
}

.profile-tab-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.profile-tab-content .form-label {
    color: #ccc;
    font-size: 0.9em;
    margin-bottom: 5px;
    display: block;
}

.profile-tab-content small {
    color: #888 !important;
}

#profile-avatar-preview {
    transition: transform 0.2s;
    cursor: pointer;
}
#profile-avatar-preview:hover {
    transform: scale(1.1);
    border-color: var(--focus-color) !important;
}
