/* ============================================================
   KARST GIS — GLOBAL STYLESHEET
   file: assets/css/style.css
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700;900&display=swap');

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    --bg-dark:      #050505;
    --glass-bg:     rgba(15, 15, 15, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-blue:  #3b82f6;
    --accent-green: #10b981;
    --text-muted:   #a1a1aa;
    --accent-teal:  #1fbfbe;
    --sidebar-w:    260px;
    --radius-lg:    16px;
    --radius-md:    12px;
    --radius-sm:    8px;
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background:
        linear-gradient(rgba(0,0,0,0.72), rgba(0,0,0,0.72)),
        url('https://images.unsplash.com/photo-1596328695079-af5c91b5853a?q=80&w=1920&auto=format&fit=crop');
    background-size: cover;
    background-attachment: fixed;
    color: white;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR — DESKTOP
   ============================================================ */
.sidebar {
    position: fixed;
    left: 10px;
    top: 20px;
    bottom: 20px;
    width: var(--sidebar-w);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px 20px;
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    padding: 4px 4px 24px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 35px;
    flex-shrink: 0;
}

.sidebar-brand img {
    width: 38px;
    height: 38px;
    max-width: 38px;
    max-height: 38px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
    display: block;
}


.brand-abbr {
    font-size: 1.1rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    text-transform: uppercase;
    font-style: italic;
    color: white;
}

.brand-sub {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.sidebar-version {
    text-align: center;
    opacity: 0.3;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.3em;
    padding-top: 20px;
    flex-shrink: 0;
}

/* ============================================================
   NAV LINK
   ============================================================ */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.15em;
    border-radius: var(--radius-md);
    transition: 0.25s;
    margin-bottom: 5px;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-logout {
    margin-top: auto !important;
    color: #ef4444 !important;
}
.nav-logout:hover { background: rgba(239,68,68,0.1) !important; color: #ff6b6b !important; }

/* ============================================================
   MAIN CONTENT — DESKTOP
   ============================================================ */
.main-content {
    margin-left: calc(var(--sidebar-w) + 40px);
    padding: 24px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::after {
    content: "";
    height: 1px;
    flex: 1;
    background: rgba(255,255,255,0.1);
}

/* ============================================================
   GLASS CARD
   ============================================================ */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--accent-blue);
    margin-bottom: 6px;
    display: block;
}

.stat-value {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: -2px;
    margin: 0;
    line-height: 1;
}

#count-gua    { text-shadow: 0 0 20px rgba(99,102,241,0.5); }
#count-air    { text-shadow: 0 0 20px rgba(16,185,129,0.5); }
#count-ponor  { text-shadow: 0 0 20px rgba(245,158,11,0.5); }
#count-telaga { text-shadow: 0 0 20px rgba(14,165,233,0.5); }

/* ============================================================
   MAP
   ============================================================ */
#map {
    height: 500px;
    width: 100%;
    border-radius: var(--radius-md);
    z-index: 1;
}

