/* =============================================
   WESTER SOLUTIONS — Hub Design v3
   ============================================= */

:root {
    --primary: #2196F3;
    --primary-dark: #1565C0;
    --primary-glow: rgba(33, 150, 243, 0.4);
    --primary-glow-strong: rgba(33, 150, 243, 0.7);
    --bg: #080c14;
    --bg-card: #111827;
    --bg-input: #1a2035;
    --text: #e8eaf0;
    --text-muted: #6b7490;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #f44336;
    --border: #1e2a3a;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text);
    min-height: 100vh; overflow-x: hidden;
}

/* ---- LOGIN ---- */
.login-box {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: var(--bg-card); padding: 40px; border-radius: var(--radius);
    width: 90%; max-width: 380px; text-align: center; border: 1px solid var(--border);
}
.login-box h1 { font-size: 24px; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.login-box input {
    width: 100%; padding: 12px 16px; margin-bottom: 12px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-input); color: var(--text); font-size: 15px;
}
.login-box input:focus { outline: none; border-color: var(--primary); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ---- BUTTONS ---- */
.btn-primary {
    width: 100%; padding: 12px; background: var(--primary); color: #fff;
    border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-small {
    padding: 6px 12px; background: transparent; color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 6px; font-size: 12px; cursor: pointer;
}
.btn-action {
    padding: 8px 16px; background: var(--primary); color: #fff;
    border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* ---- TOP BAR ---- */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
    background: var(--primary); color: #fff; border: none; border-radius: 8px;
    width: 36px; height: 36px; font-size: 14px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
#pageTitle { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
#userName { font-size: 13px; color: var(--text-muted); }

/* ============================================
   HUB SCENE — Handy + Module im Kreis
   ============================================ */

.hub-view {
    padding: 0 !important;
    padding-bottom: 80px !important;
}

.hub-scene {
    position: relative;
    width: 100%;
    height: calc(100vh - 110px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* SVG Linien Layer */
.hub-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}
.hub-svg line {
    stroke: var(--primary);
    stroke-width: 2;
    opacity: 0;
    filter: drop-shadow(0 0 4px var(--primary-glow));
    transition: opacity 0.6s ease;
}
.hub-svg line.visible {
    opacity: 0.6;
    animation: line-pulse 3s infinite;
}
@keyframes line-pulse {
    0%, 100% { opacity: 0.4; stroke-width: 2; }
    50% { opacity: 0.8; stroke-width: 3; }
}

/* ---- HANDY (Zentrum) ---- */
.hub-phone {
    position: relative;
    z-index: 10;
    width: 200px;
    height: 400px;
    background: linear-gradient(145deg, #141e30, #0f1724);
    border: 2px solid var(--primary);
    border-radius: 28px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 30px var(--primary-glow),
        0 0 60px rgba(33, 150, 243, 0.15),
        inset 0 0 20px rgba(33, 150, 243, 0.05);
    transition: all 0.4s ease;
    animation: phone-breathe 4s infinite;
}
.hub-phone:hover {
    transform: scale(1.03);
    box-shadow:
        0 0 40px var(--primary-glow-strong),
        0 0 80px rgba(33, 150, 243, 0.2),
        inset 0 0 30px rgba(33, 150, 243, 0.08);
}
.hub-phone.expanded {
    box-shadow:
        0 0 50px var(--primary-glow-strong),
        0 0 100px rgba(33, 150, 243, 0.25);
}

@keyframes phone-breathe {
    0%, 100% { box-shadow: 0 0 30px var(--primary-glow), 0 0 60px rgba(33,150,243,0.15); }
    50% { box-shadow: 0 0 45px var(--primary-glow-strong), 0 0 80px rgba(33,150,243,0.2); }
}

.hub-phone-notch {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: 50px; height: 5px; background: #1a2540; border-radius: 3px;
}
.hub-phone-bar {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; background: #1a2540; border-radius: 2px;
}

/* Detail Modal (wenn man aufs Handy klickt) */
.detail-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; padding: 20px;
    animation: fadeIn 0.3s ease;
}
.detail-modal {
    background: linear-gradient(145deg, #141e30, #0f1724);
    border: 2px solid var(--primary);
    border-radius: 28px;
    width: 100%; max-width: 320px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 0 40px var(--primary-glow-strong), 0 0 80px rgba(33,150,243,0.15);
    position: relative;
    padding: 20px 16px 16px;
}
.detail-modal-notch {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 50px; height: 5px; background: var(--primary); border-radius: 3px;
    opacity: 0.5; cursor: pointer;
}
.detail-modal-notch:hover { opacity: 1; }
.detail-modal-scroll {
    max-height: calc(85vh - 50px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}
.detail-modal-scroll::-webkit-scrollbar { width: 3px; }
.detail-modal-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.detail-modal-title {
    text-align: center; font-size: 16px; font-weight: 700;
    color: var(--primary); margin-bottom: 12px;
}

.pd-section {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.pd-section:last-child { border-bottom: none; }
.pd-section.gewinn {
    background: rgba(33,150,243,0.05);
    border-radius: 10px;
    padding: 10px;
    border: 1px solid rgba(33,150,243,0.15);
    margin-top: 4px;
}

.pd-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pd-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 11px;
}
.pd-row span:first-child { color: var(--text-muted); }
.pd-row span:last-child { font-weight: 600; }
.pd-row .green { color: var(--success); }
.pd-row .red { color: var(--danger); }
.pd-row.total { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; }
.pd-row.total span { font-weight: 700; }
.pd-row.big { font-size: 13px; padding: 4px 0; }
.pd-row.big span:last-child { font-weight: 700; font-size: 14px; }
.pd-row.highlight span:last-child { color: var(--success); font-size: 15px; }

.pd-divider { height: 1px; background: var(--border); margin: 6px 0; }

.pd-steuer-input {
    display: flex; align-items: center; gap: 2px;
}
.pd-steuer-input input {
    width: 42px; padding: 3px 4px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-size: 11px; text-align: right;
}
.pd-steuer-input input:focus { outline: none; border-color: var(--primary); }

.phone-stat-divider {
    width: 80%; height: 1px; background: rgba(255,255,255,0.08);
    margin: 2px auto;
}
.phone-stat { margin-bottom: 2px; }
.phone-stat-value { font-size: 16px !important; }
.phone-stat-label { font-size: 8px !important; }
.hub-phone-screen {
    text-align: center; padding: 10px;
}
.phone-logo {
    font-size: 20px; font-weight: 800; color: var(--primary);
    text-shadow: 0 0 20px var(--primary-glow);
    margin-bottom: 2px;
}
.phone-title {
    font-size: 7px; color: var(--text-muted); font-weight: 600;
    letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px;
}
.phone-stats { min-height: 80px; }
.phone-hint {
    color: var(--text-muted); font-size: 11px;
    animation: hint-blink 2s infinite;
}
@keyframes hint-blink {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
.phone-stat {
    margin-bottom: 6px;
}
.phone-stat-value {
    font-size: 18px; font-weight: 700; display: block;
}
.phone-stat-value.green { color: var(--success); }
.phone-stat-value.red { color: var(--danger); }
.phone-stat-value.blue { color: var(--primary); }
.phone-stat-label {
    font-size: 9px; color: var(--text-muted); text-transform: uppercase;
}

/* ---- MODULE (Kreis) ---- */
.hub-modules {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}

.hub-mod {
    position: absolute;
    width: 70px; height: 70px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border);
    cursor: pointer;
    pointer-events: all;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    transform: scale(0);
}
.hub-mod.show {
    opacity: 1;
    transform: scale(1);
}
.hub-mod[data-active="1"] {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    animation: mod-glow 3s infinite;
}
.hub-mod[data-active="1"]:hover {
    transform: scale(1.15) !important;
    box-shadow: 0 0 25px var(--primary-glow-strong);
}
.hub-mod[data-active="0"] {
    border-color: #2a2a3a;
    opacity: 0.4;
}
.hub-mod[data-active="0"].show {
    opacity: 0.4;
}
.hub-mod[data-active="0"]:hover {
    opacity: 0.7;
    transform: scale(1.1) !important;
}

@keyframes mod-glow {
    0%, 100% { box-shadow: 0 0 15px var(--primary-glow); }
    50% { box-shadow: 0 0 25px var(--primary-glow-strong); }
}

.mod-glow {
    position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    opacity: 0; z-index: -1;
}
.hub-mod[data-active="1"] .mod-glow { opacity: 0.3; }

.mod-icon { font-size: 22px; line-height: 1; }
.mod-name { font-size: 8px; font-weight: 700; margin-top: 3px; text-align: center; line-height: 1.1; }

/* Alle Module Button */
.alle-module-btn {
    text-align: center;
    padding: 12px 16px;
    animation: fadeIn 0.5s ease;
}
.alle-module-btn button {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 25px;
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-glow);
    transition: all 0.3s;
}
.alle-module-btn button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--primary-glow-strong);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- WARNUNGEN ---- */
.hub-warnungen { padding: 0 16px 100px; }
.warnung-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--bg-card); border-radius: 8px;
    margin-bottom: 8px; border-left: 3px solid var(--warning); font-size: 13px;
}
.warnung-item.kritisch { border-left-color: var(--danger); }
.warnung-item.info { border-left-color: var(--primary); }

/* ---- VIEWS ---- */
.view { padding: 16px; padding-bottom: 100px; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.view-header h2 { font-size: 20px; }

.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
    cursor: pointer; transition: border-color 0.2s;
}
.card:hover { border-color: var(--primary); }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.card-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.card-row .label { color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8); display: flex; align-items: center;
    justify-content: center; z-index: 100; padding: 16px;
}
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); width: 100%; max-width: 500px;
    max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal-title {
    font-size: 18px; font-weight: 700; margin-bottom: 16px;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-aktiv { background: rgba(76,175,80,0.2); color: var(--success); }
.badge-interessent { background: rgba(33,150,243,0.2); color: var(--primary); }
.badge-besichtigung { background: rgba(255,152,0,0.2); color: var(--warning); }
.badge-angebot { background: rgba(156,39,176,0.2); color: #ce93d8; }
.badge-gekuendigt { background: rgba(244,67,54,0.2); color: var(--danger); }
.badge-mitarbeiter { background: rgba(33,150,243,0.2); color: var(--primary); }
.badge-teamleiter { background: rgba(255,152,0,0.2); color: var(--warning); }
.badge-objektleiter { background: rgba(76,175,80,0.2); color: var(--success); }

/* ---- BOTTOM NAV ---- */
.bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-card); border-top: 1px solid var(--border);
    display: flex; justify-content: space-around;
    padding: 6px 0 env(safe-area-inset-bottom, 6px); z-index: 50;
}
.nav-item {
    background: none; border: none; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 12px; cursor: pointer;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 20px; }
.nav-label { font-size: 10px; font-weight: 600; }

/* ---- RESPONSIVE ---- */
@media (max-width: 380px) {
    .hub-mod { width: 55px; height: 55px; }
    .mod-icon { font-size: 18px; }
    .mod-name { font-size: 7px; }
}
@media (max-width: 480px) {
    .form-row { flex-direction: column; gap: 0; }
}
@media (min-width: 768px) {
    .bottomnav { display: none; }
    .hub-mod { width: 80px; height: 80px; }
    .mod-icon { font-size: 26px; }
    .mod-name { font-size: 9px; }
}
