/* 后台管理全局样式 - 提取自 layouts/header.php */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    min-height: 100vh;
    display: flex;
}

/* 侧边栏 */
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
}

.sidebar-logo-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    overflow: hidden;
}
.sidebar-logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-menu {
    list-style: none;
    padding: 0 12px;
}

/* 侧边栏主体滚动区 */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.sidebar-body::-webkit-scrollbar {
    width: 4px;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.sidebar-menu-item {
    margin-bottom: 4px;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 14px;
}

.sidebar-menu-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-menu-link.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.sidebar-menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-section {
    padding: 20px 24px 8px;
    font-size: 12px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    margin-bottom: 12px;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

/* 主内容区 */
.main {
    flex: 1;
    margin-left: 240px;
    padding: 0;
    min-width: 0;
}

.topbar {
    background: white;
    padding: 16px 32px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.topbar-btn {
    padding: 8px 16px;
    background: #f5f7fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #666;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.topbar-btn:hover {
    background: #e8eaed;
}

.content {
    padding: 32px;
    max-width: 100%;
    overflow-x: hidden;
}

/* 表格容器 - 允许横向滚动 */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 文本溢出处理 */
.card,
.stat-card,
.form-group {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* 长文本截断 */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.page-desc {
    color: #666;
    font-size: 14px;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

th {
    font-weight: 600;
    color: #666;
    background: #fafafa;
}

tbody tr:hover {
    background: #f9f9f9;
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: white;
    border: 1px solid #d0d0d0;
    color: #666;
}

.btn-outline:hover {
    background: #f5f5f5;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* 提示框 */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination-link {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: white;
    color: #666;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.pagination-link:hover,
.pagination-link.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-info {
    color: #999;
    font-size: 13px;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 200;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-menu-link span:not(.sidebar-menu-icon),
    .sidebar-logo span:last-child,
    .sidebar-user-info,
    .sidebar-section {
        display: block;
    }
    .main {
        margin-left: 0;
    }
    .content {
        padding: 16px;
    }
    .topbar {
        padding: 12px 16px;
    }
    .topbar-title {
        font-size: 16px;
    }
    .card {
        padding: 16px;
    }
    table {
        font-size: 12px;
    }
    th, td {
        padding: 10px 12px;
    }
    .mobile-menu-btn {
        display: flex !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 150;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

/* 移动端汉堡按钮 */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f5f7fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 12px;
}
.mobile-menu-btn:hover {
    background: #e8eaed;
}
.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
    stroke: #666;
}

/* 访客模式样式 */
.guest-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 12px;
    font-size: 12px;
    text-align: center;
}
.guest-badge a {
    color: #2563eb;
    margin-left: 8px;
    text-decoration: underline;
}
.admin-badge {
    background: #d1fae5;
    color: #065f46;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 12px;
    font-size: 12px;
    text-align: center;
}

/* 访客模式的操作按钮禁用 */
body.guest-mode .btn-danger,
body.guest-mode .btn-warning {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}
body.guest-mode .btn-danger:hover::after,
body.guest-mode .btn-warning:hover::after {
    content: '🔒 访客无权操作';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
}

/* 访客模式提示横幅 */
.guest-notice {
    background: #fef3c7;
    color: #92400e;
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    border-bottom: 1px solid #fde68a;
}
.guest-notice a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: underline;
}
