:root {
    --gold: #d4af37; --blue: #3498db; --text: #ecf0f1; --danger: #ff4757;
    --success: #2ecc71; --nav-h: 55px; --manual-zoom: 1; --theme: var(--gold);
    --bg-dark: #121212; --modal-bg: #1e1e1e; --txt-bold: #d6d6d6; --warning: #f1c40f;
    --font-main: 'Inter', sans-serif;
    --font-arabic: 'Amiri', serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0; padding: 0; background: #000; color: var(--text);
    font-family: 'Segoe UI', sans-serif; overflow: hidden; height: 100dvh; display: flex; flex-direction: column;
}

header { 
    background: #111; padding: 8px 15px; position: relative;
    display: flex; flex-direction: column; align-items: center;
    border-bottom: 2px solid var(--theme); z-index: 1000; flex-shrink: 0;
}
#main-title { margin: 0; font-size: 0.8rem; letter-spacing: 2px; text-transform: uppercase; color: var(--theme); font-weight: bold; }
.sub-header { color: #fff; font-size: 0.6rem; margin: 1px 0; text-align: center; }
#fs-icon-btn { position: absolute; right: 15px; top: 15px; color: var(--theme); cursor: pointer; font-size: 1.2rem; }

/* Container Utama yang menyokong Pinch Zoom */
#viewport { 
    flex: 1; position: relative; overflow: hidden; 
    display: flex; flex-direction: column; 
    touch-action: none; /* Wajib: mematikan fungsi skrol asal browser untuk zoom jari */
}

/* Enjin Stage dengan Akselerasi GPU */
#stage { 
    width: 400px; height: 400px; position: relative; 
    will-change: transform; 
    transition: transform 0.1s cubic-bezier(0.25, 0.1, 0.25, 1); 
}

#img-earth {
    transition: opacity 0.4s ease-in-out; /* Kelajuan pudar */
    opacity: 1;
}
#img-jam-tawaf {
    transition: opacity 0.4s ease-in-out; /* Kelajuan pudar */
    opacity: 1;
}

.fade-out {
    opacity: 0 !important;
}

.modal-quran-quote { background-color: #736d6b; padding: 10px; border-radius: 4px; text-align: center; font-size: 0.7rem; margin: 10px 0; border-left: 4px solid var(--primary-color); }

/* UI Ikon Zoom % Transfaren */
#zoom-ui { 
    position: absolute; top: 8px; right: 8px; z-index: 2000; 
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}

#zoom-pop { 
    display: none; background: rgba(20, 20, 20, 0.85); padding: 10px; 
    border-radius: 20px; border: 1.5px solid var(--theme); 
    width: 35px; height: 200px; flex-direction: column; align-items: center; 
    backdrop-filter: blur(15px); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
       
/* Auto-Resize Map berdasarkan ruang tersedia */
.maximized-mode #stage { transform: scale(calc(var(--manual-zoom) * 0.62)) translateY(-25px); }
#viewport:not(.maximized-mode) #stage { transform: scale(calc(var(--manual-zoom) * 1.3)); }

/* Tambah Pointer pada Butang Zoom */
#zoom-btn { 
    background:rgba(0,0,0,0.3); color:var(--theme); padding:5px 12px; 
    border-radius:15px; font-size:9px; border:1.5px solid rgba(255,255,255,0.1); 
    font-weight:bold; backdrop-filter: blur(5px); 
    cursor: pointer; /* Menukar kursor kepada bentuk tangan (pointer) */
    transition: 0.2s;
}
#zoom-btn:hover { background: rgba(0,0,0,0.5); border-color: var(--theme); }

