:root {
    --bg-gradient-start: #0f172a; /* Tmavy podklad */
    --bg-gradient-start: #09090b; /* Cerny podklad */
    --bg-gradient-end: #171717; /* Tmave sedy podklad */
    --glass-bg: rgba(20, 20, 25, 0.4);
    --glass-border: rgba(163, 230, 53, 0.3);
    --text-primary: #f8fafc;
    --accent-color: #a3e635; /* Lime barva */
    --accent-hover: #84cc16; /* Tmavsi Lime */
    --error-color: #ef4444;
    --success-color: #10b981;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Zabrani posuvnikum u animaci pozadi */
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 0 30px rgba(163, 230, 53, 0.15), inset 0 0 20px rgba(255, 255, 255, 0.05);
    text-align: center;
    transition: all 0.3s ease;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

h1 { margin-top: 0; font-size: 2rem; }

.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px; border: 1px solid var(--glass-border); border-radius: 12px;
    background: rgba(0, 0, 0, 0.6); color: white; font-size: 1rem; box-sizing: border-box;
    outline: none; transition: all 0.3s ease; box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent-color); box-shadow: 0 0 15px rgba(163, 230, 53, 0.6), inset 0 0 10px rgba(0,0,0,0.8); }
.form-group select option { color: black; }

button {
    width: 100%; padding: 12px; background: linear-gradient(135deg, rgba(163, 230, 53, 0.9), rgba(132, 204, 22, 0.9)); 
    border: none; border-radius: 12px; color: #000; font-size: 1.1rem; cursor: pointer; 
    transition: all 0.3s ease; font-weight: bold;
    box-shadow: 0 0 15px rgba(163, 230, 53, 0.4); text-shadow: 0 1px 3px rgba(0,0,0,0.3); border: 1px solid rgba(163,230,53,0.8);
}
button:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 0 25px rgba(163, 230, 53, 0.8); }
button:active { transform: translateY(1px) scale(0.98); box-shadow: 0 0 10px rgba(163, 230, 53, 0.6); }
button[style*="var(--error-color)"] { background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9)) !important; color: #fff !important; box-shadow: 0 0 15px rgba(239, 68, 68, 0.4); border-color: rgba(239,68,68,0.8); }
button[style*="var(--error-color)"]:hover { box-shadow: 0 0 25px rgba(239, 68, 68, 0.8); }
button[style*="rgba(255,255,255,0.1)"] { background: rgba(255,255,255,0.1) !important; color: #fff !important; box-shadow: none; border-color: transparent; }
button[style*="rgba(255,255,255,0.1)"]:hover { background: rgba(255,255,255,0.2) !important; box-shadow: 0 0 15px rgba(255, 255, 255, 0.2); }

.toggle-link {
    margin-top: 20px; font-size: 0.9rem; cursor: pointer; color: #cbd5e1; text-decoration: underline;
}
.toggle-link:hover { color: white; }

#message-box { margin-bottom: 15px; padding: 10px; border-radius: 8px; display: none; font-size: 0.9rem; }

.error { background: rgba(239, 68, 68, 0.2); border: 1px solid var(--error-color); color: #fca5a5; }
.success { background: rgba(16, 185, 129, 0.2); border: 1px solid var(--success-color); color: #6ee7b7; }
.hidden { display: none !important; }

/* Hlavni aplikace */
.app-wrapper {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: fixed;
    top: 0;
    left: 0;
    border: none;
    border-radius: 0;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    box-shadow: none;
    display: flex;
    overflow: hidden;
    transition: all 0.3s ease;
    z-index: 10;
}

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 999;
}
.modal-box {
    position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; 
    margin: 0 !important; z-index: 1000; width: 90%; max-width: 400px; max-height: 90vh; overflow-y: auto;
    animation: modalPopIn 0.3s ease forwards !important;
}
@keyframes modalPopIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.view-container { display: flex; flex-direction: column; width: 100%; height: 100%; }

.app-header {
    padding: 10px 20px; border-bottom: 1px solid var(--glass-border); background: rgba(0, 0, 0, 0.2);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.app-header h2 { margin: 0; font-size: 1.3rem; color: var(--accent-color); }

.app-header-controls { display: flex; gap: 15px; }
.btn-action { width: auto; padding: 8px 15px; font-size: 0.95rem; }

.content-area { flex: 1; padding: 15px; overflow-y: auto; }

/* Grid kategorii */
.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 30px; }
.category-card {
    background: rgba(0, 0, 0, 0.2); border: 1px solid var(--glass-border); border-radius: 16px;
    padding: 20px; display: flex; flex-direction: column; gap: 15px;
}
.category-card h3 { margin: 0; font-size: 1.4rem; }

.room-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.05); padding: 12px 15px; border-radius: 8px;
}

