/* 
    Si-MASKU Kaltim - Global Design System 
    Standardized CSS Tokens & Components
*/

:root {
    --primary-color: #5b5ce2;
    --primary-dark: #3437a8;
    --secondary-color: #667085;
    --success-color: #2fb344;
    --danger-color: #e03131;
    --warning-color: #f59f00;
    --info-color: #0aa2c0;
    --white: #ffffff;
    --light-bg: #f6f7fb;
    --surface-bg: #ffffff;
    --soft-bg: #f8f9fc;
    --border-color: #e4e7ec;
    --text-color: #344054;
    --text-muted: #667085;
    
    /* Spacing System */
    --sp-xs: 0.25rem;
    --sp-sm: 0.5rem;
    --sp-md: 0.875rem;
    --sp-lg: 1.25rem;
    --sp-xl: 1.75rem;
    --page-pad-y: 1.25rem;
    --page-pad-x: 1.5rem;
    --card-pad: 1.25rem;
    --card-pad-sm: 1rem;
    --header-pad-y: 0.875rem;
    --header-pad-x: 1.25rem;
    --control-height: 2.375rem;
    --title-icon-size: 1.15rem;
    --header-illustration-height: 104px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 8px 20px rgba(16, 24, 40, 0.07);
    --shadow-lg: 0 16px 32px rgba(16, 24, 40, 0.12);
    
    /* Transitions */
    --transition-fast: all 0.2s ease;
    --transition-base: all 0.3s ease;
}

/* --- Layout Refinement --- */
body {
    color: var(--text-color);
    background: var(--light-bg);
    font-size: 0.875rem;
}

.content-wrapper {
    background-color: var(--light-bg);
}

.layout-page {
    background: var(--light-bg);
}

.container-p-y {
    padding-top: var(--page-pad-y) !important;
    padding-bottom: var(--page-pad-y) !important;
}

.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
    padding-right: var(--page-pad-x);
    padding-left: var(--page-pad-x);
}

.row {
    --bs-gutter-x: 1rem;
}

.row.g-3 {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
}

.row.g-4 {
    --bs-gutter-x: 1.25rem;
    --bs-gutter-y: 1.25rem;
}

.mb-4 {
    margin-bottom: 1rem !important;
}

/* --- Premium Cards --- */
.card {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md);
    background: var(--surface-bg);
    box-shadow: var(--shadow-sm) !important;
    transition: var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-sm) !important;
}

.card-premium {
    border: none;
}

.card-header {
    background-color: var(--surface-bg) !important;
    padding: var(--header-pad-y) var(--header-pad-x) !important;
    border-bottom: 1px solid var(--border-color);
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.card-body {
    padding: var(--card-pad) !important;
}

.card-body.p-0 {
    padding: 0 !important;
}

.card-body.p-3 {
    padding: var(--card-pad-sm) !important;
}

.card-body.p-4,
.col-sm-10.p-4 {
    padding: var(--card-pad) !important;
}

.card-title,
.card-header h5,
.card-header h6,
.card-body h4,
.card-body h5,
.card-body h6 {
    letter-spacing: 0;
}

.card-title {
    margin-bottom: 0.75rem;
    font-weight: 700;
    line-height: 1.35;
}

.card-title .bx,
.card-header .bx,
.alert-heading .bx {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--title-icon-size);
    min-width: var(--title-icon-size);
    height: var(--title-icon-size);
    font-size: var(--title-icon-size);
    line-height: 1;
    vertical-align: -0.12em;
}

.card-header h5,
.card-header h6 {
    line-height: 1.35;
}

/* --- Standard page intro cards --- */
.content-wrapper > .container-xxl > .col-lg-12.mb-4.order-0,
.content-wrapper > .container-xxl > .card.mb-4:first-child {
    margin-bottom: 1rem !important;
}

.content-wrapper > .container-xxl > .col-lg-12.mb-4.order-0 > .card .card-body,
.content-wrapper > .container-xxl > .card.mb-4:first-child .card-body {
    padding: var(--card-pad) !important;
}

.content-wrapper .card img[style*="max-height: 120px"] {
    max-height: var(--header-illustration-height) !important;
    width: auto;
    object-fit: contain;
}

.content-wrapper .card img[src*="public/assets/img/illustrations/"],
.content-wrapper .card img[src*="assets/img/illustrations/"] {
    max-height: var(--header-illustration-height) !important;
    width: auto;
    object-fit: contain;
}

.content-wrapper .card .bx[style*="font-size: 80px"] {
    font-size: 64px !important;
}