/* Visual Pointer Tengah Peta (Crosshair) */
#map-pointer {
    position: absolute;
    top: 50%; left: 50%;
    width: 30px; height: 30px;
    transform: translate(-50%, -50%);
    border: 1px solid var(--theme);
    border-radius: 50%;
    z-index: 15;
    pointer-events: none; /* Supaya tidak mengganggu sentuhan jari */
    opacity: 0.5;
}
#map-pointer::before, #map-pointer::after {
    content: ''; position: absolute; background: var(--theme);
}
/* Garisan Melintang Crosshair */
#map-pointer::before { top: 50%; left: -5px; width: 40px; height: 1px; }
/* Garisan Menegak Crosshair */
#map-pointer::after { left: 50%; top: -5px; width: 1px; height: 40px; }

/* Pointer Slider Zoom */
#v-zoom { cursor: ns-resize; }

#viewport { flex:1; position:relative; overflow:hidden; display:flex; flex-direction:column; touch-action: none; }

#stage-container { transition: transform 0.1s cubic-bezier(0.1, 0.5, 0.1, 1); will-change: transform; transform-origin: center; position: absolute; cursor: grab; flex:1; display:flex; justify-content:center; align-items:center; background: radial-gradient(circle, #1a1a1a 0%, #000 100%); position:relative; overflow: hidden; }
#stage { position:relative; width:400px; height:400px; display:flex; justify-content:center; align-items:center; will-change: transform; transition: transform 0.4s cubic-bezier(0.1, 0.7, 0.1, 1); }

.maximized-mode #stage { transform: scale(calc(var(--manual-zoom) * 0.65)) translateY(-20px); --auto-zoom: 0.55; }

#viewport:not(.maximized-mode) #stage { transform: scale(calc(var(--manual-zoom) * 1.3)); }
#zoom-pop.active { display:flex; }
#v-zoom { appearance: slider-vertical; width:8px; height:100%; accent-color:var(--theme); opacity:0.6; }

/* Visual Pointer Tengah Peta (Crosshair) */
#map-pointer {
    position: absolute;
    top: 50%; left: 50%;
    width: 30px; height: 30px;
    transform: translate(-50%, -50%);
    border: 1px solid var(--theme);
    border-radius: 50%;
    z-index: 15;
    pointer-events: none; /* Supaya tidak mengganggu sentuhan jari */
    opacity: 0.5;
}
#map-pointer::before, #map-pointer::after {
    content: ''; position: absolute; background: var(--theme);
}
/* Garisan Melintang Crosshair */
#map-pointer::before { top: 50%; left: -5px; width: 40px; height: 1px; }
/* Garisan Menegak Crosshair */
#map-pointer::after { left: 50%; top: -5px; width: 1px; height: 40px; }

/* Pointer Slider Zoom */
#v-zoom { cursor: ns-resize; }

.layer { position:absolute; width:100%; height:100%; object-fit:contain; pointer-events:none; }
#lines-layer { position: absolute; width: 85vw; max-width: 320px; height: 85vw; max-height: 320px; z-index: 10; pointer-events: none; }
.line { position: absolute; width: 2px; height: 45%; bottom: 50%; left: 50%; transform-origin: bottom; }
.info-box { position: absolute; top: -98px; left: -55px; width: 115px; font-size: 9px; background: rgba(0,0,0,0.9); border: 1px solid white; padding: 5px; border-radius: 4px; text-align: center; color: white; line-height: 1.3; }

/* Container Panel Bandar */
#card-panel { 
    background: rgba(10,10,10,0.98); 
    border-top: 2.5px solid var(--theme); 
    z-index: 4000; 
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header Panel dengan Pointer */
.panel-header { 
    padding: 12px 18px; 
    background: var(--theme); 
    color: #000; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    cursor: pointer; /* Menambah pointer pada seluruh bar header */
}

/* Gaya Teks Multi-Line (hg) */
.hg { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.hg-l { text-align: left; border-right: 1px solid rgba(0,0,0,0.1); }
.hg-r { text-align: right; padding-right: 10px; }

/* Saiz Font Spesifik */
.hg-b1 { font-size: 10px; font-weight: 900; letter-spacing: 0.5px; }
.hg-b2 { font-size: 13px; font-family: monospace; font-weight: 900; }
.hg-b3 { font-size: 7.5px; font-weight: 700; opacity: 0.8; }

/* Icon Toggle */
#pIcon { 
    width: 15px; 
    text-align: right; 
    font-size: 16px; 
    cursor: pointer; 
    transition: 0.3s;
    right: 12px;
}

