/* =========================================================
   EPICA: PERSISTENTE UI (immer sichtbar im Spiel)
   Seitenleiste, Spieler-Info oben links, Chat-Ticker, Chat-Fenster
   Liegt über den Modulen (Burg usw.), die als Vollbild darunter laufen.
========================================================= */

/* ---------- SEITENLEISTE (links) ---------- */
#dashboard .dashboard-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    z-index: 500;
    background: var(--panel-bg);
    border-right: 2px solid var(--primary-dark);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    transition: transform 0.3s ease;
    box-sizing: border-box;
}

#dashboard .dashboard-sidebar.collapsed {
    transform: translateX(-100%);
}

#dashboard .sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -34px;
    transform: translateY(-50%);
    width: 34px;
    height: 60px;
    margin: 0;
    padding: 0;
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    z-index: 501;
}

#dashboard .sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px 15px;
    box-sizing: border-box;
    overflow-y: auto;
}

#dashboard .sidebar-title {
    margin: 0 0 15px 0;
    font-size: 1.3rem;
    color: var(--primary);
    text-align: center;
    letter-spacing: 1px;
}

#dashboard .resources-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--primary-dark);
    border-radius: 6px;
    padding: 10px 12px;
}

#dashboard .resource-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

#dashboard .res-value {
    font-weight: bold;
    color: #fff;
}

#dashboard .sidebar-bottom {
    margin-top: auto;
    padding-top: 15px;
}

/* Schraubenschlüssel (Account-Währung) – leicht abgesetzt von den Spiel-Ressourcen */
#dashboard .res-row-wrench {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--primary-dark);
}
#dashboard .res-row-wrench .res-value { color: #9fd3ff; }

/* Seasonpass + Freunde einladen */
#dashboard .sidebar-rewards {
    display: grid;
    gap: 6px;
    margin-top: 10px;
}
#dashboard .sidebar-reward-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
}
#dashboard .reward-badge {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
}
#dashboard .reward-badge[hidden] { display: none; }

#dashboard .sidebar-lang-label {
    display: block;
    font-size: 12px;
    color: var(--primary);
    margin-bottom: 4px;
}

#dashboard .sidebar-lang-select {
    margin-bottom: 8px;
    padding: 8px;
    font-size: 13px;
    cursor: pointer;
}

#dashboard .castle-empty-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ---------- SPIELER-INFO (oben links) ---------- */
#dashboard .top-left-ui {
    position: fixed;
    top: 12px;
    left: 262px;
    z-index: 400;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 14px 10px;
    background: var(--panel-bg);
    border: 1px solid var(--primary-dark);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s ease, left 0.3s ease;
}

/* Seitenleiste eingeklappt -> Spieler-Info und Ticker rücken nach links */
#dashboard .dashboard-sidebar.collapsed ~ .top-left-ui { left: 46px; }
#dashboard .dashboard-sidebar.collapsed ~ .chat-ticker-line { left: 46px; }

#dashboard .top-left-ui .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    object-fit: cover;
    flex-shrink: 0;
}

#dashboard #top-ui-avatar-fallback {
    line-height: 60px !important;
    font-size: 30px !important;
}

#dashboard .top-left-ui .name-link {
    display: block;
    color: var(--primary);
    font-weight: bold;
    font-size: 16px;
    text-decoration: none;
    margin-bottom: 4px;
}

#dashboard .top-left-ui .stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 12px;
    color: #ddd;
}

/* ---------- CHAT-TICKER (unten) ---------- */
#dashboard .chat-ticker-line {
    position: fixed;
    bottom: 12px;
    left: 262px;
    right: 110px;
    z-index: 300;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    font-size: 12px;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: left 0.3s ease;
}

/* ---------- ABSTAND OBEN für Module (Postfach, Helden …) ----------
   Die Spieler-Info oben links liegt über dem Inhalt. Die Burg (castle.html)
   setzt ihr eigenes padding: 0 !important und bleibt Vollbild. */
#dashboard #module-container {
    padding-top: 110px;
    box-sizing: border-box;
}

/* ---------- TIMER-LEISTE (gamedata/js/timers.js) ----------
   Laufende Aufträge in der Seitenleiste + Zahl am Knopf, wenn die Leiste eingeklappt ist */
#dashboard .sidebar-timers { margin-top: 14px; }
#dashboard .sidebar-timers[hidden] { display: none; }
#dashboard .sidebar-timers-title {
    margin: 0 0 6px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
}
#dashboard .sidebar-timers-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#dashboard .sidebar-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 6px 8px;
    text-align: left;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid #2ecc71;
    border-radius: 6px;
    color: #ddd;
    font-size: 12px;
    cursor: pointer;
}
#dashboard .sidebar-timer:hover,
#dashboard .sidebar-timer:focus-visible { border-color: var(--primary); }
#dashboard .sidebar-timer-research { border-left-color: #00c8ff; }
#dashboard .sidebar-timer-mine { border-left-color: #c77d3a; }
#dashboard .sidebar-timer-troops { border-left-color: #e67e22; }
#dashboard .sidebar-timer-mission,
#dashboard .sidebar-timer-march { border-left-color: #9b59b6; }
#dashboard .sidebar-timer-attack { border-left-color: #e74c3c; background: rgba(231, 76, 60, 0.18); }
#dashboard .sidebar-timer .st-ico { font-size: 18px; flex-shrink: 0; }
#dashboard .sidebar-timer .st-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#dashboard .sidebar-timer .st-type { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: #999; }
#dashboard .sidebar-timer .st-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
#dashboard .sidebar-timer .st-detail { color: #aaa; }
#dashboard .sidebar-timer .st-time { font-weight: bold; color: #f1c40f; white-space: nowrap; font-variant-numeric: tabular-nums; }
#dashboard .sidebar-timer-attack .st-time { color: #ff6b5b; }