.btn-enter { width: auto; padding: 6px 15px; font-size: 0.9rem; }

/* Zalozky (Tabs) v chatu */
.chat-tabs {
    display: flex; gap: 5px; margin-bottom: 5px; border-bottom: 1px solid var(--glass-border); padding-bottom: 2px; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tab {
    flex-shrink: 0; padding: 5px 12px; cursor: pointer; border-radius: 6px 6px 0 0; background: rgba(0,0,0,0.3); transition: all 0.2s; position: relative; color: #cbd5e1; font-size: 0.85rem; border: 1px solid transparent; border-bottom: none;
}
.chat-tab.active { background: var(--accent-color); font-weight: bold; color: black; }
.chat-tab:hover:not(.active) { background: rgba(255,255,255,0.1); color: white; }
.unread-badge {
    background: var(--error-color); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px;
    position: absolute; top: -5px; right: -5px; font-weight: bold;
}

@keyframes blink-tab {
    0% { background: rgba(139, 92, 246, 0.2); }
    50% { background: rgba(139, 92, 246, 0.8); }
    100% { background: rgba(139, 92, 246, 0.2); }
}
.chat-tab.blink { animation: blink-tab 1s infinite; color: white; }

.messages {
    flex: 1; display: flex; flex-direction: column; gap: 2px; background: rgba(0,0,0,0.3);
    border-radius: 8px; padding: 8px; overflow-y: auto; scroll-behavior: smooth; position: relative;
    min-height: 0;
}

.chat-input-area { display: flex; gap: 5px; align-items: stretch; flex-shrink: 0; padding-bottom: env(safe-area-inset-bottom, 5px); }

/* Grid 2x2 pro media tlacitka */
.chat-buttons-grid {
    display: grid; grid-template-columns: 40px 40px; grid-template-rows: 40px 40px; gap: 5px; flex-shrink: 0;
}

/* TinyMCE Chat Input Styling */
.tox-tinymce { border-radius: 8px !important; border: 1px solid var(--glass-border) !important; flex: 1; min-width: 150px; }
.messages p { margin: 0; padding: 0; display: inline; } /* Zabrani odskokum odstavcu z editoru */

.current-username-badge {
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    padding: 4px 12px; background: rgba(0,0,0,0.3); border-radius: 8px; 
    border: 1px solid var(--glass-border); white-space: nowrap; flex-shrink: 0; line-height: 1.2;
}

.users-sidebar {
    width: 220px; background: rgba(0,0,0,0.3); border-radius: 8px; padding: 8px;
    display: flex; flex-direction: column; overflow: hidden;
}
#online-users-list {
    flex: 1;
    min-height: 0; /* Oprava mizejiciho Odejiti na tabletech */
    overflow-y: auto;
    padding-right: 5px;
}
.users-sidebar h3 {
    margin-top: 0; margin-bottom: 15px; font-size: 1.1rem; color: var(--accent-color);
    border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 10px;
}
.online-user-item {
    padding: 5px 8px; background: rgba(255,255,255,0.05); border-radius: 6px;
    margin-bottom: 4px; font-size: 0.85rem; display: flex; align-items: center;
    cursor: pointer; transition: background 0.2s;
}
.online-user-item:hover { background: rgba(255,255,255,0.1); }
.online-user-item::before {
    content: ''; display: inline-block; width: 8px; height: 8px;
    background: var(--success-color); border-radius: 50%; margin-right: 10px;
}

.quick-whisper { transition: transform 0.2s; opacity: 0.7; }
.quick-whisper:hover { transform: scale(1.2); opacity: 1; }

.chat-image-thumb {
    max-width: 250px; max-height: 200px; border-radius: 8px; cursor: pointer;
    margin-top: 5px; border: 1px solid var(--glass-border); transition: transform 0.2s;
}
.chat-image-thumb:hover { transform: scale(1.05); }

/* Media Tlacitka */
.btn-media {
    width: 100%; height: 100%; padding: 0 !important; font-size: 1.1rem;
    display: flex; justify-content: center; align-items: center;
    background: rgba(255,255,255,0.1) !important; color: white !important;
    border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); box-shadow: none;
}
.btn-media:hover { background: rgba(255,255,255,0.2) !important; transform: scale(1.05); }

.smiley-btn {
    cursor: pointer; font-size: 1.3rem; text-align: center; transition: transform 0.2s;
}
.smiley-btn:hover { transform: scale(1.2); }

