/* =========================================================
   360° Virtual Tour – Haupt-Stylesheet
   ========================================================= */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #1a1a2e;
    background: #f5f5f7;
    line-height: 1.5;
}

a { color: inherit; }

/* ---- Utilities ---- */
.hidden { display: none !important; }
.text-muted { color: #888; font-size: .875rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn-sm { padding: 5px 11px; font-size: .8125rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}
.btn-primary:hover { background: #2d2d4e; border-color: #2d2d4e; }

.btn-outline {
    background: transparent;
    color: #1a1a2e;
    border-color: #d1d1d6;
}
.btn-outline:hover { background: #f0f0f5; }
.btn-outline.active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

.btn-danger {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}
.btn-danger:hover { background: #bb2d3b; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .875rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ---- Forms ---- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 1rem;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

label {
    font-size: .875rem;
    font-weight: 500;
    color: #374151;
}
label small { font-weight: 400; color: #888; }

input[type=text],
input[type=password],
input[type=email],
input[type=file],
textarea,
select {
    padding: 8px 12px;
    border: 1px solid #d1d1d6;
    border-radius: 6px;
    font-size: .9375rem;
    font-family: inherit;
    color: #1a1a2e;
    background: #fff;
    transition: border-color .15s;
    width: 100%;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #1a1a2e;
}
textarea { resize: vertical; }

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: .5rem;
}

/* ---- Navigation ---- */
.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: #1a1a2e;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1rem;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: .875rem;
}
.admin-nav .btn-outline {
    color: #fff;
    border-color: rgba(255,255,255,.4);
}
.admin-nav .btn-outline:hover { background: rgba(255,255,255,.1); }

/* ---- Main Content ---- */
.admin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ---- Cards ---- */
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}
.card > form,
.card > .form-group {
    padding: 20px;
}

details.collapsible summary {
    list-style: none;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
}
details.collapsible summary::-webkit-details-marker { display: none; }
details.collapsible[open] summary { border-bottom: 1px solid #e5e7eb; }
details.collapsible > form { padding: 20px; }

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}
.data-table th {
    background: #fafafa;
    font-weight: 600;
    color: #6b7280;
    font-size: .8125rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.data-table td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: #6b7280;
}
.empty-state p { margin-bottom: 1rem; font-size: 1.0625rem; }

/* ---- Progress Bar ---- */
.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}
#progress-fill {
    height: 100%;
    background: #1a1a2e;
    width: 0;
    transition: width .2s;
}

/* ---- Panorama Editor ---- */
.panorama-editor-wrap {
    width: 100%;
    height: 480px;
    background: #000;
    position: relative;
    cursor: crosshair;
}
#panorama-editor {
    width: 100%;
    height: 100%;
}

/* ---- Modals ---- */
.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    z-index: 1;
}
.modal-box h2 { margin-bottom: 1.25rem; font-size: 1.125rem; }

/* ---- Login Page ---- */
.login-page {
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(0,0,0,.06);
    text-align: center;
}
.login-logo { margin-bottom: 16px; }
.login-box h1 { font-size: 1.375rem; font-weight: 700; margin-bottom: 4px; }
.login-box .subtitle { color: #6b7280; margin-bottom: 1.5rem; font-size: .9375rem; }
.login-box form { text-align: left; }

/* ---- Password Gate ---- */
.password-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.password-box {
    background: rgba(255,255,255,.95);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 40px rgba(0,0,0,.3);
    text-align: center;
}
.password-box h1 { font-size: 1.375rem; font-weight: 700; margin-bottom: 4px; }
.password-box p { color: #6b7280; margin-bottom: 1.5rem; }
.password-box form { text-align: left; }

/* ---- Tour Viewer ---- */
.viewer-page { background: #000; overflow: hidden; }
.viewer-wrap { display: flex; flex-direction: column; height: 100vh; }

.viewer-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    height: 52px;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}
.viewer-title {
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    font-size: .9375rem;
}
.viewer-scenes {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.scene-btn {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,.3);
    background: transparent;
    color: rgba(255,255,255,.8);
    font-size: .8125rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.scene-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.scene-btn.active { background: #fff; color: #1a1a2e; border-color: #fff; }

#panorama {
    flex: 1;
    min-height: 0;
}

.viewer-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 10;
}
.info-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.viewer-info.open .info-content {
    display: block;
}
.info-content {
    display: none;
    background: rgba(0,0,0,.7);
    color: #fff;
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 300px;
    font-size: .875rem;
    margin-top: 8px;
    backdrop-filter: blur(4px);
}

/* ---- Tour Grid (Startseite) ---- */
.tour-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.tour-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, transform .15s;
    overflow: hidden;
}
.tour-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.1); transform: translateY(-2px); }
.tour-card-body { padding: 20px; }
.tour-card h2 { font-size: 1.0625rem; margin-bottom: 6px; }
.tour-card p { color: #6b7280; font-size: .875rem; margin-bottom: 10px; }

/* ---- Pannellum overrides ---- */
.pnlm-container { background: #000; }
.pnlm-hotspot-base { cursor: pointer; }

/* Standard-Tooltip von Pannellum ausblenden – wir nutzen .hs-info-popup */
.pnlm-hotspot-base > div:not(.hs-info-popup) > .pnlm-tooltip { display: none !important; }

/* ---- Info-Hotspot Popup ---- */
.pnlm-hotspot-base {
    /* Kontext für absolut positioniertes Popup */
    overflow: visible !important;
}

.hs-info-popup {
    display: none;
    position: absolute;
    /* Zentriert über dem Hotspot-Icon */
    bottom: calc(100% + 16px);
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    max-width: 90vw;
    background: rgba(12, 12, 22, 0.93);
    color: #f0f0f0;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0,0,0,.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.1);
    z-index: 300;
    /* Kein pointer-events blockieren */
    pointer-events: auto;
    /* Pfeil nach unten */
    filter: drop-shadow(0 4px 12px rgba(0,0,0,.5));
}

.hs-info-popup.visible {
    display: flex;
    flex-direction: column;
    animation: hs-popup-in .18s ease;
}

@keyframes hs-popup-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Pfeil-Dreieck */
.hs-info-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-top-color: rgba(12, 12, 22, 0.93);
}

.hs-popup-label {
    padding: 13px 16px 10px;
    font-weight: 600;
    font-size: .9375rem;
    line-height: 1.35;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    /* Label nie abschneiden */
    word-break: break-word;
}

.hs-popup-comment {
    padding: 10px 16px 14px;
    font-size: .875rem;
    line-height: 1.6;
    color: rgba(240, 240, 240, .88);
    /* Langer Text: scrollbar */
    max-height: 240px;
    overflow-y: auto;
    word-break: break-word;
    overscroll-behavior: contain;
}

/* Scrollbar im Popup */
.hs-popup-comment::-webkit-scrollbar { width: 4px; }
.hs-popup-comment::-webkit-scrollbar-track { background: transparent; }
.hs-popup-comment::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.25);
    border-radius: 2px;
}
.hs-popup-comment::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .admin-main { padding: 20px 16px; }
    .viewer-header { padding: 0 12px; }
    .viewer-title { display: none; }
    .data-table td.actions { flex-direction: column; align-items: flex-start; }
}
