/* ============================================================
   TABUNGAN SIMPAN PINJAM - BUMDes Mekar Lestari
   Mobile-First Stylesheet
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --bottom-nav-height: 60px;
    --primary: #198754;
    --primary-dark: #146c43;
    --primary-light: #d1e7dd;
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f0f2f5;
    font-size: 0.9rem;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

/* ---- Layout Wrapper ---- */
.wrapper {
    min-height: 100vh;
    padding-top: var(--topbar-height);
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
#topNavbar {
    height: var(--topbar-height);
    z-index: 1040;
}

#topNavbar .navbar-brand {
    font-size: 1rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-height: calc(100vh - var(--topbar-height));
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1035;
    scrollbar-width: thin;
    scrollbar-color: #495057 transparent;
    transform: translateX(0);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #495057; border-radius: 2px; }

/* Desktop: sidebar selalu tampil */
@media (min-width: 769px) {
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: var(--sidebar-width);
        transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .main-content.expanded {
        margin-left: 0;
    }
}

/* Mobile: sidebar tersembunyi default, slide in saat show */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,0.25);
    }
    .main-content {
        margin-left: 0 !important;
        padding-bottom: calc(var(--bottom-nav-height) + 8px);
    }
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1034;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* Sidebar Links */
.sidebar-link {
    color: #adb5bd !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
}
.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,0.1) !important;
    color: #fff !important;
}
.sidebar-link.active {
    background: var(--primary) !important;
    color: #fff !important;
}
.sidebar-label {
    display: block;
    color: #6c757d;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 12px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.content-area {
    min-height: calc(100vh - var(--topbar-height));
    padding: 12px !important;
}

@media (min-width: 769px) {
    .content-area { padding: 20px !important; }
}

/* ============================================================
   BOTTOM NAVIGATION (Mobile Only)
   ============================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: #fff;
    border-top: 1px solid #e9ecef;
    z-index: 1030;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    padding: 6px 4px;
    border-radius: 8px;
    margin: 4px 2px;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 1.3rem; margin-bottom: 2px; line-height: 1; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:active { background: var(--primary-light); transform: scale(0.95); }

@media (max-width: 768px) {
    .bottom-nav { display: flex; }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    background: linear-gradient(135deg, #198754 0%, #20c997 100%);
    border-radius: 12px;
    color: white;
    padding: 16px;
    margin-bottom: 16px;
}
.page-header h4 { margin: 0; font-weight: 700; font-size: 1rem; }
.page-header p  { margin: 2px 0 0; opacity: 0.85; font-size: 0.8rem; }

@media (min-width: 769px) {
    .page-header { padding: 20px 24px; margin-bottom: 20px; }
    .page-header h4 { font-size: 1.1rem; }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card-header {
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 12px 16px;
}
.card-body { padding: 16px; }

/* Stat Cards */
.stat-card {
    border-radius: 12px;
    border: none;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.stat-card:active { transform: scale(0.97); }

@media (min-width: 769px) {
    .stat-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.12) !important;
    }
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .stat-icon { width: 52px; height: 52px; font-size: 1.4rem; }
}

/* ============================================================
   TABLES - Mobile Responsive
   ============================================================ */
.table th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    border-top: none;
    background: #f8f9fa;
    white-space: nowrap;
    padding: 8px 10px;
}
.table td {
    vertical-align: middle;
    font-size: 0.85rem;
    padding: 8px 10px;
}
.table-hover tbody tr:hover { background-color: rgba(25,135,84,0.06); }

/* Swipeable table on mobile */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: 0 0 12px 12px;
}

/* Mobile table: compact */
@media (max-width: 576px) {
    .table th, .table td { padding: 6px 8px; font-size: 0.8rem; }
    .table th { font-size: 0.72rem; }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label { font-weight: 500; font-size: 0.875rem; margin-bottom: 4px; }
.form-control, .form-select {
    border-radius: 8px;
    border-color: #dee2e6;
    font-size: 0.9rem;
    padding: 10px 12px;
    min-height: 44px; /* touch target */
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(25,135,84,0.2);
}
.form-control-sm, .form-select-sm {
    min-height: 36px;
    padding: 6px 10px;
}
.input-group-text {
    border-radius: 8px 0 0 8px;
    background: #f8f9fa;
    border-color: #dee2e6;
    font-size: 0.875rem;
    min-height: 44px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-sm {
    font-size: 0.8rem;
    border-radius: 6px;
    min-height: 32px;
    padding: 4px 10px;
}
.btn-lg { min-height: 48px; font-size: 1rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { font-weight: 500; font-size: 0.75rem; border-radius: 6px; padding: 4px 8px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(160deg, #198754 0%, #0f5132 60%, #052c16 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card {
    background: white;
    border-radius: 20px;
    padding: 28px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
@media (min-width: 480px) {
    .login-card { padding: 40px; }
}
.login-logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #198754, #20c997);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    margin: 0 auto 16px;
}

/* ============================================================
   TRANSACTION COLORS
   ============================================================ */
.trx-setor { color: #198754; font-weight: 600; }
.trx-tarik { color: #dc3545; font-weight: 600; }

/* ============================================================
   SUMMARY BOX
   ============================================================ */
.summary-box {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 10px;
    padding: 14px;
    border-left: 4px solid var(--primary);
}

/* ============================================================
   PROGRESS
   ============================================================ */
.progress { height: 8px; border-radius: 4px; }

/* ============================================================
   ALERT
   ============================================================ */
.alert { border-radius: 10px; font-size: 0.875rem; }
.alert-permanent { /* stays on screen */ }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination { flex-wrap: wrap; gap: 4px; }
.page-link { border-radius: 6px !important; min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; }

/* ============================================================
   MODAL - Mobile Full Height
   ============================================================ */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 8px;
        max-width: calc(100% - 16px);
    }
    .modal-content { border-radius: 16px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
}

/* ============================================================
   DATATABLES
   ============================================================ */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 6px 12px;
    font-size: 0.875rem;
    min-height: 36px;
}
.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 4px 8px;
    min-height: 36px;
}
@media (max-width: 576px) {
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length { width: 100%; text-align: left; }
    .dataTables_wrapper .dataTables_filter input { width: 100%; }
}

/* ============================================================
   MOBILE CARD STACKING (replaces table on small screens)
   ============================================================ */
@media (max-width: 576px) {
    /* Stat cards 2 column */
    .stat-row .col-6 { padding: 4px; }
    .stat-card .card-body { padding: 12px; }
    .stat-card .fs-4 { font-size: 1.2rem !important; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .sidebar, #topNavbar, .btn, .no-print, .bottom-nav,
    .sidebar-overlay, .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_paginate { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    .page-header {
        background: #198754 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    body { background: white !important; }
}

/* ============================================================
   UTILITY
   ============================================================ */
.cursor-pointer { cursor: pointer; }
.fs-xs { font-size: 11px; }
.min-touch { min-height: 44px; min-width: 44px; }
