/**
 * Bagian Organisasi — mobile-first responsive layer
 * Breakpoints: mobile default · tablet 768px+ · desktop 1024px+
 */

:root {
    --org-bp-tablet: 768px;
    --org-bp-desktop: 1024px;
    --org-touch: 44px;
    --org-space-x: clamp(1rem, 4.2vw, 1.25rem);
    --org-space-y: clamp(1.25rem, 3vw, 2rem);
    --org-text-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
    --org-text-sm: clamp(0.8125rem, 0.8rem + 0.1vw, 0.875rem);
    --org-text-lg: clamp(1.0625rem, 1rem + 0.35vw, 1.125rem);
    --org-heading-1: clamp(1.5rem, 1.2rem + 1.8vw, 2rem);
    --org-heading-2: clamp(1.25rem, 1.1rem + 1vw, 1.5rem);
    --org-heading-3: clamp(1.0625rem, 1rem + 0.4vw, 1.2rem);
    --org-radius-touch: 12px;
}

/* —— Base typography & readability —— */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-size: var(--org-text-base);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Beranda: shell header/hero — org-container-global.css */
body.sg-homepage.sg-portal-page {
    overflow-x: hidden;
}

h1, .h1 { font-size: var(--org-heading-1); line-height: 1.2; }
h2, .h2 { font-size: var(--org-heading-2); line-height: 1.25; }
h3, .h3 { font-size: var(--org-heading-3); line-height: 1.3; }

p, li { overflow-wrap: break-word; word-wrap: break-word; }

img,
video,
svg,
canvas {
    max-width: 100%;
    height: auto;
}

.site-header__logo {
    max-width: min(120px, 32vw);
    height: auto;
}

/* —— Spacing: mobile-first (tighter) —— */
.container,
.container-fluid {
    padding-left: var(--org-space-x);
    padding-right: var(--org-space-x);
}

.site-main,
.sg-portal-main-inner > .container.site-main {
    padding-top: var(--org-space-y);
    padding-bottom: clamp(2rem, 5vw, 3rem);
}

