/* ═══════════════════════════════════════════════════════════
   Tower 3D Viewer - Full Stylesheet
   ═══════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Tajawal', sans-serif;
    background: #0a0a1a;
    overflow: hidden;
    color: #f1f5f9;
    direction: rtl;
}

#tower-container {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}
#tower-container canvas { display: block; }

/* ── HUD Overlay ── */
#tower-hud {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 100; pointer-events: none;
    padding: 16px 20px;
}
#tower-hud > * { pointer-events: auto; }

.hud-building-name {
    font-size: 22px; font-weight: 800;
    text-shadow: 0 2px 12px rgba(0,0,0,0.6);
    margin-bottom: 8px;
}

#hudStats {
    display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px;
}
.hud-stat {
    background: rgba(15,23,42,0.75); backdrop-filter: blur(8px);
    padding: 6px 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
    border: 1px solid rgba(255,255,255,0.08);
}
.hud-stat.occupied .hud-stat-num { color: #f5365c; }
.hud-stat.available .hud-stat-num { color: #2dce89; }
.hud-stat.rate .hud-stat-num { color: #11cdef; }
.hud-stat-num { font-weight: 800; margin-left: 4px; }

.hud-controls {
    display: flex; align-items: center; gap: 10px;
    position: fixed; bottom: 20px; right: 90px; z-index: 100;
}
.hud-controls button {
    width: 44px; height: 44px; border-radius: 12px;
    background: rgba(15,23,42,0.8); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    color: #f1f5f9; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.25s; pointer-events: auto;
}
.hud-controls button:hover {
    background: rgba(30,41,59,0.95);
    border-color: rgba(255,255,255,0.2);
    transform: scale(1.08);
}

/* ── Floor Selector ── */
#floorSelector {
    position: fixed; left: 20px; top: 50%; transform: translateY(-50%);
    z-index: 100; pointer-events: auto;
}
.floor-selector-title {
    text-align: center; font-size: 12px; font-weight: 700;
    color: #94a3b8; margin-bottom: 6px;
}
.floor-selector-list {
    display: flex; flex-direction: column; gap: 3px;
    max-height: 60vh; overflow-y: auto; padding: 4px;
    scrollbar-width: thin; scrollbar-color: #334155 transparent;
    background: rgba(15,23,42,0.7); backdrop-filter: blur(8px);
    border-radius: 14px; border: 1px solid rgba(255,255,255,0.08);
}
.floor-btn {
    width: 36px; height: 26px; border: none; border-radius: 6px;
    font-size: 11px; font-weight: 700; cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    background: rgba(255,255,255,0.05); color: #94a3b8;
    transition: all 0.2s;
}
.floor-btn:hover { background: rgba(255,255,255,0.15); color: #fff; transform: scale(1.1); }
.floor-btn-available { background: rgba(45,206,137,0.15); color: #2dce89; }
.floor-btn-occupied  { background: rgba(245,54,92,0.15); color: #f5365c; }
.floor-btn-empty     { background: rgba(255,255,255,0.03); color: #475569; }
.floor-btn.active    { background: rgba(212,175,55,0.35); color: #D4AF37; box-shadow: 0 0 8px rgba(212,175,55,0.4); transform: scale(1.15); }

/* ── Back to City Button ── */
#btnBackToCity {
    width: 44px; height: 44px; border-radius: 12px;
    background: rgba(15,23,42,0.8); backdrop-filter: blur(8px);
    border: 1px solid rgba(212,175,55,0.3); color: #D4AF37;
    font-size: 18px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    transition: all 0.25s;
}
#btnBackToCity:hover {
    background: rgba(212,175,55,0.2); border-color: rgba(212,175,55,0.6);
    box-shadow: 0 0 12px rgba(212,175,55,0.3); transform: scale(1.1);
}

/* ── Legend ── */
.hud-legend {
    position: fixed; bottom: 20px; left: 20px; z-index: 100;
    display: flex; gap: 16px;
    background: rgba(15,23,42,0.75); backdrop-filter: blur(8px);
    padding: 10px 18px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 13px; font-weight: 600;
    pointer-events: auto;
}
.legend-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-left: 6px; vertical-align: middle;
}
.legend-dot.green { background: #2dce89; box-shadow: 0 0 6px #2dce89; }
.legend-dot.red   { background: #f5365c; box-shadow: 0 0 6px #f5365c; }

/* ── Tooltip ── */
.tower-tooltip {
    position: fixed; z-index: 200; pointer-events: none;
    background: rgba(15,23,42,0.92); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px; padding: 10px 14px;
    font-family: 'Tajawal', sans-serif; direction: rtl;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    max-width: 240px;
}
.tt-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.tt-row  { font-size: 12px; color: #94a3b8; display: flex; align-items: center; gap: 6px; }
.tt-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tt-dot.dot-green { background: #2dce89; }
.tt-dot.dot-red   { background: #f5365c; }
.tt-dot.dot-amber { background: #f59e0b; }

/* ═══════ Office Detail Modal ═══════ */
.tower-modal-overlay {
    position: fixed; inset: 0; z-index: 9000;
    background: rgba(0,0,0,0.65); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    animation: modalFadeIn 0.25s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; } to { opacity: 1; }
}

.tower-modal {
    background: #1e293b; border-radius: 20px;
    width: 92%; max-width: 480px; max-height: 88vh;
    overflow-y: auto; position: relative;
    border: 1px solid #334155;
    box-shadow: 0 30px 70px rgba(0,0,0,0.5);
    animation: modalSlideIn 0.3s ease;
    scrollbar-width: thin; scrollbar-color: #475569 transparent;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close-btn {
    position: absolute; top: 12px; left: 12px; z-index: 10;
    width: 34px; height: 34px; border-radius: 10px;
    background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.15);
    color: #fff; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.modal-close-btn:hover { background: rgba(255,255,255,0.15); }

.modal-header {
    padding: 28px 24px 20px; display: flex; align-items: center; gap: 16px;
    color: #fff;
}
.modal-header-occupied  { background: linear-gradient(135deg, #dc2626, #ef4444); }
.modal-header-available { background: linear-gradient(135deg, #059669, #10b981); }

.modal-logo img {
    width: 56px; height: 56px; border-radius: 14px;
    object-fit: cover; background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.2);
}
.modal-header-text h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.modal-status-badge {
    display: inline-block; padding: 3px 12px; border-radius: 14px;
    font-size: 12px; font-weight: 700;
    background: rgba(255,255,255,0.2);
}

.modal-info-row {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.modal-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.modal-label { color: #94a3b8; font-size: 13px; min-width: 100px; }
.modal-value { font-weight: 600; font-size: 14px; }

.modal-video {
    padding: 12px 24px;
}
.modal-video iframe,
.modal-video video {
    width: 100%; border-radius: 12px; aspect-ratio: 16/9;
    background: #000;
}

.modal-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 18px 24px 24px;
}
.modal-btn {
    padding: 11px 16px; border-radius: 12px; border: none;
    cursor: pointer; font-family: 'Tajawal', sans-serif;
    font-weight: 700; font-size: 13px;
    text-decoration: none; text-align: center;
    flex: 1; min-width: 90px;
    transition: all 0.25s; display: inline-block;
}
.modal-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }

.modal-btn-book     { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
.modal-btn-whatsapp { background: #25D366; color: #fff; }
.modal-btn-email    { background: #3b82f6; color: #fff; }
.modal-btn-visit    { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }

/* ── Company Group Modal ── */
.tower-modal-wide { max-width: 580px; }
.modal-header-company { background: linear-gradient(135deg, #6366f1, #a855f7); }

/* ── Loading Screen ── */
#tower-loading {
    position: fixed; inset: 0; z-index: 10000;
    background: #0a0a1a;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 20px;
    transition: opacity 0.5s;
}
#tower-loading.fade-out { opacity: 0; pointer-events: none; }
.loading-spinner {
    width: 48px; height: 48px; border-radius: 50%;
    border: 4px solid #1e293b; border-top-color: #2dce89;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    font-size: 16px; color: #94a3b8; font-weight: 600;
}

/* ── PWA Install Banner ── */
.pwa-install-banner {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 8000;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; gap: 14px;
    direction: rtl; font-family: 'Tajawal', sans-serif;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.pwa-install-banner.visible { transform: translateY(0); }

.pwa-install-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: linear-gradient(135deg, #2dce89, #11cdef);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.pwa-install-text { flex: 1; }
.pwa-install-text h4 {
    font-size: 15px; font-weight: 700; color: #f1f5f9; margin: 0 0 2px;
}
.pwa-install-text p {
    font-size: 12px; color: #94a3b8; margin: 0;
}
.pwa-install-btn {
    padding: 10px 20px; border-radius: 10px; border: none;
    background: linear-gradient(135deg, #2dce89, #11cdef);
    color: #0f172a; font-weight: 700; font-size: 14px;
    font-family: 'Tajawal', sans-serif; cursor: pointer;
    white-space: nowrap; transition: transform 0.2s;
}
.pwa-install-btn:active { transform: scale(0.95); }
.pwa-install-close {
    width: 32px; height: 32px; border-radius: 8px;
    background: rgba(255,255,255,0.08); border: none;
    color: #94a3b8; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ── Safe Area Padding (notched displays) ── */
@supports (padding: env(safe-area-inset-top)) {
    #tower-hud {
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-right: calc(20px + env(safe-area-inset-right));
        padding-left: calc(20px + env(safe-area-inset-left));
    }
    .hud-controls {
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: calc(90px + env(safe-area-inset-right));
    }
    .hud-legend {
        bottom: calc(20px + env(safe-area-inset-bottom));
        left: calc(20px + env(safe-area-inset-left));
    }
    #floorSelector {
        left: calc(20px + env(safe-area-inset-left));
    }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .hud-building-name { font-size: 16px; }
    #hudStats { gap: 8px; }
    .hud-stat { font-size: 12px; padding: 4px 10px; }
    .hud-controls { bottom: 10px; right: 80px; }
    .hud-legend { bottom: 10px; left: 10px; font-size: 11px; }
    #floorSelector { left: 8px; }
    .tower-modal { width: 96%; max-width: 400px; }
}

/* ── Touch-friendly mobile targets ── */
@media (max-width: 1024px) and (pointer: coarse) {
    .hud-controls button {
        width: 52px; height: 52px; border-radius: 14px; font-size: 22px;
    }
    .hud-controls a {
        width: 52px !important; height: 52px !important;
        border-radius: 14px !important; font-size: 20px !important;
    }
    .floor-btn {
        width: 44px; height: 34px; border-radius: 8px;
        font-size: 13px; font-weight: 800;
    }
    .floor-selector-list {
        gap: 4px; padding: 6px;
    }
    .hud-legend {
        padding: 12px 20px; border-radius: 14px; font-size: 13px;
    }
    .legend-dot { width: 12px; height: 12px; }
    .tower-tooltip { font-size: 14px; padding: 12px 16px; }
    .modal-close-btn {
        width: 40px; height: 40px; font-size: 22px; border-radius: 12px;
    }
    .modal-btn {
        padding: 14px 18px; font-size: 14px; border-radius: 14px;
        min-height: 48px;
    }
}

/* ── PWA standalone mode adjustments ── */
@media (display-mode: standalone) {
    body { -webkit-user-select: none; user-select: none; }
    .pwa-install-banner { display: none !important; }
}
