:root {
    --primary-color: #ff6b35;
    --secondary-color: #4ecdc4;
    --sidebar-bg: #1a1a2e;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topnav-height: 60px;
    --border-radius: 12px;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: #f5f6f9;
    color: #333;
}

/* RTL 根元素全局设置 */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="ltr"] {
    direction: ltr;
    text-align: left;
}

.admin-wrapper {
    display: flex;
    height: 100vh;
}

/* ==================== 侧边栏基础样式 ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.3s ease;

}


/* RTL 侧边栏位置 */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
}

/* 移动端侧边栏默认隐藏 (LTR) */
@media screen and (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

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

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

/* 移动端侧边栏 RTL 适配 */
@media screen and (max-width: 768px) {
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    [dir="rtl"] .sidebar.active {
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
}

.logo i {
    font-size: 28px;
    margin-right: 12px;
    color: var(--primary-color);
}

/* RTL logo 图标间距 */
[dir="rtl"] .logo i {
    margin-right: 0;
    margin-left: 12px;
}

.sidebar-nav {
    padding: 15px 0;
}

.nav-section {
    margin-bottom: 5px;
}

.nav-section-title {
    padding: 12px 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    user-select: none;
}

.nav-section-title:hover {
    color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.05);
}

.nav-section-title .nav-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}

/* 菜单折叠核心样式 */
.nav-section-items {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: none !important;
}

.nav-section.expanded .nav-section-items {
    display: block !important;
}

.nav-section .nav-section-title .nav-arrow {
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}

.nav-section.expanded .nav-section-title .nav-arrow {
    transform: rotate(180deg);
}

/* RTL 箭头旋转方向保持一致（旋转180deg 视觉合理） */
[dir="rtl"] .nav-section.expanded .nav-section-title .nav-arrow {
    transform: rotate(180deg);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px 12px 30px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 107, 53, 0.2), transparent);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-item i {
    width: 24px;
    margin-right: 12px;
    font-size: 16px;
}

/* RTL 导航项适配 */
[dir="rtl"] .nav-item {
    padding: 12px 30px 12px 20px;
    border-left: none;
    border-right: 3px solid transparent;
}

[dir="rtl"] .nav-item.active {
    background: linear-gradient(270deg, rgba(255, 107, 53, 0.2), transparent);
    border-right-color: var(--primary-color);
    border-left-color: transparent;
}

[dir="rtl"] .nav-item i {
    margin-right: 0;
    margin-left: 12px;
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    /* LTR 默认：为固定侧边栏留出左边距 */
    transition: all 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
[dir="ltr"] .main-content {
    direction: ltr;
    margin-left: var(--sidebar-width);
}

/* RTL 主内容区：右边距 */
[dir="rtl"] .main-content {
    direction: rtl;
    margin-right: var(--sidebar-width);
}

/* 侧边栏折叠状态 - LTR */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar .logo span,
.sidebar-collapsed .sidebar .nav-item span {
    display: none;
}

.sidebar-collapsed .sidebar .nav-section-title span {
    display: none;
}

.sidebar-collapsed .sidebar .logo {
    justify-content: center;
}

.sidebar-collapsed .sidebar .nav-item {
    justify-content: center;
    padding: 12px;
}

.sidebar-collapsed .sidebar .nav-item i {
    margin-right: 0;
    font-size: 18px;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* 侧边栏折叠状态 - RTL */
[dir="rtl"] .sidebar-collapsed .sidebar .nav-item i {
    margin-left: 0;
    margin-right: 0;
}

[dir="rtl"] .sidebar-collapsed .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-collapsed-width);
}

/* 移动端侧边栏折叠效果适配 */
@media screen and (max-width: 768px) {
    .sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width) !important;
    }

    .sidebar-collapsed .sidebar .logo span,
    .sidebar-collapsed .sidebar .nav-item span {
        display: none !important;
    }

    .sidebar-collapsed .sidebar .nav-section-title span {
        display: none !important;
    }

    .sidebar-collapsed .sidebar .logo {
        justify-content: center !important;
    }

    .sidebar-collapsed .sidebar .nav-section-title {
        display: flex !important;
        justify-content: center !important;
    }

    .sidebar-collapsed .sidebar .nav-item {
        justify-content: center !important;
        padding: 12px !important;
    }

    .sidebar-collapsed .sidebar .nav-item i {
        margin-right: 0 !important;
        font-size: 18px !important;
    }

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

    [dir="rtl"] .sidebar-collapsed .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

/* ==================== 顶部导航 ==================== */
.top-nav {
    height: var(--topnav-height);
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* RTL 导航左区域顺序不变（gap 自动适配） */
[dir="rtl"] .nav-left {
    flex-direction: row;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

.breadcrumb {
    display: flex;
    align-items: center;
    color: #999;
    font-size: 14px;
}

/* RTL 面包屑顺序反转 */
[dir="rtl"] .breadcrumb {
    flex-direction: row-reverse;
}

.breadcrumb a {
    color: #666;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.breadcrumb-separator {
    margin: 0 10px;
}

/* RTL 面包屑分隔符间距不变 */
[dir="rtl"] .breadcrumb-separator {
    margin: 0 10px;
}

.breadcrumb-item.active {
    color: #333;
}

.user-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropdown-toggle:hover {
    background: #eee;
}

.user-dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    min-width: 180px;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

/* RTL 下拉菜单位置 */
[dir="rtl"] .user-dropdown .dropdown-menu {
    right: auto;
    left: 0;
}

.user-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s ease;
}

.dropdown-item:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 5px 0;
}