#dashboard .sidebar-timer-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #2ecc71;
    color: #000;
    font-size: 11px;
    font-weight: bold;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}
#dashboard .sidebar-timer-badge.is-attack { background: #e74c3c; color: #fff; animation: epicaTimerPulse 1.2s ease-in-out infinite; }
#dashboard .sidebar-timer-badge[hidden],
#dashboard .dashboard-sidebar:not(.collapsed) .sidebar-timer-badge { display: none; }
@keyframes epicaTimerPulse { 50% { transform: scale(1.2); } }
@media (prefers-reduced-motion: reduce) { #dashboard .sidebar-timer-badge.is-attack { animation: none; } }

/* ---------- MODULE NEBEN DER GEÖFFNETEN SEITENLEISTE (Desktop) ----------
   castle.html setzt die Burgkarte auf 100vw. Bei offener Seitenleiste beginnt
   der Inhalt rechts daneben, damit keine Gebäude verdeckt werden. */
@media (min-width: 701px) {
    #dashboard .dashboard-sidebar:not(.collapsed) ~ #module-container {
        left: 240px !important;
        width: calc(100vw - 240px) !important;
        transition: left 0.3s ease, width 0.3s ease;
    }
    #dashboard .dashboard-sidebar:not(.collapsed) ~ #module-container .castle-wrapper,
    #dashboard .dashboard-sidebar:not(.collapsed) ~ #module-container .layer-1-bg,
    #dashboard .dashboard-sidebar:not(.collapsed) ~ #module-container .layer-2-hotspots,
    #dashboard .dashboard-sidebar:not(.collapsed) ~ #module-container #castle-layout-container {
        width: 100% !important;
        min-width: 100% !important;
    }
}

/* ---------- BUTTONS UNTEN/OBEN RECHTS über den Modulen ---------- */
#dashboard .bottom-right-menu,
#dashboard .top-right-ui {
    z-index: 450;
}

/* ---------- CHAT-FENSTER ---------- */
/* Inline steht display:none -> nur mit Klasse .active sichtbar */
#dashboard .floating-chat-container.active {
    display: flex !important;
}

#dashboard .floating-chat-container {
    position: fixed;
    right: 20px;
    bottom: 90px;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: 70vh;
    z-index: 600;
    flex-direction: column;
    background: var(--panel-bg);
    border: 2px solid var(--primary);
    border-radius: 10px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    overflow: hidden;
}

#dashboard .chat-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--primary-dark);
    background: rgba(0, 0, 0, 0.4);
}

#dashboard .chat-panel-head #chat-header {
    flex: 1;
    min-width: 0;
}

#dashboard .chat-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

#dashboard .chat-rooms {
    width: 120px;
    flex-shrink: 0;
    padding: 8px;
    overflow-y: auto;
    border-right: 1px solid var(--primary-dark);
    font-size: 12px;
}

#dashboard .chat-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

#dashboard .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

#dashboard .chat-sticker-menu {
    gap: 6px;
    padding: 6px 10px;
    border-top: 1px solid var(--primary-dark);
}

#dashboard .chat-input-row {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid var(--primary-dark);
}

/* Globale Button/Input-Styles im Chat zurücksetzen */
#dashboard .floating-chat-container button {
    width: auto;
    margin: 0;
    padding: 6px 10px;
    font-size: 11px;
}

#dashboard .chat-rooms .chat-small-btn {
    width: 100%;
    margin-top: 6px;
}

#dashboard .chat-input-row input {
    flex: 1;
    margin: 0;
    padding: 8px;
    min-width: 0;
}

/* ---------- HANDY ---------- */
@media (max-width: 700px) {
    #dashboard .dashboard-sidebar { width: 78vw; }

    #dashboard .top-left-ui {
        left: 46px;
        top: 8px;
        padding: 6px 10px 12px 6px;
        gap: 8px;
    }
    #dashboard .top-left-ui .avatar { width: 44px; height: 44px; }
    #dashboard #top-ui-avatar-fallback { line-height: 44px !important; font-size: 22px !important; }
    #dashboard .top-left-ui .name-link { font-size: 14px; }
    #dashboard .top-left-ui .stats { font-size: 11px; }

    #dashboard .chat-ticker-line { left: 46px; right: 90px; }

    #dashboard .floating-chat-container {
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        bottom: 80px;
    }
    #dashboard .chat-rooms { width: 90px; }
}
