/* ===== Root Variables ===== */
:root {
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --c-bg: #f4f6fb;
    --c-surface: #ffffff;
    --c-sidebar: #1a1d29;
    --c-sidebar-hover: #272b3a;
    --c-sidebar-active: #363b4e;
    --c-primary: #6366f1;
    --c-primary-soft: rgba(99, 102, 241, .1);
    --c-success: #22c55e;
    --c-warning: #f59e0b;
    --c-danger: #ef4444;
    --c-text: #1e293b;
    --c-text-secondary: #64748b;
    --c-border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
    --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--c-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 24px 20px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
}
.sidebar-brand i { font-size: 24px; color: var(--c-primary); }

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .15s ease;
}
.sidebar-link:hover {
    background: var(--c-sidebar-hover);
    color: rgba(255,255,255,.9);
}
.sidebar-link.active {
    background: var(--c-sidebar-active);
    color: #fff;
}
.sidebar-link i { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
}

/* ===== Top Bar ===== */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    background: rgba(244,246,251,.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 32px;
    border-bottom: 1px solid var(--c-border);
    z-index: 100;
}
.topbar-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -.3px;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.sidebar-toggle { color: var(--c-text); padding: 4px; }

/* ===== Page Content ===== */
.page-content { padding: 28px 32px 48px; max-width: 1280px; }

/* ===== Cards ===== */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--c-border);
    padding: 18px 24px;
    font-weight: 600;
    font-size: 15px;
}
.card-body { padding: 24px; }

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}
.stat-icon.purple { background: var(--c-primary-soft); color: var(--c-primary); }
.stat-icon.green  { background: rgba(34,197,94,.1); color: var(--c-success); }
.stat-icon.amber  { background: rgba(245,158,11,.1); color: var(--c-warning); }
.stat-icon.red    { background: rgba(239,68,68,.1); color: var(--c-danger); }
.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -.5px;
    line-height: 1.1;
    margin-bottom: 4px;
}
.stat-label {
    font-size: 13px;
    color: var(--c-text-secondary);
    font-weight: 500;
}

/* ===== Status Dot ===== */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.online  { background: var(--c-success); box-shadow: 0 0 6px rgba(34,197,94,.4); }
.status-dot.offline { background: var(--c-danger); }

/* ===== Tables ===== */
.table { font-size: 13.5px; margin: 0; }
.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--c-text-secondary);
    border-bottom: 1px solid var(--c-border);
    padding: 12px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}
.table tbody tr:hover { background: #f8fafc; }

/* ===== Badges ===== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-status.success { background: rgba(34,197,94,.1); color: #16a34a; }
.badge-status.failed  { background: rgba(239,68,68,.1); color: #dc2626; }
.badge-status.pending  { background: rgba(245,158,11,.1); color: #d97706; }
.badge-status.skipped  { background: rgba(100,116,139,.1); color: #64748b; }

/* ===== Buttons ===== */
.btn-primary {
    background: var(--c-primary);
    border-color: var(--c-primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    padding: 8px 20px;
}
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }

.btn-outline-secondary {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13.5px;
}

/* ===== Toggle Switch ===== */
.form-switch .form-check-input {
    width: 44px;
    height: 24px;
    cursor: pointer;
}
.form-switch .form-check-input:checked {
    background-color: var(--c-primary);
    border-color: var(--c-primary);
}

/* ===== Forms ===== */
.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--c-text);
    margin-bottom: 6px;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--c-border);
    font-size: 14px;
    padding: 10px 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.form-text { font-size: 12.5px; color: var(--c-text-secondary); }

textarea.form-control { min-height: 100px; }

/* ===== Platform Badge ===== */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.platform-badge.ig { background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.platform-badge.fb { background: #1877f2; color: #fff; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--c-text-secondary);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h5 { font-weight: 600; color: var(--c-text); margin-bottom: 8px; }

/* ===== Keywords Tag ===== */
.keyword-tag {
    display: inline-block;
    background: var(--c-primary-soft);
    color: var(--c-primary);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin: 2px;
}

/* ===== Modal ===== */
.modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    border-bottom: 1px solid var(--c-border);
    padding: 20px 24px;
}
.modal-header .modal-title { font-weight: 700; font-size: 17px; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--c-border); padding: 16px 24px; }

/* ===== Alert ===== */
.alert { border-radius: var(--radius-sm); font-size: 14px; }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.2);
    }
    .main-content { margin-left: 0; }
    .page-content { padding: 20px 16px 40px; }
    .topbar { padding: 0 16px; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== Utility ===== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gap-20 { gap: 20px; }
