/* ===== Font Roboto ===== */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 300;
    font-stretch: 100%;
    src: url('https://fonts.gstatic.com/s/roboto/v51/KF07CnqEu92Fr1ME7kSn66aGLdTylUAMa3GUBHMdazTgWw.woff2') format('woff2');
    unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* Reset & Global */
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    overflow: hidden;
    height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
}


#map {
    flex: 1;
    height: 100vh;
    pointer-events: auto; /* pastikan map menerima event */
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

/* Sidebar: flex item in-flow di sebelah kiri map (bukan overlay absolute),
   sehingga map otomatis menyusut mengisi sisa ruang tanpa tertutup. */
#sidebar {
    position: relative;
    width: 340px;
    height: 100vh;
    background: white;
    z-index: 999;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s ease;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Chrome, Safari, Edge (WebKit) */
#sidebar::-webkit-scrollbar {
    width: 6px;
}
#sidebar::-webkit-scrollbar-track {
    background: transparent;
}
#sidebar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 5px;
}
#sidebar::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}
#sidebar::-webkit-scrollbar-button {
    display: none;   /* hilangkan tombol panah atas/bawah */
    height: 0;
    width: 0;
}

#sidebar.closed {
    width: 0;
    padding: 0;              /* hilangkan padding agar tidak ada sisa */
    box-shadow: none;
    overflow: hidden;        /* sembunyikan konten saat lebar 0 */
}

#sidebar img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

/* Util: toggle antara list view & detail view */
.hidden {
    display: none !important;
}

/* ===== SIDEBAR TOP BAR ===== */
#sidebarTopBar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: #db4437;
    color: white;
}
#sidebarTopBar button {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
#sidebarTopBar button:hover {
    background: rgba(255, 255, 255, 0.15);
}
#sidebarTitle {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Tombol Search dengan ikon dari Google ===== */
#sidebarSearchBtn {
    background-image: url('https://www.gstatic.com/gmeviewer/images/MyMaps_Icons003.png');
    background-position: 20px 50px;
    background-repeat: no-repeat;
    width: 24px;
    height: 24px;
    border: none;
    cursor: pointer;
}

#sidebarSearchBtn img {
    filter: brightness(0) invert(1);
}

/* ===== SEARCH ===== */
#sidebarSearchRow {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}
#sidebarSearchInput {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

/* ===== INFO PANEL (deskripsi peta + share) ===== */
#sidebarInfoPanel {
    background: #f0f0f0;
    border-bottom: 1px solid #e2e8f0;
}

#sidebarInfoBody {
    padding: 0 0px 0px 0px;
}
#sidebarInfoBody.hidden {
    display: none;
}
#sidebarInfoDescription {
    margin: 0px 10px 10px;
    padding: 0px;
    font-size: 10px;
    line-height: 1.5;
    color: #475569;
}

/* ===== LIST HEADER (label + tombol tambah wilayah) ===== */
#sidebarListHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: -1px 16px 10px;
}

#addRegionBtn {
    background: #929292;
    color: white;
    padding: 2px 7px;
    font-size: 13px;
}
#addRegionBtn:hover {
    background: #148a2f;
}

.region-list-empty {
    padding: 20px;
    margin: 0;
    color: #94a3b8;
    font-size: 14px;
    font-family: Arial, Helvetica, sans-serif;
}

/* ===== REGION BLOCK (checkbox toggle-visibility + chevron collapse) ===== */
.region-block {
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 0;
}
.region-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0px 16px;
}
.region-checkbox {
    width: 15px;
    height: 15px;
    accent-color: #db4437;
    cursor: pointer;
    flex-shrink: 0;
}
.region-name {
    font-weight: 600;
    font-height: 20px;
    margin-left: 10px;
    font-stretch: 100%;
    font-size: 14px;
    font-style: normal;
    color:#222;
    white-space: nowrap;
    font-family: 'Roboto';
    display: inline-block;
    cursor: pointer;
    max-width: calc(100% - 56px);
    vertical-align: middle;
}
.region-toggle-row {
    height: 20px;
    padding: 0px 16px 0px 19px;
    cursor: pointer;
    user-select: none;
}
.region-chevron {
    font-size: 20px;
    color: #64748b;
}

/* Elemen pembungkus agar tidak ada padding */
#gangHeader {
    margin: 0;
    padding: 0;
    position: relative;
}

#sidebarDetailView {
    padding: 0;
    margin: 0;
}

