:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --sidebar-width: 250px;
}

body {
    font-size: 0.875rem;
    background-color: #f8f9fa;
}

/* Sidebar dengan Scroll */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    overflow-y: auto; /* Enable vertical scrolling */
    height: 100vh; /* Full height */
}

/* Custom Scrollbar untuk Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #343a40;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

.sidebar .nav-link {
    font-weight: 500;
    color: #adb5bd;
    padding: 0.75rem 1rem;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary-color);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary-color);
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.sidebar .nav-link:hover i {
    transform: scale(1.1);
}

.sidebar-header {
    padding: 0 1rem;
    position: sticky;
    top: 0;
    background-color: #343a40;
    z-index: 101;
    border-bottom: 1px solid #495057;
}

.sidebar .dropdown-menu {
    background-color: #343a40;
    border: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar .dropdown-toggle[aria-expanded="true"] + .dropdown-menu {
    max-height: 300px;
    overflow-y: auto;
}

.sidebar .dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar .dropdown-menu::-webkit-scrollbar-thumb {
    background: #6c757d;
}

.sidebar .dropdown-item {
    color: #adb5bd;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.sidebar .dropdown-item:hover,
.sidebar .dropdown-item.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-divider {
    border-top: 1px solid #495057;
    margin: 0.5rem 1rem;
}

/* Main content */
main {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

/* Top navbar */
.navbar-light {
    background-color: #fff !important;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 99;
}

/* Smooth transitions */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

/* Back to top button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.back-to-top:hover {
    opacity: 1;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive sidebar */
@media (max-width: 767.98px) {
    .sidebar {
        position: static;
        height: auto;
        max-height: 300px;
    }
    
    main {
        margin-left: 0;
    }
    
    .sidebar.collapse {
        display: none;
    }
    
    .sidebar.collapse.show {
        display: block;
    }
}

/* Statistics Cards dengan hover effect */
.card.border-left-primary:hover {
    border-left-color: #2e59d9 !important;
}

.card.border-left-success:hover {
    border-left-color: #1cc88a !important;
}

.card.border-left-info:hover {
    border-left-color: #36b9cc !important;
}

.card.border-left-warning:hover {
    border-left-color: #f6c23e !important;
}

/* Table enhancements dengan scroll */
.table-responsive {
    border-radius: 0.375rem;
}

.table th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
}

/* Form enhancements */
.form-control:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

/* Custom utilities untuk animasi */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}


/* DataTables Customization */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_length,
.dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_filter input {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
}

.dataTables_info {
    padding-top: 0.75rem !important;
}

/* Loading states */
.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.nav-link.loading {
    position: relative;
    color: transparent !important;
}

.nav-link.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #adb5bd;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

/* Table enhancements */
.table-active {
    background-color: rgba(0, 123, 255, 0.1) !important;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.075);
}

/* Sidebar collapsed state */
.sidebar.collapsed {
    margin-left: -250px;
}

main.expanded {
    margin-left: 0;
}

/* Back to top button enhancements */
.back-to-top {
    transition: all 0.3s ease !important;
}

.back-to-top:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

/* File input styling */
.file-input-group {
    position: relative;
}

.file-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-preview {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

/* Character counter */
.char-counter {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
}

.char-counter.text-warning {
    font-weight: bold;
}

/* Bulk actions */
.bulk-actions {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    display: none;
}

/* Custom toast notifications */
.custom-toast {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .bulk-actions,
    .dataTables_length,
    .dataTables_filter,
    .dataTables_paginate {
        display: none !important;
    }
    
    main {
        margin-left: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}

/* Responsive table with horizontal scroll */
.table-responsive.scroll-shadow {
    position: relative;
}

.table-responsive.scroll-shadow::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.1));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.table-responsive.scroll-shadow.scrolling::after {
    opacity: 1;
}

/* Custom scrollbar for table */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Keyboard shortcut hint */
.keyboard-hint {
    font-size: 0.75rem;
    color: #6c757d;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: #f8f9fa;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .table {
        color: #fff;
        background-color: #343a40;
    }
    
    .table th,
    .table td {
        border-color: #495057;
    }
    
    .table-hover tbody tr:hover {
        background-color: rgba(255, 255, 255, 0.075);
    }
}