/* ============================================
   广告批量搭建系统 - 主题样式
   ============================================ */

:root {
    --bg-page: #f5f6fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1f2937;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-sidebar: #d1d5db;
    --text-sidebar-active: #ffffff;
    --border: #e5e7eb;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}
.logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid #374151;
    margin-bottom: 20px;
}
.logo h2 { color: white; font-size: 20px; margin-bottom: 8px; }
.mode-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--info);
    color: white;
}
.mode-tag.mode-mock { background: var(--warning); }
.mode-tag.mode-real { background: var(--success); }
.sidebar nav { display: flex; flex-direction: column; }
.nav-item {
    display: block;
    padding: 12px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: #374151;
    color: var(--text-sidebar-active);
}
.nav-item.active {
    background: #374151;
    color: white;
    border-left-color: var(--primary);
}

/* ===== Content ===== */
.content {
    margin-left: 220px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    background: var(--bg-card);
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: 20px; font-weight: 600; }
.page-body { padding: 32px; flex: 1; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
}
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }

/* ===== Buttons ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-secondary { background: #e5e7eb; color: var(--text-primary); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== Tables ===== */
.table {
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.table th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
}
.table tr:hover td { background: #f9fafb; }
.table img { max-width: 60px; max-height: 60px; border-radius: 4px; object-fit: cover; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge.pending_review { background: #fef3c7; color: #92400e; }
.badge.approved { background: #d1fae5; color: #065f46; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.published { background: #dbeafe; color: #1e40af; }
.badge.failed { background: #fecaca; color: #7f1d1d; }
.badge.active { background: #d1fae5; color: #065f46; }
.badge.paused { background: #fef3c7; color: #92400e; }
.badge.disabled { background: #f3f4f6; color: #6b7280; }
.badge.image { background: #ddd6fe; color: #5b21b6; }
.badge.video { background: #fce7f3; color: #9f1239; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ===== Material Grid ===== */
.material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.material-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.15s;
}
.material-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.material-card .thumb {
    width: 100%;
    height: 120px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.material-card .thumb img, .material-card .thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.material-card .info { padding: 8px 12px; font-size: 12px; }
.material-card .name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.material-card .meta { color: var(--text-secondary); margin-top: 4px; }

/* ===== Filter Tabs ===== */
.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    width: fit-content;
}
.filter-tab {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.15s;
}
.filter-tab:hover { background: #f3f4f6; color: var(--text-primary); }
.filter-tab.active { background: var(--primary); color: white; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-backdrop.show { display: flex; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-footer { margin-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Toast ===== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}
.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--info);
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    margin-bottom: 8px;
    min-width: 200px;
    animation: slideIn 0.3s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    text-align: center;
}
.sidebar {
    position: relative;
}
