/* style.css - Vamily Premium Design-System (REPAIRED) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap');

:root {
    --bg-dark: #0f172a; 
    --bg-card: #1e293b; 
    --bg-card-hover: #334155;
    --bg-input: #0f172a;
    --primary: #bef264; /* Tennis-Neon */
    --primary-muted: rgba(190, 242, 100, 0.15);
    --primary-dark: #84cc16;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --border-bright: rgba(255, 255, 255, 0.2);
    --glass: blur(20px);
    --danger: #f87171;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);

    /* Legacy-Kompatibilität */
    --bg-main: var(--bg-dark);
    --primary-glow: var(--primary-muted);
    --color-sieg: var(--primary);
    --color-niederlage: var(--danger);
    --color-unentschieden: #f59e0b;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --bottom-nav-height: calc(75px + var(--safe-bottom));
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: calc(var(--bottom-nav-height) + 10px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: var(--glass);
    border-bottom: 1px solid var(--border);
}

.header-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.header-logo h1 span { color: var(--primary); }

.header-user-status {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 6px 6px 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border-bright);
    cursor: pointer;
    box-shadow: var(--shadow);
}

.balance-badge {
    color: var(--primary);
    font-weight: 800;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar span { color: var(--bg-dark); font-weight: 800; font-size: 0.8rem; }

/* DROPDOWN */
.dropdown-menu {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 240px;
    background: #1e293b;
    border: 1px solid var(--border-bright);
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
    display: none;
    flex-direction: column;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}
.dropdown-menu.active { display: flex; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.dropdown-header { padding: 12px; }
.dropdown-header strong { display: block; font-size: 1rem; color: var(--text-main); }
.dropdown-header span { font-size: 0.75rem; color: var(--text-muted); }
.dropdown-divider { height: 1px; background: var(--border); margin: 8px 0; }
.dropdown-item { display: flex; align-items: center; gap: 12px; padding: 12px; color: var(--text-main); text-decoration: none; border-radius: 12px; font-weight: 600; font-size: 0.9rem; }
.dropdown-item:hover { background: var(--bg-card-hover); }
.dropdown-item.logout { color: var(--danger); }

/* CONTENT & VIEWS */
main { flex: 1; padding: 0 16px; }
.view-section { display: none; animation: fadeIn 0.3s ease-out forwards; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* CARDS */
.card-section {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-section h2 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.card-section h2 svg { color: var(--primary); }

/* BIERDECKEL GRID REPAIR */
.getraenke-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.quick-action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: 20px;
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.quick-action-btn:active { transform: scale(0.96); border-color: var(--primary); }
.quick-action-btn .btn-name { font-weight: 700; font-size: 0.95rem; text-align: center; color: var(--text-main); }
.quick-action-btn .btn-preis { color: var(--primary); font-weight: 800; margin-top: 6px; font-size: 0.85rem; }

/* DRINK SELECTION OVERLAYS */
.drink-count-badge {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: var(--primary);
    color: var(--bg-dark);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.8rem;
    box-shadow: 0 0 15px var(--primary-muted);
    border: 2px solid var(--bg-card);
    z-index: 6;
    pointer-events: none;
}

.adjust-btn {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    background: transparent;
    transition: background 0.15s;
    z-index: 5;
    cursor: pointer;
}
.adjust-btn.minus {
    left: 0;
    border-top-left-radius: 20px;
    border-bottom-left-radius: 20px;
}
.adjust-btn.plus {
    right: 0;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 20px;
}
.adjust-btn:active { background: rgba(190, 242, 100, 0.1); }

/* CM TOURNAMENT TREE REPAIR */
.tree-container {
    display: flex;
    gap: 40px;
    padding: 20px 10px;
    overflow: auto;
    min-height: 400px;
    position: relative; /* WICHTIG für SVG-Linien */
}

/* MATCH HIGHLIGHTS (Own Matches) */
.is-own-match {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 0 20px var(--primary-muted) !important;
    position: relative;
}
.is-own-match::after {
    content: "DEIN SPIEL";
    position: absolute;
    top: -10px;
    right: 12px;
    background: var(--primary);
    color: var(--bg-dark);
    font-size: 0.55rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* SUB-VIEW NAVIGATION (Pyramide) */
.sub-nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.sub-nav-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
}
.sub-nav-btn.active {
    background: var(--primary-muted);
    border-color: var(--primary);
    color: var(--primary);
}

#tree-connections-svg path {
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 1.5;
    transition: stroke 0.3s;
}

/* ADMIN MITGLIEDER LISTE */
.mitglieder-item {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
}

.mitglieder-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.mitglieder-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mitglieder-name { font-weight: 800; font-size: 1.1rem; color: var(--text-main); }
.mitglieder-badge { font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; }
.mitglieder-meta { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.mitglieder-token { color: var(--primary); font-family: monospace; font-weight: 700; }

.mitglieder-actions { display: flex; gap: 8px; align-items: center; }

.mitglieder-actions button {
    height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-whatsapp { background: #25d366 !important; color: white !important; box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3); }
.btn-whatsapp:active { transform: scale(0.95); opacity: 0.9; }

.btn-edit-user { background: var(--bg-dark) !important; border: 1.5px solid var(--border-bright) !important; color: var(--text-main) !important; }
.btn-delete-user { background: var(--danger) !important; color: white !important; box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3); }

/* FILTER TAGS */
.filter-group { display: flex; flex-wrap: wrap; gap: 10px; margin: 15px 0; }
.btn-tag {
    background: var(--bg-card);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-tag.active {
    background: var(--primary-muted);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 15px var(--primary-muted);
}

/* LÖSCH-BUTTON MINI */
.btn-delete-mini {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    z-index: 10;
}
.btn-delete-mini:hover { background: var(--danger); color: white; }

.tree-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 20px;
    width: 250px;
    min-width: 250px;
}

.tree-match-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-bright);
    border-radius: 16px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    width: 100%;
}
.tree-match-card:hover { border-color: var(--primary); transform: translateX(4px); }

.tree-match-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.tree-match-team.winner {
    background: var(--primary-muted);
    color: var(--primary);
    font-weight: 700;
}

.tree-match-score {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 0.8rem;
}

/* DASHBOARD ACTIONS GRID */
.dashboard-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.action-card {
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    border: 1px solid var(--border-bright);
}
.action-card:active { transform: scale(0.96); background: var(--bg-card-hover); }
.action-card span { font-weight: 800; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); }

.action-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    color: var(--primary);
    border: 1px solid var(--border);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.action-icon.deckel { color: #38bdf8; }
.action-icon.pyramide { color: var(--primary); }
.action-icon.cm { color: #f59e0b; }
.action-icon.tracker { color: #6366f1; }

/* MODAL OVERLAY & CONTENT */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 9, 15, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    width: 100%;
    max-width: 450px;
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: 28px;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.4rem; font-weight: 800; color: var(--text-main); }
.btn-close-modal { background: none; border: none; color: var(--text-muted); font-size: 1.8rem; cursor: pointer; }

.player-info-card { background: var(--bg-dark); padding: 16px; border-radius: 16px; border: 1px solid var(--border); margin-bottom: 24px; }
.info-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.info-row:last-child { margin-bottom: 0; }
.info-row .label { color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.info-row .value { font-weight: 700; color: var(--text-main); }
.info-row .value.highlight { color: var(--primary); }

.history-section h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1.5px; margin-bottom: 12px; }
.mini-history-list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; }
.mini-history-item { background: rgba(255,255,255,0.03); padding: 10px 14px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.mini-history-item .winner { color: var(--primary); font-weight: 700; }

.modal-footer { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

/* PYRAMIDE TRIANGLE SHAPE */
.pyramide-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px; 
    padding: 150px;
}
.pyramide-row { 
    display: flex; 
    justify-content: center; 
    gap: 15px; 
    width: 100%; 
}
.pyramide-player, .pyramide-placeholder {
    position: relative;
    background: var(--bg-card);
    border: 1.5px solid var(--border-bright);
    border-radius: 16px;
    padding: 10px 8px;
    width: 120px;
    height: 115px;
    text-align: center;
    box-shadow: 0 8px 15px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pyramide-placeholder {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    pointer-events: none;
}
.pyramide-placeholder.ghost { opacity: 0; }
.pyramide-player:active { transform: scale(0.92); }
.pyramide-player.challengeable { 
    border-color: var(--primary); 
    box-shadow: 0 0 20px var(--primary-muted); 
    border-width: 2px;
}
.pyramide-player.me { 
    background: var(--primary); 
    border-color: transparent; 
    box-shadow: 0 0 30px var(--primary-muted);
}
.pyramide-player.me .firstname, .pyramide-player.me .lastname, .pyramide-player.me .rank { color: var(--bg-dark); }
.pyramide-player .rank { font-weight: 900; color: var(--primary); display: block; font-size: 1.15rem; line-height: 1; }
.pyramide-player .firstname { font-size: 0.8rem; font-weight: 800; line-height: 1.1; color: var(--text-main); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.pyramide-player .lastname { font-size: 0.8rem; font-weight: 800; line-height: 1.1; color: var(--text-main); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.pyramide-player .lk-badge { 
    font-size: 0.65rem; 
    background: rgba(255,255,255,0.08); 
    padding: 2px 6px; 
    border-radius: 6px; 
    color: var(--text-muted); 
    font-weight: 700;
}
.pyramide-player.me .lk-badge { background: rgba(0,0,0,0.1); color: var(--bg-dark); opacity: 0.8; }

/* DASHBOARD FEED 2-COL GRID */
.dashboard-grid.compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.compact-schedule { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 14px; position: relative; border-left: 4px solid var(--primary); margin-bottom: 0 !important; }
.type-icon { position: absolute; top: 10px; right: 10px; color: var(--primary); opacity: 0.6; }
.match-time { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.match-names { display: flex; flex-direction: column; gap: 2px; }
.player { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.player.highlight { color: var(--primary); }
.player.winner { color: var(--primary); }
.vs-mini { font-size: 0.6rem; font-weight: 900; color: var(--text-muted); text-transform: uppercase; opacity: 0.4; }
.match-action-text { font-size: 0.65rem; color: var(--text-muted); font-weight: 600; margin-top: 6px; }

/* NAVIGATION */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: var(--glass);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 12px 0 28px;
    z-index: 100;
}
.nav-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--text-muted); gap: 4px; width: 20%; cursor: pointer; }
.nav-item.active { color: var(--primary); }
.nav-item span { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; }

/* UTILS */
.empty-state { text-align: center; padding: 30px; color: var(--text-muted); border: 1.5px dashed var(--border); border-radius: 20px; width: 100%; }
.input-field { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 12px; color: var(--text-main); font-family: inherit; }
.btn-primary { width: 100%; padding: 14px; background: var(--primary); color: var(--bg-dark); border-radius: 14px; border: none; font-weight: 800; cursor: pointer; box-shadow: 0 4px 15px var(--primary-muted); }
.btn-delete { background: var(--danger); color: white; border: none; padding: 8px; border-radius: 8px; cursor: pointer; }
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}
.log-info { display: flex; flex-direction: column; gap: 2px; }
.log-name { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.log-meta { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.log-preis { font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; font-size: 1rem; }

.tree-match-meta {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    font-size: 0.75rem;
}

/* SETTINGS & SWITCHES */
.settings-section {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.settings-section h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

/* Switch Toggle Row */
.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-bright);
}
.switch-row:last-child {
    border-bottom: none;
}
.switch-label {
    display: flex;
    flex-direction: column;
}
.switch-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}
.switch-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* iOS-style Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}
.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
    border-radius: 34px;
    border: 1px solid var(--border-bright);
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}
input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--bg-dark);
}

/* Selectable Toggle Buttons (Multiple Select) */
.toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.btn-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--border-bright);
    color: var(--text-muted);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-toggle:active {
    transform: scale(0.95);
}
.btn-toggle.active {
    background: var(--primary-muted);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 15px var(--primary-muted);
}

