:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --sidebar-bg: #1a1d23;
    --sidebar-hover: #2a2d35;
    --sidebar-active: #0d6efd;
    --sidebar-text: #a0a4b0;
    --sidebar-text-active: #ffffff;
    --navbar-height: 56px;
    --font-family: 'Poppins', 'Inter', sans-serif;
    --card-radius: 12px;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --btn-radius: 8px;
    --input-radius: 8px;
}

* {
    font-family: var(--font-family);
}

body {
    background-color: #f4f6f9;
    min-height: 100vh;
    overflow-x: hidden;
}

#app-wrapper {
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand i {
    color: var(--sidebar-active);
}

.sidebar-toggle {
    color: var(--sidebar-text);
    font-size: 1.2rem;
    padding: 0;
    text-decoration: none;
}

.sidebar-toggle:hover {
    color: #fff;
}

.sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    padding: 12px 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-item {
    padding: 2px 12px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-nav .nav-group {
    padding: 16px 12px 4px;
}

.sidebar-nav .nav-group-label {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    padding: 0 16px;
}

.disabled-link {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

#topNavbar {
    min-height: var(--navbar-height);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.page-title {
    font-weight: 600;
    color: #333;
}

.footer {
    margin-top: auto;
    border-top: 1px solid #e9ecef;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

@media (min-width: 992px) {
    .sidebar.is-collapsed {
        transform: translateX(-100%);
    }

    .main-content.is-sidebar-collapsed {
        margin-left: 0;
    }
}

.login-page {
    background: linear-gradient(135deg, #1a1d23 0%, #2d3436 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-icon {
    width: 80px;
    height: 80px;
    background: #eef2ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

.table > :not(caption) > * > * {
    vertical-align: middle;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
}

.breadcrumb-item a {
    color: var(--sidebar-active);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: #6c757d;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.35);
    }

    .sidebar-overlay.is-active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0;
    }

    .login-container {
        padding: 16px;
    }

    .login-card {
        padding: 28px 20px;
    }
}

body.sidebar-mobile-open {
    overflow: hidden;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 6px 12px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px;
}

.btn {
    border-radius: 8px;
    font-weight: 500;
}

.form-control {
    border-radius: 8px;
    border-color: #e0e0e0;
}

.form-control:focus {
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.input-group-text {
    border-radius: 8px;
    background: #f8f9fa;
    border-color: #e0e0e0;
}

.modal-content {
    border: none;
    border-radius: 12px;
}

.alert {
    border: none;
    border-radius: 10px;
}

/* ========================================
   RESPONSIVE — MINIMAL & CLEAN
   ======================================== */

/* Tables: responsive wrapper */
.dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ALL tables: prevent overflow on small screens */
.table-responsive {
    margin-bottom: 0;
}

/* Filter + date form on mobile: stack vertically */
@media (max-width: 576px) {
    .btn-group {
        flex-wrap: wrap;
        gap: 3px;
    }
    .btn-group .btn {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
    form.d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }
    form.d-flex input[type="date"] {
        width: 100% !important;
        min-width: unset !important;
    }
}

/* Form buttons on mobile: full width */
@media (max-width: 576px) {
    form .d-flex.gap-2 {
        flex-direction: column;
    }
    form .d-flex.gap-2 .btn {
        width: 100%;
    }
}

/* Card header: wrap badge on mobile */
@media (max-width: 576px) {
    .card-header.d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.25rem;
    }
    .card-header.d-flex .badge {
        align-self: flex-start;
    }
}

/* Canvas (charts): responsive */
canvas {
    max-width: 100%;
    height: auto !important;
}

/* Prevent iOS zoom on input focus */
input, select, textarea {
    font-size: 16px;
}

/* Touch targets: minimum 44px for buttons on touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        min-height: 44px;
    }
    .sidebar-nav .nav-link {
        padding: 12px 16px;
        min-height: 44px;
    }
}

/* Breadcrumb: wrap on mobile */
@media (max-width: 576px) {
    .breadcrumb {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }
}

/* Login page: tighter padding on small screens */
@media (max-width: 480px) {
    .login-card {
        padding: 24px 16px;
    }
    .login-icon {
        width: 60px;
        height: 60px;
    }
}

/* Sidebar: slightly narrower on tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .sidebar {
        width: 240px;
    }
}

/* Action buttons in quick actions: responsive font */
@media (max-width: 400px) {
    .btn:not(.btn-sm) {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }
}

/* Tables (any table with data-label attributes) → card layout on very small screens */
@media (max-width: 576px) {
    table[data-responsive="true"] thead,
    #stockPadiTable thead,
    #stockBerasTable thead,
    #recentTransactionsTable thead {
        display: none;
    }

    table[data-responsive="true"],
    table[data-responsive="true"] tbody,
    #stockPadiTable,
    #stockPadiTable tbody,
    #stockBerasTable,
    #stockBerasTable tbody,
    #recentTransactionsTable,
    #recentTransactionsTable tbody {
        display: block;
        width: 100%;
    }

    table[data-responsive="true"] tbody tr,
    #stockPadiTable tbody tr,
    #stockBerasTable tbody tr,
    #recentTransactionsTable tbody tr {
        display: block;
        padding: 10px 12px;
        border-bottom: 1px solid #e9ecef;
    }

    table[data-responsive="true"] tbody tr:last-child,
    #stockPadiTable tbody tr:last-child,
    #stockBerasTable tbody tr:last-child,
    #recentTransactionsTable tbody tr:last-child {
        border-bottom: none;
    }

    table[data-responsive="true"] tbody td,
    #stockPadiTable tbody td,
    #stockBerasTable tbody td,
    #recentTransactionsTable tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        text-align: right !important;
    }

    table[data-responsive="true"] tbody td:before,
    #stockPadiTable tbody td:before,
    #stockBerasTable tbody td:before,
    #recentTransactionsTable tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        font-size: 0.8rem;
        text-align: left;
    }
}
