/* =========================================
   1. CONFIG & VARIABLES
   ========================================= */
:root {
    --warna-utama: #2563eb;
    --warna-header: #ffffff;
    --warna-sidebar: #1e293b;
    --warna-teks-sidebar: #cbd5e1;
    --warna-teks-hover: #ffffff;
    --warna-background: #cbd5e1;
    --warna-teks: #334155;

    --tinggi-header: 60px;
    --lebar-sidebar: 250px;
    --transisi: all 0.3s ease;
}

/* Rendering Optimization */
.main-content,
.sidebar {
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
    /* Approximate height to prevent scroll jank */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--warna-background);
    color: var(--warna-teks);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
}

ul {
    list-style: none;
}

/* =========================================
   2. SIDEBAR
   ========================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--lebar-sidebar);
    height: 100vh;
    background-color: #0F2E4A;
    transition: var(--transisi);
    will-change: transform, left;
    /* Hint to browser */
    z-index: 1000;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: var(--tinggi-header);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    background-color: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    contain: content;
}

.sidebar-menu {
    padding: 10px 0;
    flex: 1;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: var(--warna-teks-sidebar);
    transition: 0.2s;
    border-left: 4px solid transparent;
    text-decoration: none;
}

.sidebar-menu li a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar-menu li a span.arrow {
    margin-left: auto;
}

.sidebar-menu li a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--warna-teks-hover);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.sidebar-menu li a.active {
    background-color: rgba(255, 255, 255, 0.25);
    /* Make it distinct */
    color: #FFD700;
    border-left-color: #fbbf24;
    /* Amber accent to stand out */
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Dropdown Style */
.dropdown-menu {
    background-color: rgba(0, 0, 0, 0.2);
    display: none;
}

.dropdown-menu li a {
    padding-left: 45px;
    font-size: 0.95rem;
}

.dropdown-menu.show {
    display: block;
}

.sidebar.closed {
    left: calc(var(--lebar-sidebar) * -1);
}

/* =========================================
   3. HEADER
   ========================================= */
.header {
    position: fixed;
    top: 0;
    left: var(--lebar-sidebar);
    /* Starts after sidebar */
    width: calc(100% - var(--lebar-sidebar));
    height: var(--tinggi-header);
    background-color: var(--warna-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 900;
    transition: var(--transisi);
    will-change: width, left;
}

.header.full-width {
    left: 0;
    width: 100%;
}

.menu-toggle {
    cursor: pointer;
    font-size: 1.5rem;
    background: none;
    border: none;
    color: var(--warna-teks);
}

/* =========================================
   4. MAIN CONTENT
   ========================================= */
.main-content {
    margin-left: var(--lebar-sidebar);
    padding: calc(var(--tinggi-header) + 30px) 30px 30px;
    /* Top padding = header height + gap */
    transition: var(--transisi);
    min-height: 100vh;
}

.main-content.full-width {
    margin-left: 0;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    /* Lighter shadow for performance */
    margin-bottom: 20px;
    background-color: #fff;
    contain: content;
    /* Isolate layout calculation */
}

/* =========================================
   5. RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        left: -100%;
        width: 100%;
        max-width: 300px;
    }

    .sidebar.active {
        left: 0;
    }

    .header {
        left: 0;
        width: 100%;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Accordion Styles */
.accordion-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
}

.accordion-header:hover {
    background-color: #f1f5f9;
}

.accordion-body {
    padding: 20px;
    display: none;
    border-radius: 0 0 8px 8px;
    contain: content;
}

.accordion-item.active .accordion-body {
    display: block;
}

.accordion-item.active .accordion-header {
    background-color: #e0f2fe;
    color: #0369a1;
    border-bottom: 1px solid #bae6fd;
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

/* Button Styles */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transisi);
    will-change: background-color, transform;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    will-change: background-color;
    /* Optimized transitions */
}

.btn-primary {
    background-color: var(--warna-utama);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-warning {
    background-color: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.table tr:hover {
    background-color: #f1f5f9;
}

/* DataTables Spacing */
.dataTables_wrapper .dataTables_length,
/* Utility Classes */
.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.text-left {
    text-align: left !important;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    contain: strict;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 500px;
}



.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #1e293b;
    font-size: 1.25rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #ef4444;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #475569;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s;
    will-change: border-color, box-shadow;
}

.form-control:focus {
    outline: none;
    border-color: var(--warna-utama);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: #f8fafc;
    border-radius: 0 0 8px 8px;
}

.btn-secondary:hover {
    background-color: #64748b;
}

/* User Profile Dropdown */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.user-profile:hover {
    background-color: #f1f5f9;
}

.user-avatar {
    width: 30px;
    height: 30px;
    background-color: var(--warna-utama);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 180px;
    background-color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    padding: 5px 0;
    display: none;
    z-index: 1000;
    margin-top: 10px;
    border: 1px solid #e2e8f0;
}

.profile-dropdown.show {
    display: block;
}

.profile-dropdown a {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    color: var(--warna-teks);
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.profile-dropdown a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    color: #64748b;
}

.profile-dropdown a:hover {
    background-color: #f8fafc;
    color: var(--warna-utama);
}

.profile-dropdown a:hover i {
    color: var(--warna-utama);
}

/* SweetAlert Custom Container */
.my-swal-container {
    z-index: 9999 !important;
}




.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-image: linear-gradient(288deg, rgba(0, 85, 255, 1) 1.5%, rgba(4, 56, 115, 1) 91.6%);
    position: relative;
}