/* ===== Gambar gang: hilangkan margin bawah ===== */
#gangImage {
    display: block;
    width: 100%;
    height: 50px;
    object-fit: cover;
    margin: 0;
}

.gang-list.collapsed {
    display: none;
    color: #475569;
}

.gang-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 2px 33px 6px 44px;
    font-size: 12px;
    color: #111111;
    cursor: pointer;
    max-width: 100%;
    font-family: 'Roboto';
    font-weight: 500;
    text-overflow: ellipsis;

}
.gang-item:hover {
    background: #f1f5f9;
}
.gang-item.hidden {
    display: none;
}
.gang-item-empty {
    color: #94a3b8;
    cursor: default;
    font-style: italic;
}
.gang-item-empty:hover {
    background: transparent;
}
.gang-item-more {
    color: #2563eb;
    font-weight: bold;
}
.gang-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

/* Tombol kembali tetap di kiri tengah */
#closeSidebar {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 26px;
    cursor: pointer;
    padding: 4px 6px;
    flex-shrink: 0;
    margin-right: 8px;
    line-height: 1;
    transition: opacity 0.2s;
}
#closeSidebar:hover {
    opacity: 0.7;
}

/* Box nama gang - naik ke atas gambar dengan z-index */
#gangNameBox {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 19px 0 12px;
    background-color: #db4437;
    background-repeat: repeat-x;
    background-position: left center;
    background-size: 100px 50px;
    overflow: hidden;
    margin: 0;
    margin-top: -35px;          /* naikkan ke area gambar */
    position: relative;         /* agar z-index bekerja */
    z-index: 2;                 /* di atas gambar */
}

#gangName {
    margin: 0;
    font-weight: 500;
    font-size: 6px;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    flex: 1;
    text-align: left;
}

#sidebar p {
    padding: 20px;
    margin: 0;
    line-height: 1.4;
    font-size: 13px;
    font-family: Arial, Helvetica, sans-serif;
}

/* Modal umum */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}
.modal.show {
    display: flex;
}
.modal-content {
    width: 400px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-content input,
.modal-content textarea,
.modal-content select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}
.modal-content textarea {
    min-height: 120px;
    resize: vertical;
}
.modal-content button {
    padding: 10px;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.modal-content button:hover {
    background: #0f172a;
}
.modal-content button#loginCloseBtn,
.modal-content button#regionCloseBtn {
    background: #ccc;
    color: #000;
}

/* Tombol Draw (Leaflet control) */
.leaflet-draw-btn {
    padding: 8px 14px;
    background: white;
    border: 2px solid #1e293b;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-size: 14px;
    transition: 0.2s;
}
.leaflet-draw-btn:hover {
    background: #f1f5f9;
}

/* Tombol auth (login/logout) */
.auth-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: white;
    color: #1e293b;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 14px;
}
.auth-btn:hover {
    background: #f1f5f9;
}
#logoutBtn {
    background: #ef4444;
    color: white;
}
#logoutBtn:hover {
    background: #dc2626;
}

/* Label territory */
.territory-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}
.territory-label:before {
    display: none;
}

/* ===== GANG DESCRIPTION (khusus) ===== */
#gangDescription {
    font-family: 'Roboto', Arial, Helvetica;
    font-weight: 500;
    font-size: 14px;
    text-align: justify;
    line-height: 1.6;
    color: #1e293b;
    padding: 0px 20px 16px 0px;
}

.header-description{
    padding: 8px 16px;
}

/* Label "description" */
#gangdescription .header-description {
    font-family: 'Roboto', Arial, Helvetica;
    font-size: 10px;
    letter-spacing: 0.5px;
    color: #9e9e9e;               /* abu-abu sedang untuk label */
    margin-bottom: 10px;
    font-weight: 600;
    padding: 0px 0px 10px 20px;
}

.region-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 0 6px;
    color: #ef4444;
    transition: color 0.2s;
}
.region-delete-btn:hover {
    color: #dc2626;
}

.sidebar-toggle-float {
    position: fixed;
    top: 50%;
    left: 340px; /* saat sidebar terbuka */
    transform: translateY(-50%);
    z-index: 10000;
    background: white;
    border: 1px solid #ccc;
    border-left: none;
    border-radius: 0 6px 6px 0;
    padding: 12px 8px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
    color: #333;
    will-change: left;
}

.sidebar-toggle-float:hover {
    background: #f1f5f9;
    transform: translateY(-50%) scale(1.05);
}