/* Jazykove vlajky */
.lang-flag {
    width: 32px; height: 24px; object-fit: cover; border-radius: 4px; cursor: pointer;
    opacity: 0.4; transition: all 0.2s; border: 2px solid transparent;
}
.lang-flag:hover { opacity: 0.8; transform: scale(1.1); }
.lang-flag.active { opacity: 1; border-color: var(--accent-color); box-shadow: 0 0 10px rgba(163,230,53,0.5); }

#image-modal-box { text-align: center; max-width: 90vw; }
#enlarged-image { max-width: 100%; max-height: 80vh; border-radius: 12px; box-shadow: 0 15px 35px rgba(0,0,0,0.8); }

.profile-view-field {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    text-align: left;
    min-height: 22px;
    word-wrap: break-word;
}

/* Audio a nahravani */
.chat-audio { max-width: 100%; height: 40px; margin-top: 5px; outline: none; border-radius: 8px; }
.recording {
    animation: pulse-red 1.5s infinite;
    background: rgba(239, 68, 68, 0.4) !important;
    color: white !important;
    border: 1px solid rgba(239, 68, 68, 0.8) !important;
}
@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 15px rgba(239, 68, 68, 0.9); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
}

/* Mazani zprav */
.delete-msg-btn {
    cursor: pointer; color: #ef4444; font-size: 0.8rem; margin-right: 8px;
    display: none; transition: transform 0.2s;
}
.delete-msg-btn:hover { transform: scale(1.2); }

.role-admin .delete-msg-btn, .role-superadmin .delete-msg-btn {
    display: inline-block;
}

/* Odpovidani na zpravy */
.reply-msg-btn {
    cursor: pointer; color: #60a5fa; font-size: 0.8rem; margin-right: 8px;
    transition: transform 0.2s; display: inline-block;
}
.reply-msg-btn:hover { transform: scale(1.2); }

.quote-block {
    background: rgba(0, 0, 0, 0.4); border-left: 4px solid var(--accent-color);
    padding: 8px 12px; margin-bottom: 8px; font-size: 0.85rem; color: #e2e8f0; border-radius: 0 8px 8px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3); font-style: italic; position: relative; overflow: hidden;
}
.quote-block::before {
    content: '"'; position: absolute; left: 10px; top: -5px; font-size: 3rem; color: rgba(163,230,53,0.15); font-family: serif; line-height: 1; pointer-events: none;
}

.btn-format { 
    width: 30px; height: 30px; padding: 0; display: flex; justify-content: center; align-items: center; 
    background: rgba(255,255,255,0.1) !important; color: white !important; font-size: 1rem; border-radius: 6px; box-shadow: none !important; margin: 0; 
}
.btn-format:hover { background: rgba(255,255,255,0.2) !important; transform: scale(1.1); }

/* Bublina a uzivatelska jmena */
.user-hoverable {
    cursor: pointer; border-bottom: 1px dashed rgba(255,255,255,0.3); transition: color 0.2s;
}
.user-hoverable:hover { color: white !important; }

#user-tooltip {
    position: absolute; padding: 12px; z-index: 9999; width: 220px; pointer-events: none;
    background: rgba(15, 23, 42, 0.95); border: 1px solid var(--glass-border);
    box-shadow: 0 10px 25px rgba(0,0,0,0.8); border-radius: 12px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    transition: opacity 0.2s, transform 0.2s;
    opacity: 0; transform: translateY(10px); display: block;
}
#user-tooltip.visible {
    opacity: 1; transform: translateY(0);
}
.status-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px;
}

/* Optimalizace pro mobilni zarizeni */
@media (max-width: 768px) {
    .app-wrapper {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0;
        border: none;
    }
    .glass-container {
        width: 95%;
        padding: 20px;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    .app-header-controls {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        margin-top: 10px;
    }
    .content-area[style] {
        flex-direction: column !important;
        padding: 10px !important;
    }
    .users-sidebar {
        width: auto !important;
        height: 180px;
        padding: 10px;
    }
    .categories-grid { grid-template-columns: 1fr; }
    
    /* Prispusobeni tlacitek chatu pro snadnejsi klikani prstem */
    .chat-input-area { flex-wrap: wrap; }
    .current-username-badge { order: -2; width: 100%; margin-bottom: 5px; justify-content: center; box-sizing: border-box; }
    #chat-input { order: -1; width: 100%; margin-bottom: 5px; }
    
    #smiley-picker { grid-template-columns: repeat(6, 1fr) !important; width: 100%; box-sizing: border-box; left: 0 !important; }
    #image-modal-box { width: 95vw; }
}