.alert {
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.alert-secondary {
    background-color: var(--soft-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-muted) !important;
}

/* --- Hero & Header Sections --- */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px;
}

.hero-section .card-title {
    color: white !important;
}

/* --- KPI cards --- */
.card[style*="linear-gradient"] {
    border: 0 !important;
}

.card[style*="linear-gradient"] .card-body {
    min-height: 96px;
    padding: 1rem !important;
}

.card[style*="linear-gradient"] h3,
.card[style*="linear-gradient"] h2 {
    line-height: 1.1;
    letter-spacing: 0;
}

.card[style*="linear-gradient"] h6 {
    line-height: 1.25;
}

/* --- Table Styling --- */
.table-responsive {
    border-radius: 0;
    border: 0;
    background: var(--surface-bg);
}

.table {
    color: var(--text-color);
    border-collapse: collapse !important;
    width: 100% !important;
    margin-bottom: 0 !important;
}

.table thead th {
    background: var(--surface-bg) !important;
    color: #384551 !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0 !important;
    font-size: 0.75rem !important;
    line-height: 1.2;
    border-top: 1px solid var(--border-color) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0.8125rem 1rem !important;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.875rem 1rem !important;
    vertical-align: middle !important;
    border-bottom: 1px solid var(--border-color) !important;
    line-height: 1.45;
}

.table .badge {
    min-height: 1.35rem;
    display: inline-flex;
    align-items: center;
}

.table tbody tr:hover {
    background-color: rgba(105, 108, 255, 0.04) !important;
}

.table small {
    line-height: 1.45;
}

.dataTables_wrapper {
    font-size: 0.8125rem;
}

.dataTables_wrapper > .row:first-child {
    align-items: center;
    padding-top: 0.75rem;
}

.dataTables_wrapper > .row:last-child {
    align-items: center;
    padding-bottom: 0.75rem;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info {
    color: var(--text-muted) !important;
    font-size: 0.8125rem;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    min-height: 2.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--surface-bg);
    color: var(--text-color);
    font-size: 0.8125rem;
    padding: 0.4375rem 0.875rem;
}

.dataTables_wrapper .dataTables_length select {
    width: 5.25rem;
    min-width: 5.25rem;
    padding-right: 2rem;
    background-position: right 0.75rem center;
}

.dataTables_wrapper .dataTables_filter input {
    width: 12.5rem;
    margin-left: 0;
}

.dataTables_wrapper .pagination {
    --bs-pagination-padding-x: 0;
    --bs-pagination-padding-y: 0;
    --bs-pagination-font-size: 0.8125rem;
    --bs-pagination-border-radius: var(--radius-sm);
    --bs-pagination-active-bg: var(--primary-color);
    --bs-pagination-active-border-color: var(--primary-color);
    gap: 0.25rem;
    margin-bottom: 0;
}

.dataTables_wrapper .page-link {
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-sm) !important;
    background-color: #f0f2f5;
    color: #566a7f;
    box-shadow: none;
}

.dataTables_wrapper .page-item.active .page-link {
    color: #fff;
    background-color: var(--primary-color);
    box-shadow: 0 0.125rem 0.25rem rgba(105, 108, 255, 0.4);
}

.dataTables_wrapper .page-item.disabled .page-link {
    background-color: #f5f5f9;
    color: #a8b1bb;
}

.dataTables_wrapper .dt-buttons .btn,
.dataTables_wrapper .dataTables_filter .form-control,
.dataTables_wrapper .dataTables_length .form-select {
    font-size: 0.8125rem;
}

.dataTables_wrapper .dt-buttons .btn {
    min-height: 2.375rem;
}

.card-datatable,
.dataTables_wrapper {
    border-radius: 0;
}

/* --- Badge Refinements --- */
.badge {
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.2;
}

.badge-premium {
    padding: 0.5em 0.8em;
    font-weight: 600;
    border-radius: var(--radius-sm);
    letter-spacing: 0;
}

