/* ===== Smart Tool Cabinet Management Platform ===== */
:root {
    --primary: #2c3e50;
    --primary-light: #34495e;
    --sidebar-bg: #1a252f;
    --sidebar-hover: #243242;
    --sidebar-active: #2c3e50;
    --accent: #3498db;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --info: #17a2b8;
    --light-bg: #f0f2f5;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --header-height: 56px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    background-color: var(--light-bg);
    color: #333;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #c2c7d0;
    z-index: 1040;
    transition: transform var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    margin-left: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.nav-section-title {
    padding: 12px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6c7a89;
    font-weight: 600;
}

.nav-item-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #c2c7d0;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
}

.nav-item-link.active {
    color: #fff;
    background: var(--accent);
}

.nav-item-link .nav-icon {
    width: 20px;
    font-size: 16px;
    margin-right: 12px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item-link .nav-text {
    flex: 1;
    white-space: nowrap;
}

.nav-item-link .nav-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.nav-item-link[aria-expanded="true"] .nav-arrow {
    transform: rotate(90deg);
}

.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.1);
}

.nav-submenu .nav-item-link {
    padding-left: 52px;
    font-size: 13px;
}

.nav-submenu .nav-item-link.active {
    background: rgba(52, 152, 219, 0.25);
    border-right: 3px solid var(--accent);
}

/* ===== Main Content Area ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-speed) ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid #e4e6eb;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    color: #555;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    margin-right: 16px;
}

.sidebar-toggle:hover {
    background: var(--light-bg);
}

.top-header .breadcrumb {
    margin-bottom: 0;
    background: none;
    padding: 0;
    font-size: 14px;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-right .btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: none;
    color: #555;
    font-size: 18px;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.header-right .btn-icon:hover {
    background: var(--light-bg);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 20px;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.2s;
    color: #333;
    font-size: 14px;
}

.user-dropdown .dropdown-toggle:hover {
    background: var(--light-bg);
}

.user-dropdown .dropdown-toggle::after {
    margin-left: 4px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.main-content {
    flex: 1;
    padding: 20px;
}

.main-footer {
    padding: 12px 20px;
    text-align: center;
    font-size: 13px;
    color: #999;
    border-top: 1px solid #e4e6eb;
    background: #fff;
}

/* Sidebar collapsed state */
body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

/* ===== Cards ===== */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    padding: 14px 20px;
    border-radius: 10px 10px 0 0 !important;
}

.card-body {
    padding: 20px;
}

/* Dashboard stat cards */
.stat-card {
    border-radius: 10px;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    opacity: 0.2;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 4px;
}

.stat-card .stat-change {
    font-size: 12px;
    margin-top: 8px;
}

.stat-card.bg-primary-gradient {
    background: linear-gradient(135deg, var(--accent), #2980b9);
}

.stat-card.bg-success-gradient {
    background: linear-gradient(135deg, var(--success), #219a52);
}

.stat-card.bg-warning-gradient {
    background: linear-gradient(135deg, var(--warning), #e67e22);
}

.stat-card.bg-danger-gradient {
    background: linear-gradient(135deg, var(--danger), #c0392b);
}

.stat-card.bg-info-gradient {
    background: linear-gradient(135deg, var(--info), #138496);
}

/* ===== Tables ===== */
.table-container {
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.table-container .table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.table-container .table-header h5 {
    margin: 0;
    font-weight: 600;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.table-hover tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.04);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.015);
}

/* ===== Status Badges ===== */
.badge-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-available {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.badge-in-use {
    background: rgba(52, 152, 219, 0.1);
    color: var(--accent);
}

.badge-maintenance {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
}

.badge-scrapped {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.badge-overdue {
    background: var(--danger);
    color: #fff;
}

.badge-normal {
    background: var(--success);
    color: #fff;
}

.badge-low-stock {
    background: var(--warning);
    color: #fff;
}

.badge-pending {
    background: rgba(23, 162, 184, 0.1);
    color: var(--info);
}

.badge-returned {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.badge-borrowed {
    background: rgba(52, 152, 219, 0.1);
    color: var(--accent);
}

/* ===== Forms ===== */
.form-label {
    font-weight: 500;
    font-size: 14px;
    color: #555;
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #ddd;
    padding: 8px 14px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.input-group-text {
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #f8f9fa;
}

.search-box {
    position: relative;
    max-width: 300px;
}

.search-box .form-control {
    padding-left: 36px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 14px;
    z-index: 5;
}

/* ===== Buttons ===== */
.btn {
    border-radius: 8px;
    font-size: 14px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #2980b9;
    border-color: #2980b9;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: #219a52;
    border-color: #219a52;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #e67e22;
    border-color: #e67e22;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-action {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
}

/* ===== Alerts / Toast ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border: none;
    min-width: 300px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-danger {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--accent);
}

.alert {
    border-radius: 10px;
    border: none;
    font-size: 14px;
}

.alert-info {
    background: rgba(52, 152, 219, 0.1);
    color: #2980b9;
}

.alert-success {
    background: rgba(39, 174, 96, 0.1);
    color: #219a52;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    color: #d68910;
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
}

/* ===== Pagination ===== */
.pagination .page-item .page-link {
    border-radius: 8px;
    margin: 0 2px;
    color: var(--primary);
    border: 1px solid #dee2e6;
    font-size: 14px;
    padding: 6px 12px;
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #ccc;
}

.page-info {
    font-size: 14px;
    color: #888;
}

/* ===== Modal ===== */
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.modal-header {
    border-bottom: 1px solid #eee;
    padding: 16px 20px;
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid #eee;
    padding: 12px 20px;
}

/* ===== Login Layout ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--primary) 50%, var(--accent) 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo .logo-icon {
    width: 60px;
    height: 60px;
    background: var(--accent);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    margin-bottom: 12px;
}

.login-logo h4 {
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 4px;
}

.login-logo p {
    color: #999;
    font-size: 14px;
}

/* ===== Error Page ===== */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.error-code {
    font-size: 100px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    opacity: 0.15;
}

.error-message {
    font-size: 20px;
    color: #555;
    margin-top: -10px;
    margin-bottom: 20px;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .main-wrapper {
        margin-left: 0;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1035;
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 12px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }

    .table-container .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===== Utilities ===== */
.text-primary-custom {
    color: var(--primary) !important;
}

.text-accent {
    color: var(--accent) !important;
}

.bg-primary-custom {
    background-color: var(--primary) !important;
}

.bg-accent {
    background-color: var(--accent) !important;
}

.rounded-lg {
    border-radius: 10px !important;
}

.fw-600 {
    font-weight: 600 !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

/* Loading spinner */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.spinner-wrapper {
    text-align: center;
}

.spinner-wrapper .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--accent);
}

/* Chart container */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 300px;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 8px !important;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #ddd;
    padding: 6px 12px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Print styles */
@media print {
    .sidebar,
    .top-header,
    .main-footer {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