.leaflet-popup-content-wrapper {
    background: rgba(255,255,255,0.95) !important;
    backdrop-filter: blur(10px);
    color: #333 !important;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.leaflet-popup-tip { background: rgba(255,255,255,0.95) !important; }

/* ============================================================
   CARD HEADER
   ============================================================ */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.card-header-flex h3 {
    margin: 0;
    font-style: italic;
    font-weight: 900;
    color: white;
    font-size: 18px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}
.table-scroll::-webkit-scrollbar { height: 5px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.table-wrapper { min-width: 800px; }

/* DataTables */
.dataTables_wrapper { color: white !important; }

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    color: white !important;
    border-radius: var(--radius-sm) !important;
    padding: 7px 12px !important;
    outline: none;
}

.dataTables_wrapper .dataTables_filter input::placeholder { color: var(--text-muted); }
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { margin-bottom: 12px; }

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { color: var(--text-muted) !important; font-size: 12px; margin-top: 12px; }

.dataTables_wrapper .paginate_button {
    color: var(--text-muted) !important;
    border-radius: var(--radius-sm) !important;
    padding: 4px 10px !important;
}
.dataTables_wrapper .paginate_button.current,
.dataTables_wrapper .paginate_button:hover {
    background: rgba(59,130,246,0.2) !important;
    color: white !important;
    border: 1px solid var(--accent-blue) !important;
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
    background: transparent !important;
    width: 100% !important;
}

table.dataTable thead th {
    color: var(--accent-blue) !important;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 12px 15px !important;
    border: none !important;
    background: rgba(255,255,255,0.04) !important;
    white-space: nowrap;
}

table.dataTable tbody tr { background: rgba(255,255,255,0.03) !important; transition: 0.25s; }
table.dataTable tbody tr:hover { background: rgba(255,255,255,0.07) !important; }
table.dataTable tbody td {
    border: none !important;
    padding: 13px 15px !important;
    color: #e5e5e5;
    font-size: 13px;
    vertical-align: middle;
}

/* ============================================================
   BADGES & TAGS
   ============================================================ */
.type-tag {
    background: rgba(0,191,255,0.1);
    color: var(--accent-blue);
    padding: 4px 9px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 800;
    border: 1px solid rgba(0,191,255,0.25);
    white-space: nowrap;
}

.badge {
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1px;
    display: inline-block;
    text-transform: uppercase;
    white-space: nowrap;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--accent-blue);
}

.badge-clickable { cursor: pointer; transition: 0.25s; }
.badge-clickable:hover { filter: brightness(1.3); transform: translateY(-1px); }

