/* 后台管理系统样式 - 优化版 */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --sidebar-width: 250px;
    --navbar-height: 60px;
    --border-radius: 0.5rem;
    --transition-speed: 0.3s;
}

/* ==================== 基础样式重置 ==================== */
* {
    box-sizing: border-box;
}

body {
    font-size: 0.875rem;
    background-color: #f8f9fa;
    line-height: 1.5;
}

.feather {
    width: 16px;
    height: 16px;
    vertical-align: text-bottom;
}

/* ==================== 导航栏样式 ==================== */
.admin-navbar {
    min-height: var(--navbar-height);
    height: var(--navbar-height);
    z-index: 1030;
    overflow: visible !important;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-navbar .navbar-brand {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background-color: rgba(0, 0, 0, 0.1);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);
    min-width: var(--sidebar-width);
    white-space: nowrap;
    height: 100%;
    display: flex;
    align-items: center;
    margin: 0;
    transition: background-color var(--transition-speed) ease;
}

.admin-navbar .navbar-brand:hover {
    background-color: rgba(0, 0, 0, 0.15);
}

.admin-navbar .navbar-brand img {
    height: 40px;
    object-fit: contain;
}

.admin-navbar .navbar-nav {
    height: 100%;
    display: flex;
    align-items: center;
    margin: 0;
}

.admin-navbar .dropdown {
    position: static;
    height: 100%;
    display: flex;
    align-items: center;
}

.admin-navbar .nav-link.dropdown-toggle {
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 1rem !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.85) !important;
    transition: all var(--transition-speed) ease;
}

.admin-navbar .nav-link.dropdown-toggle:hover,
.admin-navbar .nav-link.dropdown-toggle:focus {
    color: #fff !important;
    background-color: rgba(255, 255, 255, 0.15);
}

.admin-navbar .dropdown-menu {
    position: absolute !important;
    top: 100% !important;
    right: 0 !important;
    left: auto !important;
    margin-top: 0 !important;
    transform: translateY(10px) scale(0.95);
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    min-width: 200px;
}

.admin-navbar .dropdown-menu.show {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.dropdown-item {
    padding: 0.625rem 1rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

/* ==================== 搜索区域样式 ==================== */
.admin-navbar .search-container {
    flex: 1;
    max-width: 400px;
    margin: 0 1rem;
}

.admin-navbar .form-control {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 2rem;
    transition: all var(--transition-speed) ease;
}

.form-control-dark {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.form-control-dark:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ==================== 搜索下拉菜单统一样式 ==================== */
.search-dropdown-container {
    position: relative;
}

.search-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 0.25rem;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-results-list {
    padding: 0.5rem 0;
    margin: 0;
    list-style: none;
}

.search-result-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    color: #212529;
    text-decoration: none;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item:focus {
    background-color: #f8f9fa;
    color: #16181b;
    text-decoration: none;
}

.search-result-item:active {
    background-color: #e9ecef;
}

/* ==================== 侧边栏样式 ==================== */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    bottom: 0;
    left: 0;
    z-index: 100;
    width: var(--sidebar-width);
    padding: 48px 0 0;
    background-color: #fff;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-speed) ease;
}

.sidebar-sticky {
    position: relative;
    top: 0;
    height: calc(100vh - var(--navbar-height) - 48px);
    padding-top: 0.5rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar .nav-link {
    font-weight: 500;
    color: #495057;
    padding: 0.75rem 1rem;
    border-left: 3px solid transparent;
    transition: all var(--transition-speed) ease;
    margin: 0.125rem 0.5rem;
    border-radius: 0.375rem;
}

.sidebar .nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.08);
    border-left-color: var(--primary-color);
    transform: translateX(5px);
}

.sidebar .nav-link.active {
    color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c757d;
    padding: 1rem 1.5rem 0.5rem;
    font-weight: 600;
}

/* ==================== 主要内容区域 ==================== */
main {
    padding-top: 1rem;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-speed) ease;
}

/* ==================== 卡片样式 ==================== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
    transition: all var(--transition-speed) ease;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 2rem 0 rgba(58, 59, 69, 0.15);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.border-left-primary { border-left: 0.25rem solid var(--primary-color) !important; }
.border-left-success { border-left: 0.25rem solid var(--success-color) !important; }
.border-left-info { border-left: 0.25rem solid var(--info-color) !important; }
.border-left-warning { border-left: 0.25rem solid var(--warning-color) !important; }

/* ==================== 表格样式 ==================== */
.table {
    margin-bottom: 0;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
}

.table-responsive {
    border-radius: var(--border-radius);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* ==================== 按钮样式 ==================== */
.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* ==================== 表单样式 ==================== */
.form-control {
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    transform: translateY(-1px);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

.is-invalid {
    border-color: var(--danger-color) !important;
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--danger-color);
}

/* ==================== 文件上传样式 ==================== */
.file-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition-speed) ease;
    background-color: #f8f9fa;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.03);
}

.file-upload-area.dragover {
    border-color: var(--success-color);
    background-color: rgba(25, 135, 84, 0.05);
    transform: scale(1.02);
}

.img-preview {
    max-width: 200px;
    max-height: 200px;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 0.25rem;
    background-color: #fff;
    object-fit: cover;
}

/* ==================== 加载和动画 ==================== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-border {
    animation: spin 0.75s linear infinite;
    display: inline-block;
}

/* ==================== UEditor全屏模式 ==================== */
body.edui-editor-fullscreen {
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.edui-editor-fullscreen .navbar,
body.edui-editor-fullscreen .sidebar,
body.edui-editor-fullscreen .container-fluid,
body.edui-editor-fullscreen .row,
body.edui-editor-fullscreen main,
body.edui-editor-fullscreen .d-flex.justify-content-between,
body.edui-editor-fullscreen .border-bottom,
body.edui-editor-fullscreen .btn-toolbar,
body.edui-editor-fullscreen .row.mb-4,
body.edui-editor-fullscreen .alert,
body.edui-editor-fullscreen .card:not(.edui-default) {
    display: none !important;
}

body.edui-editor-fullscreen #edui1 {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 10000 !important;
    background: white;
}

/* ==================== 工具类和辅助样式 ==================== */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0a58ca 100%);
}

.badge {
    font-size: 0.7em;
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* ==================== 移动端适配 ==================== */
@media (max-width: 767.98px) {
    :root {
        --navbar-height: 50px;
    }

    .admin-navbar {
        min-height: var(--navbar-height);
        height: var(--navbar-height);
    }

    .admin-navbar .navbar-brand {
        min-width: auto;
        padding: 0.5rem 0.75rem;
    }

    .admin-navbar .navbar-brand img {
        height: 30px;
    }

    .admin-navbar .navbar-brand span {
        font-size: 0.9rem;
    }

    .admin-navbar .search-container {
        display: none !important;
    }

    .admin-navbar .dropdown-menu {
        position: fixed !important;
        top: var(--navbar-height) !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        border-radius: 0;
    }

    .sidebar {
        top: var(--navbar-height);
        transform: translateX(-100%);
        z-index: 1020;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-sticky {
        height: calc(100vh - var(--navbar-height));
    }

    main {
        margin-left: 0;
        padding-top: 0.5rem;
    }

    .search-dropdown-menu {
        position: fixed;
        top: var(--navbar-height) !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
        z-index: 1060;
    }
}

/* ==================== 大屏幕适配 ==================== */
@media (min-width: 1200px) {
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .navbar, .sidebar, .btn {
        display: none !important;
    }

    main {
        margin-left: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}