/* ============================================================
   FILE: modules/map.css
   DIGUNAKAN OLEH: index.php (halaman utama dengan peta)
   ============================================================
   FUNGSI: Map Container, Map Controls, Map Type Toggle,
           Coverage Info, Map Markers, Coverage Circle
   ============================================================ */

/* ============================================================
   MAP CONTROLS & CONTAINER
   ============================================================ */
.map-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 15px;
    background: var(--input-bg);
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    gap: 12px;
}

@media (min-width: 481px) {
    .map-controls {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
}

.map-type-toggle {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.btn-map-type {
    padding: 8px 14px;
    border: 2px solid var(--primary-color);
    background: var(--input-bg);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8em;
    font-weight: 600;
}

.btn-map-type.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
}

.btn-map-type:hover:not(.active) {
    background: var(--primary-light);
}

.coverage-info {
    font-weight: 600;
    font-size: 0.9em;
    text-align: center;
}

.map-container {
    background: var(--input-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    height: 300px;
    position: relative;
}

@media (min-width: 481px) {
    .map-container {
        height: 350px;
    }
}

@media (min-width: 769px) {
    .map-container {
        height: 450px;
    }
}

@media (min-width: 993px) {
    .map-container {
        height: 500px;
    }
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

.leaflet-container {
    height: 100%;
    width: 100%;
}

.leaflet-interactive {
    stroke-width: 2;
}

/* ============================================================
   COVERAGE ACTION
   ============================================================ */
.coverage-action-section {
    padding: 18px;
    border-radius: var(--radius);
    margin: 16px 0;
    box-shadow: var(--shadow);
    display: none;
}

.coverage-action-covered {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 1px solid #a3d4a5;
    color: #155724;
    border-radius: var(--radius);
    padding: 16px;
}

.coverage-action-not-covered {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 1px solid #ffd699;
    color: #856404;
    border-radius: var(--radius);
    padding: 16px;
}

.coverage-action-section h4 {
    margin-bottom: 12px;
    font-size: 1.2em;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

@media (min-width: 481px) {
    .action-buttons {
        flex-direction: row;
    }
}

/* ============================================================
   MAP MARKERS
   ============================================================ */
.user-marker {
    /* Styling via JS */
}

.hid-marker {
    /* Styling via JS */
}

/* ============================================================
   COVERAGE RESULTS
   ============================================================ */
#coverage-result .success-message,
#coverage-result .warning-message,
#coverage-result .error-message {
    padding: 15px;
    border-radius: 10px;
}

#coverage-result .success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

#coverage-result .warning-message {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

#coverage-result .error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

#coverage-result h4 {
    margin: 0 0 6px 0;
    font-size: 1em;
}

#coverage-result p {
    margin: 4px 0 0 0;
    font-size: 0.9em;
}

/* ============================================================
   HID TABLE CONTAINER
   ============================================================ */
.hid-table-container {
    margin-top: 16px;
    background: var(--input-bg);
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
    display: none;
}

.hid-table-container.active {
    display: block;
}

.hid-table-container h4 {
    margin-bottom: 12px;
    color: var(--text-dark);
    font-size: 1em;
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
}

.table-wrapper.hid-table-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    transform: scaleY(-1);
    padding-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
}

.table-wrapper.hid-table-scroll > * {
    transform: scaleY(-1);
}

@media (min-width: 481px) {
    .table-wrapper.hid-table-scroll {
        transform: none;
        padding-top: 0;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: var(--input-bg);
    }
    .table-wrapper.hid-table-scroll > * {
        transform: none;
    }
}

.scroll-hint {
    text-align: center;
    padding: 6px;
    font-size: 0.7em;
    color: #666;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 6px;
}

html.theme-dark body .scroll-hint, body.theme-dark .scroll-hint{
    color: #cbd5e1;
    background: #162238;
}

/* ============================================================
   HID TABLE - MOBILE CARD VIEW
   ============================================================ */
#hid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    border: none;
    table-layout: auto;
}

#hid-table thead {
    display: none;
}

#hid-table tbody tr {
    display: block;
    margin-bottom: 14px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--input-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#hid-table tbody tr:last-child {
    margin-bottom: 0;
}

#hid-table tbody tr:nth-of-type(even) {
    background: #fafbfc;
}

#hid-table tbody tr:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
}

#hid-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    font-size: 0.85em;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
}

#hid-table tbody td:last-child {
    border-bottom: none;
}

#hid-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--primary-color);
    flex-shrink: 0;
    width: 38%;
    font-size: 0.8em;
    background: #f8f9fc;
    padding: 4px 8px;
    border-radius: 8px;
}

#hid-table tbody td:first-child::before {
    content: none;
}

#hid-table tbody td:first-child {
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    border-radius: 20px;
    margin-bottom: 8px;
    font-weight: bold;
    border-bottom: none;
    padding: 6px 12px;
}

#hid-table tbody td:last-child::before {
    content: none;
}

#hid-table tbody td:last-child {
    justify-content: center;
    margin-top: 6px;
}

@media (min-width: 481px) {
    #hid-table thead {
        display: table-header-group;
    }
    #hid-table tbody tr {
        display: table-row;
        padding: 0;
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        margin-bottom: 0;
    }
    #hid-table tbody td {
        display: table-cell;
        padding: 8px 6px;
        border-bottom: 1px solid var(--border-color);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
        font-size: 0.8em;
        background: transparent;
    }
    #hid-table tbody td::before {
        content: none;
    }
    #hid-table tbody td:first-child {
        justify-content: normal;
        background: none;
        color: inherit;
        border-radius: 0;
        margin-bottom: 0;
        padding: 8px 6px;
        font-weight: normal;
    }
    #hid-table tbody td:last-child {
        justify-content: normal;
        margin-top: 0;
        padding: 8px 6px;
    }
    #hid-table {
        font-size: 0.85em;
    }
}

@media (min-width: 769px) {
    #hid-table {
        font-size: 0.9em;
    }
}

@media (min-width: 993px) {
    #hid-table {
        font-size: 1em;
    }
    #hid-table th,
    #hid-table td {
        padding: 12px 10px;
    }
    .btn-copy-small {
        padding: 6px 14px;
        font-size: 0.75em;
    }
}

/* ============================================================
   DARK THEME - MAP & HID
   ============================================================ */
html.theme-dark body .search-section, body.theme-dark .search-section{
    border-color: rgba(78, 168, 222, 0.22);
}

html.theme-dark body .results-section, body.theme-dark .results-section{
    border-color: rgba(78, 168, 222, 0.18);
}

html.theme-dark body #hid-table tbody tr:nth-of-type(even), body.theme-dark #hid-table tbody tr:nth-of-type(even){
    background: #141e33;
}

html.theme-dark body #hid-table tbody td, body.theme-dark #hid-table tbody td{
    border-bottom-color: #283450;
}

html.theme-dark body #hid-table tbody td::before, body.theme-dark #hid-table tbody td::before{
    background: #182542;
    color: #9cc9ee;
}

html.theme-dark body #hid-table tbody tr:hover, body.theme-dark #hid-table tbody tr:hover{
    background: #192543;
}

html.theme-dark body #coverage-result .success-message, body.theme-dark #coverage-result .success-message{
    background: #14532d;
    border: 1px solid #166534;
    color: #bbf7d0;
}

html.theme-dark body #coverage-result .warning-message, body.theme-dark #coverage-result .warning-message{
    background: #78350f;
    border: 1px solid #92400e;
    color: #fde68a;
}

html.theme-dark body #coverage-result .error-message, body.theme-dark #coverage-result .error-message{
    background: #7f1d1d;
    border: 1px solid #991b1b;
    color: #fecaca;
}

html.theme-dark body .coverage-action-covered, body.theme-dark .coverage-action-covered{
    background: linear-gradient(135deg, #14532d, #166534);
    border: 1px solid #22c55e;
    color: #bbf7d0;
}

html.theme-dark body .coverage-action-not-covered, body.theme-dark .coverage-action-not-covered{
    background: linear-gradient(135deg, #78350f, #854d0e);
    border: 1px solid #eab308;
    color: #fde68a;
}

@media (min-width: 481px) {
    html.theme-dark body #hid-table tbody td, body.theme-dark #hid-table tbody td{
        border-bottom-color: #2d3b55;
    }
}

/* ============================================================
   RESPONSIVE - HP SANGAT KECIL
   ============================================================ */
@media (max-width: 380px) {
    #hid-table tbody td {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    #hid-table tbody td::before {
        width: 100%;
        background: none;
        padding-left: 0;
    }
    #hid-table tbody td:first-child {
        flex-direction: row;
        justify-content: center;
    }
    #hid-table tbody td:last-child {
        align-items: stretch;
    }
    .btn-copy-small {
        width: 100%;
    }
}