.section-spacing {
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

/* —— Touch targets —— */
.btn,
button:not(.btn-close):not(.page-link),
.site-header__nav a,
.site-header__nav-close,
.site-header__nav-toggle,
.site-header-doc-search__submit,
.pagination .page-link,
.gl-filters__tab,
.np-card__link,
.eo-module-card {
    min-height: var(--org-touch);
}

.btn-sm {
    min-height: 40px;
    padding: 0.45rem 0.85rem;
}

.btn:not(.btn-sm):not(.btn-lg) {
    padding: 0.55rem 1.1rem;
    font-size: var(--org-text-base);
    border-radius: var(--org-radius-touch);
}

.form-control,
.form-select,
.site-header-doc-search__input,
.gl-toolbar__input,
.np-toolbar .form-control {
    min-height: var(--org-touch);
    font-size: 16px; /* prevent iOS zoom on focus */
    border-radius: var(--org-radius-touch);
}

textarea.form-control {
    min-height: 5.5rem;
}

/* —— Navbar mobile —— */
.site-header__topbar {
    flex-wrap: wrap;
    gap: 0.65rem;
}

.site-header__brand-row {
    flex: 1 1 auto;
    min-width: 0;
}

.site-header__titles {
    min-width: 0;
}

/* Non-portal header — portal memakai smart-governance-portal-nav.css */
body:not(.sg-portal-page) .site-header__title,
.site-header:not(.site-header--sg-portal) .site-header__title {
    font-size: clamp(1rem, 4.5vw, var(--header-title-size, 1.35rem)) !important;
}

body:not(.sg-portal-page) .site-header__subtitle,
.site-header:not(.site-header--sg-portal) .site-header__subtitle {
    font-size: clamp(0.72rem, 2.8vw, var(--header-subtitle-size, 0.85rem)) !important;
}

.site-header__search-wrap {
    flex: 1 1 100%;
    order: 3;
    width: 100%;
    max-width: none;
}

.site-header-doc-search__field {
    min-height: var(--org-touch);
}

.site-header__nav-toggle {
    min-width: var(--org-touch);
    padding: 0.5rem 0.75rem;
    gap: 0.35rem;
}

.site-header__nav-panel .site-header__nav li a,
.site-header__nav-collapse .site-header__nav li a {
    display: flex;
    align-items: center;
    min-height: var(--org-touch);
    padding: 0.65rem 1rem;
    font-size: var(--org-text-base);
    border-radius: 10px;
}

/* Menu mobile: lihat assets/css/org-navbar.css (panel .is-open) */

.site-header__actions,
.site-header__actions-end {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
}

.site-header__actions .btn {
    width: 100%;
    justify-content: center;
}

/* —— Stack layouts vertically (mobile default) —— */
.row:not(.row-cols-auto):not(.g-0) > [class*="col-"] {
    margin-bottom: 0;
}

.row.g-3 > [class*="col-"],
.row.g-4 > [class*="col-"] {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .row.eorg-hub-grid > [class*="col-"],
    .row.g-4.g-lg-5 > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .sg-subhero__grid {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
    }

    .sg-subhero__stats {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.65rem;
    }

    .eo-dash__top {
        flex-direction: column;
        align-items: stretch;
    }

    .eo-dash__clock {
        width: 100%;
    }

    .gl-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .gl-filters {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .gl-filters::-webkit-scrollbar {
        display: none;
    }

    .gl-filters__tab {
        flex-shrink: 0;
    }

    .np-latest__head {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* —— Responsive tables —— */
.org-table-wrap,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 12px;
    border: 1px solid var(--card-border, #e5e7eb);
    background: #fff;
}

.site-main .table,
.table {
    font-size: var(--org-text-sm);
    margin-bottom: 0;
}

@media (max-width: 767.98px) {
    .site-main table.table {
        min-width: 520px;
    }

    .site-main .table-responsive > .table {
        min-width: 0;
    }

    .table th,
    .table td {
        padding: 0.65rem 0.75rem;
        vertical-align: middle;
    }

    .table .btn-sm {
        min-height: 36px;
        white-space: nowrap;
    }
}

/* —— Cards —— */
.card,
.section-card,
.pub-float-panel,
.np-card,
.gl-item,
.eo-stat-card,
.eo-widget,
.eo-module-card,
.eorg-hub-card,
.pi-portal-card,
.beranda-galeri-item {
    border-radius: clamp(12px, 3vw, 16px);
}

@media (max-width: 767.98px) {
    .card .card-body,
    .section-card .card-body {
        padding: 1rem 1.1rem;
    }

    .pub-float-panel,
    .eorg-hub--premium,
    .eorg-hub--enterprise {
        margin-left: calc(-1 * var(--org-space-x));
        margin-right: calc(-1 * var(--org-space-x));
        padding-left: var(--org-space-x);
        padding-right: var(--org-space-x);
        border-radius: 14px;
    }

    .np-hero__card {
        grid-template-columns: 1fr !important;
    }

    .np-hero__body {
        padding: 1.15rem 1.2rem 1.25rem;
    }

    .eorg-smart-panel {
        grid-template-columns: 1fr !important;
    }

    .eorg-smart-panel__metrics {
        grid-template-columns: 1fr 1fr;
    }

    .eorg-metric--wide {
        grid-column: 1 / -1;
    }
}

/* —— Masonry / gallery mobile —— */
@media (max-width: 767.98px) {
    .gl-masonry {
        column-count: 1 !important;
        column-gap: 0.85rem;
    }

    .gl-item {
        margin-bottom: 0.85rem;
    }
}

/* —— Modals —— */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.65rem;
        max-width: calc(100% - 1.3rem);
    }

    .modal-body {
        padding: 1rem 1.1rem;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

/* —— Footer —— */
@media (max-width: 767.98px) {
    .site-footer__grid,
    .site-footer .row {
        row-gap: 1.5rem;
    }

    .site-footer [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* —— Beranda / portal strips —— */
@media (max-width: 767.98px) {
    .beranda-section__head,
    .sg-section__head {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .beranda-galeri-grid:not(.beranda-galeri-scroll) {
        grid-template-columns: 1fr !important;
        gap: 0.85rem;
    }

    .digital-library__hero-row {
        flex-direction: column;
    }
}

/* —— Tablet: 768px+ —— */
@media (min-width: 768px) {
    :root {
        --org-space-x: clamp(1.15rem, 2.5vw, 1.5rem);
        --org-space-y: clamp(1.5rem, 2.5vw, 2rem);
    }

    .site-header__search-wrap {
        flex: 1 1 auto;
        order: unset;
        width: auto;
        max-width: min(22rem, 100%);
    }

    .row.g-3 > .col-sm-6,
    .row.g-4 > .col-sm-6 {
        width: auto;
        max-width: none;
    }

    .gl-masonry {
        column-count: 2 !important;
    }

    .sg-subhero__stats {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

/* —— Desktop: 1024px+ —— */
@media (min-width: 1024px) {
    .container {
        padding-left: 20px;
        padding-right: 20px;
    }

    .section-spacing {
        margin-bottom: 2.5rem;
    }

    .site-header__actions-end {
        flex-direction: row;
        width: auto;
    }

    .site-header__actions .btn {
        width: auto;
    }

    .gl-masonry {
        column-count: 3 !important;
    }
}

@media (min-width: 1200px) {
    .gl-masonry {
        column-count: 4 !important;
    }
}

/* —— Admin dashboard tables —— */
@media (max-width: 767.98px) {
    .adm-quick-access__grid,
    .sg-monitor-kpi-row {
        grid-template-columns: 1fr !important;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid #dee2e6;
        padding-bottom: 2px;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        min-height: var(--org-touch);
        display: inline-flex;
        align-items: center;
    }
}

/* —— Safe areas (notched phones) —— */
@supports (padding: max(0px)) {
    .site-header__nav-panel.is-open,
    .site-header__nav-collapse.show {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* —— Reduced motion —— */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
