/**
 * ERP Batik - Custom CSS
 * Theme: Elegant Brown
 * Version: 1.0
 */

:root {
    /* Color Palette - Brown Theme */
    --primary-color: #8B4513;
    /* Saddle Brown */
    --secondary-color: #A0522D;
    /* Sienna */
    --accent-color: #D2691E;
    /* Chocolate */
    --light-brown: #F5DEB3;
    /* Wheat */
    --dark-brown: #654321;
    /* Dark Brown */
    --bg-light: #FFF8DC;
    /* Cornsilk */
    --text-dark: #3E2723;
    /* Dark Brown Text */
    --success: #4CAF50;
    --danger: #f44336;
    --warning: #ff9800;
    --info: #2196F3;

    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-bg: #654321;
    --sidebar-text: #F5DEB3;
    --sidebar-hover: #8B4513;

    /* Header */
    --header-height: 60px;
    --header-bg: #8B4513;
    --header-text: #ffffff;
}

/* ===========================
   GENERAL STYLES
   =========================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: var(--text-dark);
    overflow-x: hidden;
}

.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-custom {
    background-color: var(--primary-color) !important;
}

.btn-primary-custom {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-primary-custom:hover {
    background-color: var(--dark-brown);
    border-color: var(--dark-brown);
    color: white;
}

.btn-secondary-custom {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

.btn-secondary-custom:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* ===========================
   HEADER / NAVBAR
   =========================== */
.navbar-custom {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: var(--header-height);
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 1000;
    transition: all 0.3s ease;
}

.navbar-custom.sidebar-collapsed {
    left: 0;
}

.navbar-brand {
    color: var(--header-text) !important;
    font-weight: 700;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    /* Important for truncation */
}

.navbar-brand:hover {
    color: var(--light-brown) !important;
}

.navbar-nav .nav-link {
    color: var(--header-text) !important;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5);
    color: var(--header-text);
}

/* User Dropdown */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--header-text);
    cursor: pointer;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid var(--light-brown);
    object-fit: cover;
}

/* ===========================
   SIDEBAR
   =========================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--dark-brown) 100%);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    overflow: hidden;
    /* Prevent sidebar itself from scrolling */
    transition: all 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--sidebar-text);
    position: relative;
    z-index: 10;
}

.sidebar-menu-title {
    font-size: 1rem;
    color: var(--sidebar-text);
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu-item {
    margin: 0.25rem 0.75rem;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.sidebar-menu-link:hover {
    background-color: var(--sidebar-hover);
    color: white;
}

.sidebar-menu-link.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

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

.sidebar-menu-badge {
    margin-left: auto;
    font-size: 0.75rem;
}

/* Submenu */
.sidebar-submenu {
    list-style: none;
    padding-left: 1.5rem;
    margin: 0.25rem 0;
    display: none;
}

.sidebar-submenu.show {
    display: block;
}

.sidebar-submenu-link {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--light-brown);
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.sidebar-submenu-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-submenu-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 500;
}

/* Sidebar Menu Scrollbar */
.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===========================
   MAIN CONTENT
   =========================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
    transition: all 0.3s ease;
}

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

/* Page Header */
.page-header {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.page-subtitle {
    color: #6c757d;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

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

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

.breadcrumb-item.active {
    color: var(--text-dark);
}

/* ===========================
   CARDS
   =========================== */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    /* transform: translateY(-2px); REMOVED as per user request */
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    border-radius: 10px 10px 0 0 !important;
    border: none;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Fix for white background headers */
.card-header.bg-white {
    background-color: white !important;
    color: var(--text-dark);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    /* Add subtle border */
}

.card-header.bg-white h5,
.card-header.bg-white h6 {
    color: var(--text-dark);
}

.card-header-light {
    background-color: white;
    color: var(--primary-color);
    border-bottom: 2px solid var(--light-brown);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 10px 10px !important;
}

/* Stats Cards */
.stats-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: 10px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.stats-card-icon {
    font-size: 3rem;
    opacity: 0.3;
    position: absolute;
    right: 1rem;
    bottom: 1rem;
}

.stats-card-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stats-card-label {
    font-size: 0.95rem;
    opacity: 0.9;
}

/* ===========================
   TABLES
   =========================== */
.table-responsive {
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: var(--primary-color);
    color: white;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    padding: 1rem;
}

.table tbody tr {
    transition: all 0.3s ease;
}

.table tbody tr:hover {
    background-color: var(--bg-light);
    /* transform: scale(1.01); REMOVED to prevent visual glitches */
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    color: var(--text-dark);
    /* Ensure text is visible */
}

/* DataTables Custom Styling */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 0.375rem 0.75rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--secondary-color) !important;
    border-color: var(--secondary-color) !important;
    color: white !important;
}

