/* ============================================================
   佰视佳AI营销工作台 - 全局样式
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    color: #333;
    background: #f5f6fa;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: #667eea; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 240px;
    background: #1a1a2e;
    color: #fff;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 16px; font-weight: 700; }
.sidebar-close {
    display: none;
    background: none; border: none; color: #fff;
    font-size: 24px; cursor: pointer;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
}
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 12px; color: rgba(255,255,255,0.6); }

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-section { margin-bottom: 4px; }
.nav-title {
    padding: 10px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(102,126,234,0.2); color: #fff; border-left-color: #667eea; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 8px; }
.nav-logout { color: rgba(255,255,255,0.5) !important; }
.nav-logout:hover { color: #ff6b6b !important; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }

/* Main Content */
.main-content {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-menu-btn { display: none; background: none; border: none; cursor: pointer; padding: 4px; }
.menu-icon { display: block; width: 22px; height: 2px; background: #333; position: relative; }
.menu-icon::before, .menu-icon::after { content: ''; display: block; width: 22px; height: 2px; background: #333; position: absolute; }
.menu-icon::before { top: -7px; } .menu-icon::after { top: 7px; }
.topbar-title { font-size: 16px; font-weight: 700; color: #1a1a2e; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 13px; color: #666; }
.topbar-logout-btn { background: none; border: none; font-size: 18px; cursor: pointer; }

.page-content { flex: 1; padding: 24px; max-width: 1400px; }

/* Cards */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 16px;
}
.card h4 { font-size: 15px; color: #1a1a2e; margin: 0 0 14px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
}
.btn:hover { background: #f5f5f5; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border: none; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,0.4); background: linear-gradient(135deg, #667eea, #764ba2); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-success { background: #4caf50; color: #fff; border: none; }
.btn-success:hover { background: #43a047; }
.btn-warning { background: #ff9800; color: #fff; border: none; }
.btn-danger { background: #f44336; color: #fff; border: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 5px; }
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}
.form-input:focus { border-color: #667eea; outline: none; }
textarea.form-input { resize: vertical; }
select.form-input { appearance: none; background: #fff url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23999'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e") no-repeat right 10px center; background-size: 16px; padding-right: 32px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Tables */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: #f8f9fc;
    color: #666;
    font-weight: 600;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.data-table tr:hover td { background: #fafbff; }
.empty-cell { text-align: center; color: #bbb; padding: 40px !important; }
.time-cell { color: #999; font-size: 12px; white-space: nowrap; }
.content-link { color: #333; font-weight: 500; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-gray { background: #f5f5f5; color: #757575; }
.badge-yellow { background: #fff3e0; color: #e65100; }
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-blue { background: #e3f2fd; color: #1565c0; }
.badge-red { background: #ffebee; color: #c62828; }
.badge-purple { background: #f3e5f5; color: #6a1b9a; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    text-decoration: none;
    transition: all 0.15s;
}
.page-btn:hover { background: #f0f0f0; text-decoration: none; }
.page-btn.active { background: #667eea; color: #fff; border-color: #667eea; }
.page-info { font-size: 12px; color: #999; margin-left: 12px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    color: #fff;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    max-width: 400px;
}
.toast-success { background: #4caf50; }
.toast-error { background: #f44336; }
.toast-info { background: #2196f3; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Dashboard */
.welcome-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 28px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.welcome-text h2 { font-size: 22px; margin: 0 0 4px; }
.welcome-text p { margin: 0; opacity: 0.85; font-size: 14px; }
.welcome-date { font-size: 28px; opacity: 0.5; }

.section { margin-bottom: 24px; }
.section-title { font-size: 16px; color: #1a1a2e; margin: 0 0 12px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quick-action-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.quick-action-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(102,126,234,0.15); text-decoration: none; }
.qa-icon { font-size: 32px; }
.qa-title { font-weight: 700; font-size: 14px; }
.qa-desc { font-size: 12px; color: #999; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.tool-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
    color: #333;
    position: relative;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(102,126,234,0.12); text-decoration: none; }
.tool-card-icon { font-size: 28px; margin-bottom: 6px; }
.tool-card-name { font-size: 13px; font-weight: 600; }
.tool-card-badge {
    position: absolute; top: 8px; right: 8px;
    background: #f44336; color: #fff;
    font-size: 11px; padding: 1px 8px;
    border-radius: 10px; font-weight: 700;
}

/* Tool Pages */
.tool-page { max-width: 1200px; }
.tool-header { margin-bottom: 20px; }
.tool-header h2 { font-size: 22px; color: #1a1a2e; margin: 0 0 4px; }
.tool-header p { color: #888; margin: 0; font-size: 14px; }
.tool-layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.tool-layout-single { max-width: 900px; }
.tool-input {}
.tool-output { min-height: 400px; }
.tool-output-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tool-output-header h4 { margin: 0; }
.tool-output-actions { display: flex; gap: 6px; }

.output-placeholder { text-align: center; padding: 60px 20px; color: #bbb; }
.output-placeholder .placeholder-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.output-placeholder p { margin: 0; font-size: 15px; }
.output-placeholder .placeholder-hint { font-size: 13px; color: #ccc; margin-top: 4px; }
.output-content { line-height: 1.8; font-size: 14px; }
.output-loading { text-align: center; padding: 60px 20px; }
.output-error { color: #d32f2f; padding: 40px; text-align: center; }
.token-info { margin-top: 12px; padding: 8px 12px; background: #f5f5f5; border-radius: 8px; font-size: 12px; color: #999; }

.spinner {
    width: 36px; height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal.show { display: block; }
.modal-card { background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #999; }
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999; }
.modal-overlay.show { display: block; }

/* Script tag */
.script-tag { color: #667eea; font-weight: 700; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid #e8e8e8; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    border: none;
    background: none;
    font-family: inherit;
}
.tab:hover { color: #667eea; }
.tab.active { color: #667eea; border-bottom-color: #667eea; }

/* Stats cards */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); text-align: center; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-card .stat-label { font-size: 12px; color: #999; margin-top: 4px; }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 4px; }

/* Search/Filter bar */
.filter-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Back link */
.back-link { color: #667eea; text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 4px; }
.back-link:hover { text-decoration: underline; }

/* Info grid (detail pages) */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-item { display: flex; flex-direction: column; }
.info-item.full { grid-column: 1 / -1; }
.info-label { font-size: 12px; color: #999; margin-bottom: 2px; }
.quick-actions-sm { display: flex; gap: 8px; flex-wrap: wrap; }

/* Alert card */
.alert-card { border-left: 4px solid #ff9800; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }
