/* CSS untuk Hikari (Hasil Kualitas Rapor Pendidikan) */

/* Base Styles */
html,
body {
    height: 100%;
    width: 100%;
    font-family: 'Inter', sans-serif;
    overflow-x: hidden; /* Prevent horizontal scroll on body */
}

/* App Container - Prevent overflow */
#app-container {
    max-width: 100vw;
    overflow-x: hidden;
}

#main-content-container {
    max-width: 100%;
    overflow-x: hidden;
}

main {
    max-width: 100%;
    overflow-x: hidden;
}

/* Table Container */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

table {
    min-width: 100%; /* Changed from 2000px to 100% */
    width: max-content; /* Allow table to grow based on content */
}

/* Responsive table on mobile */
@media (max-width: 768px) {
    table {
        min-width: 800px; /* Smaller minimum on mobile */
    }
}

th,
td {
    white-space: nowrap;
    /* Cegah teks ter-wrap */
    vertical-align: top;
    /* Perataan atas untuk konten sel */
    padding: 0.75rem 0.5rem; /* Reduce padding on mobile */
}

@media (min-width: 768px) {
    th,
    td {
        padding: 0.75rem 1rem;
    }
}

/* Disabled Button Style */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Stat Card */
.stat-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}

/* Capaian Detail (Clickable) */
.capaian-detail {
    cursor: pointer;
    transition: background-color 0.15s;
}

.capaian-detail:hover {
    background-color: #eef2ff;
    /* bg-indigo-50 */
    border-radius: 4px;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Table Row Hover */
#data-table-body tr {
    cursor: pointer;
    transition: background-color 0.15s;
}

#data-table-body tr:hover {
    background-color: #f3f4f6;
    /* bg-gray-100 */
}

/* Global Summary Card */
.global-summary-card {
    background: linear-gradient(135deg, #14532d 0%, #22c55e 100%);
    color: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.25rem;
    overflow: hidden;
    max-width: 100%; /* Prevent overflow */
}

@media (min-width: 768px) {
    .global-summary-card {
        padding: 1.5rem;
    }
}

/* Prevent cards from causing horizontal scroll */
.stat-card,
.global-summary,
#filter-section,
#charts-section,
#rekap-kecamatan-container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Charts responsive */
#charts-section .grid {
    max-width: 100%;
}

#charts-section .stat-card {
    min-width: 0; /* Allow cards to shrink */
}

.global-capaian-detail {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0.5rem;
    overflow: hidden;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@media (min-width: 768px) {
    .global-capaian-detail {
        min-height: 85px;
    }
}

.global-capaian-detail:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.global-capaian-detail:active {
    transform: translateY(0);
}

/* Modal Table Container */
.modal-table-container {
    max-height: 400px;
    /* Tinggi maksimum container tabel */
    overflow-y: auto;
    /* Mengaktifkan scrolling vertikal */
    border-radius: 0.5rem;
}

.modal-table-container thead th {
    position: sticky;
    top: 0;
    background-color: #f3f4f6;
    /* bg-gray-100 */
    z-index: 10;
}

/* User Dropdown Animation */
#user-dropdown {
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header Responsive */
header {
    max-width: 100vw;
    overflow-x: hidden;
}

header > div {
    max-width: 100%;
}

@media (max-width: 640px) {
    header h1 {
        font-size: 0.875rem;
    }

    header .h-10 {
        height: 2rem;
        width: 2rem;
    }
}

/* Header buttons responsive */
@media (max-width: 768px) {
    header .flex.items-center.gap-2 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    header button {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    header button span {
        display: none; /* Hide text on very small screens */
    }
}

@media (min-width: 640px) {
    header button span {
        display: inline;
    }
}

/* Chart Clickable */
#kecamatanChart,
#topBaikChart,
#topKurangChart {
    cursor: pointer;
}

/* Chart Hover Effect */
canvas:hover {
    opacity: 0.95;
}

/* Bottom Navigation Styles */
#bottom-nav {
    transition: transform 0.3s ease-in-out;
    pointer-events: auto;
}

#bottom-nav button {
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
}

#bottom-nav button.active-nav-item svg {
    color: #4f46e5;
}

#bottom-nav button.active-nav-item span {
    color: #4f46e5;
}

#bottom-nav button:not(.active-nav-item) svg {
    color: #6b7280;
}

#bottom-nav button:not(.active-nav-item) span {
    color: #6b7280;
}

#bottom-nav button:active {
    transform: scale(0.95);
}

/* Mobile Menu Overlay Animation */
#mobile-menu-overlay {
    pointer-events: auto !important;
}

#mobile-menu-overlay.hidden {
    pointer-events: none;
}

#mobile-menu-overlay>div {
    transform: translateY(100%);
    pointer-events: auto !important;
}

#mobile-menu-overlay.show>div {
    transform: translateY(0);
}

/* Mobile Menu Buttons */
#mobile-paud-btn,
#mobile-dikdasmen-btn,
#mobile-logout-btn {
    cursor: pointer !important;
    pointer-events: auto !important;
    touch-action: manipulation;
    user-select: none;
    position: relative;
    z-index: 10;
}

#mobile-paud-btn *,
#mobile-dikdasmen-btn *,
#mobile-logout-btn * {
    pointer-events: none !important;
}

#mobile-paud-btn:active,
#mobile-dikdasmen-btn:active,
#mobile-logout-btn:active {
    transform: scale(0.98);
    opacity: 0.8;
}

#mobile-menu-overlay .p-6 {
    pointer-events: auto !important;
}

/* Add bottom padding to main content on mobile to prevent content being hidden behind nav */
@media (max-width: 767px) {
    main.flex-1 {
        padding-bottom: 5rem;
    }
}

/* Responsive Container Fixes */
.container,
.w-full {
    max-width: 100%;
}

/* Prevent grid overflow */
.grid {
    max-width: 100%;
}

/* Filter section responsive */
#filter-section .grid {
    gap: 0.75rem;
}

@media (max-width: 640px) {
    #filter-section .grid {
        grid-template-columns: 1fr;
    }
}

/* Indicator cards responsive */
#indicator-cards-container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Chart container responsive */
.chart-container {
    max-width: 100%;
    overflow: hidden;
}

/* Prevent horizontal scroll from any element */
* {
    max-width: 100%;
}

/* Allow specific elements to exceed */
table,
.table-container,
canvas {
    max-width: none;
}


/* ============================================
   RESPONSIVE FIXES - Prevent Horizontal Scroll
   ============================================ */

/* Global box-sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Prevent body overflow */
body {
    position: relative;
    overflow-x: hidden !important;
    max-width: 100vw;
}

/* Main containers */
#app-container,
#app-screen,
#main-content-container,
main {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Content sections */
.global-summary,
#filter-section,
#charts-section,
#data-table-section,
#rekap-kecamatan-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Grid layouts */
.grid {
    width: 100%;
    max-width: 100%;
}

/* Flex layouts */
.flex {
    max-width: 100%;
}

/* Images responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Buttons responsive */
button {
    max-width: 100%;
}

/* Input fields responsive */
input,
select,
textarea {
    max-width: 100%;
}

/* Cards responsive */
.stat-card,
.global-summary-card,
.global-capaian-detail {
    width: 100%;
    max-width: 100%;
}

/* Modal responsive */
#detail-modal > div {
    max-width: 95vw;
}

@media (min-width: 768px) {
    #detail-modal > div {
        max-width: 90vw;
    }
}

/* Table wrapper */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Pagination responsive */
#pagination-controls {
    width: 100%;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (max-width: 640px) {
    #pagination-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    #pagination-controls > div {
        width: 100%;
        justify-content: center;
    }
}

/* Filter section responsive */
@media (max-width: 768px) {
    #filter-section .grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* Charts section responsive */
@media (max-width: 1024px) {
    #charts-section .grid {
        grid-template-columns: 1fr;
    }
}

/* Indicator cards responsive */
#indicator-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 100%;
}

@media (max-width: 640px) {
    #indicator-cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
}

/* Header responsive improvements */
header .flex.flex-col.md\\:flex-row {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 768px) {
    header .flex.items-center.gap-2 {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Bottom navigation responsive */
#bottom-nav {
    width: 100%;
    max-width: 100vw;
}

/* Mobile menu responsive */
#mobile-menu-overlay {
    width: 100vw;
    max-width: 100vw;
}

/* Prevent text overflow */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Scrollbar styling for better UX */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Ensure no element causes horizontal scroll */
.no-overflow {
    overflow-x: hidden !important;
    max-width: 100% !important;
}