#card-panel { background: rgba(10, 10, 10, 0.98); border-top: 2px solid var(--theme); z-index: 2000; display: flex; flex-direction: column; transition: transform 0.4s ease; margin-bottom: var(--nav-h); }
.panel-header1 { padding: 12px 15px; background: var(--theme); color: #000; display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; cursor: pointer; }
.panel-header { padding:12px 15px; background:var(--theme); color:#000; display:flex; align-items:center; cursor:pointer; justify-content: space-between; font-weight: 800; }

/* Logik Label 3 Baris Panel Utama */
.hg { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.hg-l { text-align: left; border-right: 1px solid rgba(0,0,0,0.1); padding-right: 10px; }
.hg-r { text-align: right; padding-right: 5px; }
.hg-b1 { font-size: 10px; font-weight: 900; opacity: 0.8; letter-spacing: 1px; }
.hg-b2 { font-size: 12px; font-family: monospace; font-weight: 900; white-space: nowrap; }
.hg-b3 { font-size: 8px; font-weight: 700; opacity: 0.8; margin-top: 1px; }

.header-left { font-weight: 900; font-size: 13px; text-align: left; }
.header-center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.header-center .top-row { display: flex; align-items: baseline; gap: 8px; font-weight: 900; font-family: monospace; }
.header-center .day-title { font-size: 16px; text-transform: uppercase; }
.header-center .day-text { font-size: 16px; text-transform: uppercase; }
.header-center .time-text { font-size: 16px; }
.header-center .date-text { font-size: 11px; font-weight: 700; margin-top: 2px; font-family: sans-serif; }
.header-right { text-align: right; font-size: 18px; font-weight: bold; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 8px; padding: 10px; overflow-y: auto; max-height: 0; transition: max-height 0.4s ease; }
#card-panel.open .info-grid { max-height: 38vh; }

.city-card { background: #1a1a1a; border-radius: 6px; border-bottom: 3.5px solid var(--theme); padding: 10px; min-height: 145px; display: flex; flex-direction: column; justify-content: center; text-align: center; position: relative; }
.city-card h4 { margin: 0; color: var(--theme); font-size: 0.75rem; text-transform: uppercase; }
.location-info { font-size: 10px; color: #888; font-weight: bold; margin-bottom: 4px; }
.city-card .time-12 { font-size: 0.8rem; font-weight: bold; color: #fff; font-family: monospace; } .day-full { font-size: 0.85rem; font-weight: bold; color: #fff; font-family: monospace; }
.city-card .time-24 { font-size: 0.75rem; color: #aaa; font-family: monospace; margin-bottom: 1px; }
.city-card .hijri-text { font-size: 0.65rem; color: var(--gold); font-weight: bold; margin-top: 1px; }
.city-card .date { font-size: 0.65rem; color: #888; }

.badge-alert { font-size: 7px; padding: 1px 4px; border-radius: 3px; font-weight: bold; text-transform: uppercase; margin-top: 4px; display: inline-block; }
.bg-red { background: var(--danger); color: #fff; animation: blinker 1s infinite; }
.bg-green { background: var(--success); color: #000; }
.bg-yellow { background: var(--warning); color: #000; }
@keyframes blinker { 50% { opacity: 0.3; } }

.info-btn { position: absolute; top: -2px; left: 3px; color: var(--blue); background: none; border: none; font-size: 10px; font-weight: bold; cursor: pointer; padding: 5px; }
.remove-btn { position: absolute; top: -2px; right: 3px; color: var(--danger); background: none; border: none; font-size: 14px; font-weight: bold; cursor: pointer; padding: 5px; }

.panel-overlay { position: fixed; bottom: -100%; left: 0; width: 100%; background: #fff; color: #222; z-index: 8000; transition: bottom 0.4s ease; border-radius: 20px 20px 0 0; padding: 15px 15px calc(var(--nav-h) + 15px) 15px; }
.panel-overlay.show { bottom: 0; }
.x-red { position:absolute; top:15px; right:15px; color:var(--danger); font-size:1.5rem; cursor:pointer; font-weight:bold; line-height:1; }
.tab-menu { display:flex; gap:20px; border-bottom:1.5px solid #eee; margin-bottom:15px; }
.tab-link.active::after { content:''; position:absolute; bottom:-1.5px; left:0; width:100%; height:3px; background:var(--blue); }

/* Gaya asal tab */
.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    display: inline-block;
    color: #888; /* Warna pudar jika tidak aktif */
}

/* Gaya apabila tab aktif */
.tab-link.active {
    color: #007bff; /* Warna teks biru */
    border-bottom: 2px solid #007bff; /* Garis bawah biru */
    font-weight: bold;
}

.mobile-nav { position:fixed; bottom:0; left:0; right:0; height:var(--nav-h); background:#111; display:flex; border-top:1px solid #333; z-index:9000; padding-bottom: env(safe-area-inset-bottom); }
.nav-item { flex:1; display:flex; flex-direction:column; justify-content:center; align-items:center; font-size:10px; color:#666; cursor:pointer; }
.nav-item.active { color:var(--theme); border-top:3px solid var(--theme); background:rgba(255,255,255,0.03); }
.nav-item.active-miqat { color: var(--gold); background: #1a1a1a; }
.nav-item.active-gmt { color: var(--blue); background: #1a1a1a; }

/* UI ELEMENTS */
.setting-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; background: #f5f5f5; padding: 8px; border-radius: 8px; width: 100%; }
.setting-row select, .setting-row input[type="datetime-local"] { flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 5px; font-size: 11px; height: 35px; background: #fff; }

.checkbox-group { display: flex; align-items: center; gap: 15px; flex: 1; justify-content: center; }
.check-label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: bold; color: #444; cursor: pointer; user-select: none; }
.check-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--gold); }

.zoom-minimal { display: flex; align-items: center; gap: 12px; margin: 12px 0; background: #eee; padding: 12px; border-radius: 10px; }
.zoom-percent { font-family: monospace; font-size: 12px; font-weight: 800; color: var(--gold); background: #000; padding: 4px 8px; border-radius: 5px; min-width: 55px; text-align: center; }
#zoomSlider { flex: 1; accent-color: var(--gold); cursor: pointer; }

.btn-trash { background: var(--danger); color: white; border: none; border-radius: 5px; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; }
.btn-action { border: none; border-radius: 5px; padding: 0 10px; font-weight: bold; font-size: 9px; height: 35px; flex: 1; cursor: pointer; color: white; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 10000; display: none; justify-content: center; align-items: center; }
.modal-box { background: #fff; color: #222; border-radius: 15px; width: 90%; max-width: 380px; position: relative; padding: 25px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-title { margin: 0 0 10px 0; font-size: 18px; color: var(--danger); font-weight: 800; }
.modal-desc { font-size: 13px; color: #555; line-height: 1.5; margin-bottom: 20px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btn { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; font-size: 14px; }
.btn-cancel { background: #eee; color: #333; }
.btn-confirm { background: var(--danger); color: white; }

table {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, sans-serif;
}
/* Mengubah garisan menjadi halus dan samar */
th, td {
    border: 1px solid #e0e0e0; 
    padding: 12px;
    text-align: left;
    background-color: #333;
}
/* Latar belakang kepala jadual yang lembut */
th {
    background-color: #333;
    color: #f9f9f9;
}

/* Mengubah semua teks di dalam tag <p> menjadi justify */
p {
    text-align: justify;
}

/* Atau gunakan class khas jika mahu kesan pada perenggan tertentu sahaja */
.teks-rata {
    text-align: justify;
}