/* --- Controls --- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: 0;
    min-height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    line-height: 1.25;
}

.btn .bx,
.dropdown-item .bx,
.badge .bx {
    font-size: 1rem;
    line-height: 1;
}

.btn-label-primary {
    color: #696cff !important;
    background-color: rgba(105, 108, 255, 0.16) !important;
    border-color: transparent !important;
}

.btn-label-primary:hover,
.btn-label-primary:focus {
    color: #fff !important;
    background-color: #696cff !important;
    border-color: #696cff !important;
}

.btn-label-success {
    color: #71dd37 !important;
    background-color: rgba(113, 221, 55, 0.16) !important;
    border-color: transparent !important;
}

.btn-label-success:hover,
.btn-label-success:focus {
    color: #fff !important;
    background-color: #71dd37 !important;
    border-color: #71dd37 !important;
}

.btn-label-danger {
    color: #ff3e1d !important;
    background-color: rgba(255, 62, 29, 0.16) !important;
    border-color: transparent !important;
}

.btn-label-danger:hover,
.btn-label-danger:focus {
    color: #fff !important;
    background-color: #ff3e1d !important;
    border-color: #ff3e1d !important;
}

.btn-sm,
.btn-group-sm > .btn {
    min-height: 2rem;
    padding: 0.375rem 0.75rem;
}

.btn-xs,
.btn-icon.btn-xs {
    min-height: 1.75rem;
}

.btn-group {
    flex-wrap: wrap;
    gap: 0;
}

.btn-group.rounded-pill,
.btn-group.bg-light {
    gap: 0.125rem;
}

/* --- Monitoring Satker Page --- */
.simasku-filter-card .card-body {
    min-height: 64px;
}

.simasku-monitoring-accordion .accordion-item {
    overflow: hidden;
}

.simasku-monitoring-accordion .accordion-button {
    min-height: 68px;
    padding: 0.875rem 1.25rem;
    gap: 0.5rem;
}

.simasku-monitoring-accordion .accordion-button:not(.collapsed) {
    background: var(--soft-bg);
    color: var(--text-color);
    box-shadow: inset 0 -1px 0 var(--border-color);
}

.simasku-monitoring-accordion .accordion-button::after {
    flex-shrink: 0;
}

.simasku-monitoring-accordion .accordion-body {
    padding: 1rem 1.25rem 1.25rem;
}

.simasku-monitoring-table {
    border: 1px solid var(--border-color);
    background: var(--surface-bg);
}

.simasku-monitoring-table .table {
    min-width: 1120px;
    font-size: 0.75rem;
}

.simasku-monitoring-table .table-premium thead th,
.simasku-monitoring-table .table-premium tbody td {
    padding: 0.625rem 0.7rem !important;
}

.simasku-document-panel {
    height: 100%;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

@media (max-width: 1199.98px) {
    .simasku-document-panel {
        padding-top: 1rem;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        border-left: 0;
    }
}

.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.375rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    min-height: var(--control-height);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(91, 92, 226, 0.65);
    box-shadow: 0 0 0 0.18rem rgba(91, 92, 226, 0.12);
}

.form-label {
    margin-bottom: 0.375rem;
    color: var(--text-color);
}

.input-group-text {
    border-color: var(--border-color);
    min-height: var(--control-height);
}

.progress {
    border-radius: 999px;
    background-color: #eef0f6;
}

.progress-bar {
    border-radius: 999px;
}

.avatar {
    flex-shrink: 0;
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
}

.avatar-xl {
    width: 4rem;
    height: 4rem;
}

.modal-content {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color) !important;
}

.modal-header,
.modal-footer {
    padding: 1rem 1.25rem !important;
}

.modal-body {
    padding: 1.25rem !important;
}

/* --- Stat Icons --- */
.stat-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.25rem;
    transition: var(--transition-fast);
}

.card:hover .stat-icon {
    transform: scale(1.1);
}

/* --- Sidebar --- */
.layout-menu {
    border-right: 1px solid var(--border-color);
}

.app-brand .app-brand-text {
    font-size: 1.3rem;
    letter-spacing: -0.2px;
}

.simasku-brand-version {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    align-self: center;
}

.simasku-brand-logo {
    width: 1.5rem;
    height: 1.5rem;
    object-fit: contain;
}

.menu-inner {
    padding-bottom: 0.75rem !important;
}

.layout-menu .menu-vertical .menu-inner > .menu-header,
.layout-menu .menu-header {
    margin-top: 0.75rem !important;
    height: auto !important;
    min-height: 1.5rem;
    inline-size: auto !important;
    overflow: visible !important;
    white-space: normal !important;
    padding-right: 1rem !important;
}

.layout-menu .menu-header .menu-header-text {
    display: block;
    max-width: 100%;
    font-size: 0.66rem;
    line-height: 1.35;
    color: var(--text-muted);
    letter-spacing: 0;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: normal;
    overflow-wrap: anywhere;
}