.login-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(3px);
    pointer-events: none;
}

#particles-js {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 0;
    contain: strict;
    pointer-events: none;
    /* Improvement: allow clicks to pass through if needed, though usually background */
}

.login-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 10;
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-header h2 {
    color: #FFD700;
    font-size: 2rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: 700;
}

.login-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.login-form .form-group {
    text-align: left;
    margin-bottom: 20px;
}

.login-form label {
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.login-form label i {
    color: #ffffff !important;
}

/* Button Gradient Style */
.btn-grad {
    background-image: linear-gradient(to right, #000428 0%, #004e92 51%, #000428 100%);
    margin: 20px 0;
    padding: 15px 45px;
    text-align: center;
    text-transform: uppercase;
    transition: 0.5s;
    background-size: 200% auto;
    will-change: background-position;
    color: white;
    box-shadow: none;
    border-radius: 10px;
    display: block;
    outline: none;
    border: none;
    width: 100%;
    cursor: pointer;
    font-weight: 600;
}

.btn-grad:hover {
    background-position: right center;
    color: #fff;
    text-decoration: none;
}

/* Transaction Tabs */
.transaksi-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--warna-utama);
}

.tab-btn.active {
    color: var(--warna-utama);
    border-bottom-color: var(--warna-utama);
}

.tab-content {
    display: none;
    padding: 10px 0;
}

.tab-content.active {
    display: block;
}

/* Search Bar */
.search-container {
    margin-bottom: 20px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--warna-utama);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

/* Ensure consistent height for form elements in filters */
input[type="date"].form-control {
    height: 38px;
    /* Reduced to match smaller buttons */
    padding: 6px 10px;
}

.filter-actions .btn {
    height: 38px;
    /* Match input height */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    /* User requested 200px */
    gap: 15px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* Prevent scrollbar cutting off card edges */
    padding-bottom: 15px; /* Extra space at bottom */
    align-content: start;
}

/* Custom Scrollbar for Product Grid */
.product-grid::-webkit-scrollbar {
    width: 6px;
}
.product-grid::-webkit-scrollbar-track {
    background: #f1f5f9; 
    border-radius: 4px;
}
.product-grid::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 4px;
}
.product-grid::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

.product-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Ensures content is spaced out */
    height: 100%;
    /* Forces cards to fill the grid cell height */
    /* Removed transition properties */
}

/* Specific Border Colors */
/* Assuming a class will be added to differentiate, or using parent selector */
#tab-ikan .product-card {
    border: 2px solid #f59e0b;
    /* Yellow for Fish */
}

#tab-barang .product-card {
    border: 2px solid #2563eb;
    /* Blue for Goods */
}

/* Removed .product-card:hover */

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Centered alignment */
    margin-bottom: 5px;
    /* Reduced margin */
}

/* Reordering elements visually is tricky with just CSS if HTML structure is fixed, 
   but user asked to put name BELOW select. 
   I will need to update HTML in the next step. 
   Here I just adjust styles for sizes. */

.product-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 5px;
    margin-top: 10px;
    /* Added top margin for spacing when moved */
}

.product-stock {
    font-size: 0.8rem;
    color: white;
    /* Changed to white for better contrast on colored badges */
    padding: 2px 8px;
    border-radius: 4px;
    align-self: flex-end;
}

.qty-container {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
}

.qty-btn {
    background: #f1f5f9;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1rem;
    color: #475569;
    transition: background-color 0.2s;
    width: 40px;
    /* Fixed width for better look */
    display: flex;
    justify-content: center;
    align-items: center;
}

.qty-btn:hover:not(:disabled) {
    background-color: #e2e8f0;
    color: #1e293b;
}

.qty-btn:active:not(:disabled) {
    background-color: #cbd5e1;
}

.qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.qty-input {
    flex-grow: 1;
    /* Make input fill remaining space */
    width: 0;
    /* Reset width to allow flex-grow to work properly */
    text-align: center;
    border: none;
    padding: 8px;
    font-size: 1rem;
    outline: none;
    appearance: textfield;
    -moz-appearance: textfield;
    /* Remove arrows firefox */
}

/* Remove arrows chrome/safari/edge */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}



.product-stock.in-stock {
    background-color: #10b981;
    /* Green */
}

.product-stock.out-of-stock {
    background-color: #ef4444;
    /* Red */
}

.finance-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--warna-utama);
    margin: 5px 0;
    /* Reduced margin */
}

.product-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 15px;
}

.qty-input {
    width: 80px;
    /* Increased from 60px */
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    text-align: center;
}

.qty-input-cart {
    font-size: 1rem;
    padding: 5px;
    width: 80px;
    text-align: center;
}

.btn-add {
    flex: 1;
    background-color: var(--warna-utama);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.cart-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .cart-layout {
        grid-template-columns: 1fr;
    }
}

.cart-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.cart-summary {
    background-color: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #cbd5e1;
}

.summary-row.total {
    border-bottom: none;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--warna-utama);
    margin-top: 10px;
}

.payment-section {
    margin-top: 20px;
}

.payment-section h4 {
    margin-bottom: 15px;
    color: #1e293b;
}

.btn-process {
    width: 100%;
    background-color: #10b981;
    color: white;
    padding: 12px;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 15px;
}

.btn-process:hover {
    background-color: #059669;
}

.btn-reset {
    width: 100%;
    background-color: #ef4444;
    color: white;
    padding: 10px;
    font-size: 0.9rem;
    margin-top: 10px;
}

.btn-reset:hover {
    background-color: #dc2626;
}