.status-draft    { background: rgba(255,193,7,0.15);  color: #ffc107; border-color: #ffc107; }
.status-verified { background: rgba(40,167,69,0.15);  color: #2ecc71; border-color: #2ecc71; }

.role-badge {
    font-size: 10px;
    font-weight: 900;
    padding: 5px 12px;
    border-radius: 20px;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-view {
    background: rgba(255,255,255,0.08);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.25s;
    font-size: 13px;
    line-height: 1;
}
.btn-view:hover { background: var(--accent-blue); border-color: var(--accent-blue); transform: scale(1.05); }

.btn-delete {
    background: rgba(255,71,87,0.12);
    color: #ff4757;
    border: 1px solid rgba(255,71,87,0.3);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.25s;
    font-size: 13px;
    line-height: 1;
}
.btn-delete:hover { background: #ff4757; color: white; border-color: #ff4757; }

.aksi-group { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
/* Pastikan kolom aksi tidak memaksa wrap */
table.dataTable tbody td:last-child { white-space: nowrap; width: 1%; }

.btn-edit-user {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.25s;
    font-size: 13px;
}
.btn-edit-user:hover { opacity: 0.85; transform: scale(1.05); }

.btn-del-user {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
    border: 1px solid rgba(239,68,68,0.3);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.25s;
    font-size: 13px;
}
.btn-del-user:hover { background: #ef4444; color: white; border-color: #ef4444; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 16px;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.modal-content::-webkit-scrollbar { width: 5px; }
.modal-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 12px;
}

.btn-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: 0.2s;
}
.btn-close:hover { opacity: 1; }

@keyframes slideUp {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea,
.glass-select {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-md);
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent-blue); }
textarea { resize: none; }

/* Spinner off */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================================================
   SELECT2
   ============================================================ */
.select2-container--default .select2-selection--single {
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: var(--radius-md) !important;
    height: 46px !important;
    display: flex !important;
    align-items: center !important;
    transition: 0.2s;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--open .select2-selection--single {
    border-color: var(--accent-blue) !important;
    background: rgba(255,255,255,0.09) !important;
}
.select2-container--open .select2-selection--single {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: white !important;
    line-height: 46px !important;
    padding-left: 14px !important;
    font-size: 14px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 46px !important; right: 10px !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow b { border-color: rgba(255,255,255,0.5) transparent transparent transparent !important; }
.select2-dropdown {
    background: #161616 !important;
    border: 1px solid var(--accent-blue) !important;
    border-radius: 0 0 var(--radius-md) var(--radius-md) !important;
    margin-top: -1px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
    overflow: hidden;
}
.select2-search--dropdown .select2-search__field {
    background: rgba(255,255,255,0.08) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    color: white !important;
    border-radius: var(--radius-sm) !important;
}
.select2-results__option { padding: 10px 14px !important; font-size: 13px; color: #ddd; }
.select2-results__option--highlighted[aria-selected] { background: var(--accent-blue) !important; color: white !important; }
.select2-results__options::-webkit-scrollbar { width: 5px; }
.select2-results__options::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

/* ============================================================
   TABLET — max 1024px
   ============================================================ */
@media (max-width: 1024px) {
    :root { --sidebar-w: 80px; }
    .sidebar { padding: 24px 10px; }
    .sidebar h2,
    .nav-link span,
    .sidebar-version { display: none; }
    .nav-link { justify-content: center; font-size: 18px; padding: 12px; gap: 0; }
    .main-content { margin-left: calc(var(--sidebar-w) + 20px); }
}

/* ============================================================
   MOBILE — max 768px
   ============================================================ */
@media (max-width: 768px) {

    /* Sidebar → bottom bar */
    .sidebar {
        position: fixed;
        left: 0; right: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: auto;
        border-radius: 20px 20px 0 0;
        padding: 10px 8px 18px;
        flex-direction: row;
        align-items: center;
        border-top: 1px solid var(--glass-border);
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .sidebar-brand,
    .sidebar-version { display: none; }

    .sidebar nav {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        width: 100%;
    }

    .nav-link {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
        padding: 8px 6px;
        margin: 0 !important;
        font-size: 8px;
        letter-spacing: 0.04em;
        border-radius: 12px;
        flex: 1;
        max-width: 72px;
    }
    .nav-link i { font-size: 18px; }
    .nav-link span { display: block !important; }
    .nav-link[href="logout.php"] { color: #ef4444 !important; }

    /* Main content: ruang bawah untuk navbar */
    .main-content {
        margin-left: 0;
        padding: 14px 12px 90px;
    }

    .section-title { font-size: 10px; letter-spacing: 0.15em; margin-bottom: 14px; }

    /* Stats: 2×2 */
    .stats-grid,
    div[style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    .stat-value { font-size: 1.8rem; }

    /* Map */
    #map { height: 300px; }

    /* Glass card */
    .glass-card { padding: 14px; border-radius: var(--radius-md); }

    /* Card header: stack */
    .card-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 14px;
    }
    .card-header-flex h3 { font-size: 15px; }
    .card-header-flex > div { text-align: left !important; }

    /* DataTables controls: full width */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        width: 100% !important;
        text-align: left !important;
        display: block;
        margin-bottom: 8px;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }
    .dataTables_wrapper .top { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
    .dataTables_wrapper .bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 10px; }

    /* Table */
    .table-wrapper { min-width: 660px; }
    .table-scroll::after {
        content: "⇆ geser untuk melihat semua";
        display: block;
        font-size: 10px;
        color: var(--text-muted);
        text-align: right;
        padding-top: 6px;
    }

    /* Modal: slide up dari bawah */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-content {
        max-width: 100%;
        max-height: 88vh;
        border-radius: 20px 20px 0 0;
    }

    /* Modal detail inner grid */
    #modalDetail > div > div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Forms */
    .coords-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
    #mapPicker { height: 260px !important; }
}

/* ============================================================
   VERY SMALL — max 380px
   ============================================================ */
@media (max-width: 380px) {
    .stat-value { font-size: 1.5rem; }
    .nav-link { font-size: 7px; padding: 8px 4px; max-width: 60px; }
    .nav-link i { font-size: 16px; }
    .glass-card { padding: 12px; }
}