.menu-vertical .menu-item .menu-link i,
.menu-vertical .menu-icon {
    width: 1.15rem;
    min-width: 1.15rem;
    font-size: 1.15rem;
    text-align: center;
}

.menu-vertical .menu-sub .menu-link {
    min-height: 2.125rem;
    height: auto;
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
}

.menu-vertical .menu-sub .menu-link .text-truncate {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.menu-vertical .menu-sub .menu-link small {
    display: block;
    line-height: 1.35;
    white-space: normal;
}

/* --- Legacy page normalizers --- */
.summary,
.content-wrapper .p-3.text-white.rounded[style*="height: 60px"] {
    min-height: 86px !important;
    height: auto !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm);
    padding: var(--card-pad-sm) !important;
    line-height: 1.35;
}

.summary span,
.content-wrapper .p-3.text-white.rounded[style*="height: 60px"] span {
    font-size: 0.8125rem !important;
    line-height: 1.35;
    margin-right: 0.75rem;
}

.summary strong,
.content-wrapper .p-3.text-white.rounded[style*="height: 60px"] strong {
    font-size: 1.125rem !important;
    line-height: 1.1;
    white-space: nowrap;
}

.content-wrapper .row[style*="font-size: 11px"] {
    font-size: 0.75rem !important;
    line-height: 1.45 !important;
}

.content-wrapper .table[style*="font-size: 12px"],
.content-wrapper .table[style*="font-size: 13px"],
.content-wrapper table[style*="font-size: 12px"],
.content-wrapper table[style*="font-size: 13px"] {
    font-size: 0.8125rem !important;
}

.content-wrapper p[style*="font-size: 12px"],
.content-wrapper p[style*="font-size: 13px"],
.content-wrapper .small[style*="line-height"] {
    font-size: 0.8125rem !important;
    line-height: 1.6 !important;
    color: var(--text-muted) !important;
}

.content-wrapper .badge[style*="font-size: 10px"] {
    font-size: 0.6875rem !important;
}

.content-wrapper .sticky-top {
    top: 1rem !important;
    z-index: 3 !important;
}

.content-wrapper .input-group-text[style*="width"] {
    min-width: 7rem;
    width: auto !important;
}

.simasku-token-form {
    width: min(100%, 28rem);
}

.content-wrapper .table-responsive[style*="font-size"] {
    font-size: 0.8125rem !important;
}

/* --- Spacing Utilities --- */
.mt-standard { margin-top: var(--sp-lg); }
.mb-standard { margin-bottom: var(--sp-lg); }
.p-standard { padding: var(--sp-lg); }

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    :root {
        --sp-lg: 1rem;
        --page-pad-y: 1rem;
        --page-pad-x: 1rem;
        --card-pad: 1rem;
        --header-pad-x: 1rem;
    }

    .card-body {
        padding: var(--card-pad) !important;
    }

    .card-header {
        align-items: flex-start;
        flex-direction: column;
        min-height: auto;
    }

    .content-wrapper .d-flex.justify-content-between.align-items-center {
        align-items: flex-start !important;
        gap: 0.75rem;
        flex-wrap: wrap;
    }

    .btn,
    .btn-sm {
        white-space: normal;
    }

    .dataTables_wrapper .d-flex.justify-content-between {
        align-items: flex-start !important;
        gap: 0.75rem;
    }
}

/* --- Micro-animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-wrapper > div {
    animation: fadeIn 0.4s ease-out;
}

.simasku-user-link {
    min-height: 2.625rem !important;
    align-items: center;
    margin-bottom: 0 !important;
    column-gap: 0.875rem;
}

.simasku-user-meta {
    min-width: 0;
    max-width: 100%;
    line-height: 1.25;
    margin-left: 0.125rem;
}

.simasku-user-initial {
    font-size: 0.8125rem;
    font-weight: 700;
}

.simasku-user-status {
    width: 0.5rem;
    height: 0.5rem;
    transform: translate(-2px, -2px);
}

/* --- Premium Enhancements --- */
/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(105, 108, 255, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(105, 108, 255, 0.5);
}

/* Active Scale for Buttons */
.btn:active {
    transform: scale(0.97);
}

/* Subtle Sneat Striped Table Overrides */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #fafbfc !important;
    box-shadow: inset 0 0 0 9999px #fafbfc !important;
}

/* Sneat Borderless Table Bottom Row Fix */
.table tbody tr:last-child td {
    border-bottom: 0 !important;
}

/* Custom shadow for table containers to align with cards */
.table-responsive {
    border: 1px solid #e4e7ec !important;
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.02) !important;
}