.dataTables_empty {
    text-align: center;
    padding: 2rem !important;
    color: var(--text-dark);
    font-style: italic;
    background-color: white !important;
}

/* ===========================
   FORMS
   =========================== */
.form-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 0.625rem 0.875rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(139, 69, 19, 0.25);
}

/* Select2 Custom Styling */
.select2-container--default .select2-selection--single {
    border: 1px solid #ddd;
    border-radius: 5px;
    height: calc(2.5rem + 2px);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 2.5rem;
    color: var(--text-dark);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(2.5rem + 2px);
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--primary-color);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color);
}

/* ===========================
   BADGES
   =========================== */
.badge {
    padding: 0.35rem 0.65rem;
    font-weight: 500;
    border-radius: 5px;
}

.badge-brown {
    background-color: var(--primary-color);
    color: white;
}

.badge-brown-light {
    background-color: var(--light-brown);
    color: var(--dark-brown);
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
    border-radius: 5px;
    padding: 0.5rem 1.25rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn-group .btn {
    border-radius: 5px;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.btn-icon {
    width: 35px;
    height: 35px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

/* ===========================
   ALERTS / NOTIFICATIONS
   =========================== */
.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.25rem;
}

.swal2-popup {
    border-radius: 10px;
}

.swal2-confirm {
    background-color: var(--primary-color) !important;
}

.swal2-cancel {
    background-color: #6c757d !important;
}

/* ===========================
   FOOTER
   =========================== */
.footer {
    background-color: white;
    padding: 1.5rem;
    text-align: center;
    border-top: 1px solid #e9ecef;
    margin-top: 3rem;
}

.footer-text {
    color: #6c757d;
    font-size: 0.875rem;
    margin: 0;
}

/* ===========================
   AUTH PAGES
   =========================== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-color) 50%, var(--accent-color) 100%);
    padding: 2rem;
}

.auth-card {
    max-width: 450px;
    width: 100%;
    background: white;
    border-radius: 15px;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h2 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-logo p {
    color: #6c757d;
    font-size: 0.95rem;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .navbar-custom {
        left: 0;
        padding: 0 1rem;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .navbar-custom {
        padding: 0.5rem;
        height: auto;
        min-height: var(--header-height);
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .gap-3 {
        gap: 0.75rem !important;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-card {
        margin-bottom: 1rem;
    }

    .table {
        font-size: 0.875rem;
    }
}

/* ===========================
   UTILITIES
   =========================== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

/* Preloader */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.spinner-batik {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(139, 69, 19, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: batikSpin 1s linear infinite;
    margin: 0 auto;
}

.loader-text {
    font-size: 1.25rem;
    letter-spacing: 5px;
    margin-top: 1rem;
}

.loader-progress {
    width: 100px;
    height: 3px;
    background: #eee;
    margin: 10px auto;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
}

.loader-progress::after {
    content: '';
    position: absolute;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    animation: progressMove 1.5s ease-in-out infinite;
}

@keyframes batikSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes progressMove {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pointer {
    cursor: pointer;
}

.text-brown {
    color: var(--primary-color);
}

.bg-brown {
    background-color: var(--primary-color);
}

.border-brown {
    border-color: var(--primary-color) !important;
}