/* ==================== 页面内容 ==================== */
.page-content {
    flex: 1;
    padding: 25px;
}

/* RTL 页面内容内边距对称，无需修改 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

/* RTL 页眉方向反转 */
[dir="rtl"] .page-header {
    flex-direction: row-reverse;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i {
    color: var(--primary-color);
}

.page-header p {
    font-size: 14px;
    color: #999;
    margin-top: 5px;
}

/* ==================== 卡片 ==================== */
.card {
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* RTL 卡片头部内容顺序反转（按钮组等） */
[dir="rtl"] .card-header {
    flex-direction: row-reverse;
}

.card-body {
    padding: 25px;
}

/* RTL 卡片主体文本右对齐 */
[dir="rtl"] .card-body {
    text-align: right;
}

.card-footer {
    padding: 15px 25px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

/* ==================== 表格 ==================== */
.table {
    margin-bottom: 0;
    white-space: nowrap;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    color: #666;
    font-size: 14px;
    border-bottom: 2px solid #eee;
    padding: 15px;
    white-space: nowrap;
    text-align: left;
}

/* RTL 表格表头右对齐 */
[dir="rtl"] .table thead th {
    text-align: right;
}

.table tbody td {
    padding: 15px;
    vertical-align: middle;
    white-space: nowrap;
    text-align: left;
}

/* RTL 表格单元格右对齐 */
[dir="rtl"] .table tbody td {
    text-align: right;
}

.table tbody tr:hover {
    background: #fafafa;
}

.table-responsive {
    overflow-x: auto;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #ff8a5c);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
    transform: translateY(-2px);
}

.btn-outline-secondary {
    background: #fff;
    border: 1px solid #ddd;
    color: #666;
}

.btn-outline-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: #fff;
}

.btn-outline-danger {
    border: 1px solid #dc3545;
    color: #dc3545;
}

.btn-outline-danger:hover {
    background: #dc3545;
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* RTL 按钮组顺序保留，但 gap 自动适配 */
/* ==================== 表单 ==================== */
.form-label {
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
    display: block;
}

/* RTL 表单标签右对齐 */
[dir="rtl"] .form-label {
    text-align: right;
}

.form-control,
.form-select {
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    width: 100%;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.search-form {
    display: flex;
    gap: 15px;
}

/* RTL 搜索表单方向不变 */
[dir="rtl"] .search-form {
    flex-direction: row;
}

.search-form .input-group {
    width: 300px;
}

.status-select {
    width: 150px;
}

/* ==================== 上传区域 ==================== */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(255, 107, 53, 0.02);
}

.upload-placeholder {
    color: #999;
}

.upload-placeholder i {
    font-size: 48px;
    margin-bottom: 15px;
    color: #ddd;
}

.upload-placeholder p {
    font-size: 16px;
    margin-bottom: 8px;
    color: #666;
}

.upload-placeholder span {
    font-size: 12px;
}

.upload-preview {
    position: relative;
    width: 100%;
    max-width: 200px;
}

.upload-preview img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.upload-preview .btn-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* RTL 上传预览删除按钮位置 */
[dir="rtl"] .upload-preview .btn-remove {
    right: auto;
    left: -10px;
}

/* ==================== 分页 ==================== */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.pagination {
    display: flex;
    gap: 8px;
}

/* RTL 分页顺序反转（从右向左排列页码） */
[dir="rtl"] .pagination {
    flex-direction: row-reverse;
}

.pagination .page-link {
    color: #666;
    border: 1px solid #ddd;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.pagination .page-link:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination .page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    color: #ddd;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* RTL 空状态保持居中 */
[dir="rtl"] .empty-state {
    text-align: center;
}

/* ==================== 徽章 ==================== */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.bg-success {
    background: #28a745 !important;
}

.bg-danger {
    background: #dc3545 !important;
}

.bg-secondary {
    background: #6c757d !important;
}

/* ==================== 警告框 ==================== */
.alert {
    border-radius: var(--border-radius);
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* RTL 警告框内容右对齐 */
[dir="rtl"] .alert {
    text-align: right;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ==================== 表单操作区 ==================== */
.form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 15px;
}

/* RTL 表单操作区方向不变，但内容右对齐 */
[dir="rtl"] .form-actions {
    justify-content: flex-start;
}

/* ==================== SweetAlert 移动端响应式 ==================== */
@media screen and (max-width: 768px) {
    .swal2-modal {
        width: 90% !important;
        max-width: 320px !important;
    }

    .swal2-title {
        font-size: 1.2rem !important;
        padding: 15px 15px 0 !important;
    }

    .swal2-content {
        font-size: 0.9rem !important;
        padding: 10px 15px !important;
    }

    .swal2-actions {
        padding: 15px !important;
        gap: 10px !important;
    }

    .swal2-confirm,
    .swal2-cancel {
        font-size: 0.9rem !important;
        padding: 8px 16px !important;
    }
}

/* RTL SweetAlert 文字对齐 */
[dir="rtl"] .swal2-title,
[dir="rtl"] .swal2-content,
[dir="rtl"] .swal2-html-container {
    text-align: right;
}
