/* ============================================================
   Auto Call System — 完整样式
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #0ea5e9;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f1f5f9;

    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: #e0f2fe;
    --primary-gradient: linear-gradient(135deg, #0ea5e9, #6366f1);

    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;
    --secondary: #64748b;
    --secondary-light: #f1f5f9;

    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-body: #1e293b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(0, 0, 0, 0.04);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
}

/* ---------- Base ---------- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    font-size: 0.925rem;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ---------- Layout: Sidebar + Main ---------- */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.25rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--sidebar-active);
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand small {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--sidebar-text);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 0.5rem 1rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0.25rem 0.75rem;
    margin: 0;
    flex: 1;
}

.sidebar-nav-item {
    margin-bottom: 2px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.sidebar-nav-link i {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
}

.sidebar-nav-link.active {
    color: var(--sidebar-text-active);
    background: rgba(14, 165, 233, 0.15);
}

.sidebar-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 3px;
    background: var(--sidebar-active);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--sidebar-text);
    font-size: 0.85rem;
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user .user-name {
    color: var(--sidebar-text-active);
    font-weight: 600;
    display: block;
    line-height: 1.2;
}

.sidebar-user .user-role {
    font-size: 0.75rem;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Top Navbar ---- */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1040;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.92);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-left .page-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar toggle button (mobile) */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-body);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

/* ---- Content Area ---- */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* ---- Footer ---- */
.footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   Sidebar Overlay (mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ---- Stat Cards (Dashboard) ---- */
.stat-card {
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
    border: none;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-footer {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.stat-card-primary {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
    color: #fff;
}

.stat-card-warning {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
}

.stat-card-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
}

.stat-card-info {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #fff;
}

/* ============================================================
   Tables
   ============================================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.table {
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-striped-bg: #f8fafc;
    --bs-table-hover-bg: #f0f9ff;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    color: var(--secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background var(--transition);
}

/* ============================================================
   Badges / Status
   ============================================================ */
.badge {
    font-weight: 500;
    padding: 0.3em 0.7em;
    border-radius: 20px;
    font-size: 0.78rem;
}

.badge.bg-warning {
    background: var(--warning-light) !important;
    color: #92400e;
}

.badge.bg-info {
    background: var(--info-light) !important;
    color: #0e7490;
}

.badge.bg-success {
    background: var(--success-light) !important;
    color: #065f46;
}

.badge.bg-danger {
    background: var(--danger-light) !important;
    color: #991b1b;
}

.badge.bg-secondary {
    background: var(--secondary-light) !important;
    color: #475569;
}

.badge.bg-light {
    background: #e2e8f0 !important;
    color: #475569;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    transition: all var(--transition);
    position: relative;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: #fff;
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: #fff;
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
    color: #fff;
}

.btn-info {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    border: none;
    color: #fff;
}

.btn-info:hover {
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
    color: #fff;
}

.btn-secondary {
    background: #e2e8f0;
    border: none;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
    color: #1e293b;
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}

.btn-sm i {
    font-size: 0.95rem;
}

/* ============================================================
   Forms
   ============================================================ */
.form-control,
.form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    transition: all var(--transition);
    background: var(--bg-card);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-body);
    margin-bottom: 0.35rem;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
}

.modal-header .modal-title {
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
}

.modal.fade .modal-dialog {
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s ease;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast-notification {
    pointer-events: auto;
    min-width: 320px;
    max-width: 420px;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    animation: toastIn 0.3s ease forwards;
    cursor: pointer;
}

.toast-notification i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-notification .toast-msg {
    flex: 1;
}

.toast-notification.toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast-notification.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast-notification.toast-info {
    background: linear-gradient(135deg, #0ea5e9, #6366f1);
}

.toast-notification.toast-warning {
    background: linear-gradient(135deg, #f59e0b, #f97316);
}

.toast-notification.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(14, 165, 233, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(99, 102, 241, 0.08) 0%, transparent 50%);
    animation: loginBgAnim 20s ease infinite;
}

@keyframes loginBgAnim {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(2%, -2%) rotate(1deg);
    }

    66% {
        transform: translate(-1%, 1%) rotate(-1deg);
    }
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: loginCardIn 0.6s ease;
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-card-header {
    padding: 2rem 2rem 0;
    text-align: center;
}

.login-card-header .logo-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--primary-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.3);
}

.login-card-header h3 {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-card-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-card-body {
    padding: 2rem;
}

.login-card-footer {
    padding: 0 2rem 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-btn {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    width: 100%;
    transition: all var(--transition);
}

.login-btn:hover {
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.4);
    transform: translateY(-2px);
    color: #fff;
}

/* ============================================================
   Alert Override (for flash messages)
   ============================================================ */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    animation: alertSlideIn 0.3s ease;
}

@keyframes alertSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-info {
    background: var(--info-light);
    color: #0e7490;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   Filter Panel (call_tasks)
   ============================================================ */
.filter-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   Quick actions card
   ============================================================ */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ============================================================
   Hover card for dashboard
   ============================================================ */
.dashboard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.dashboard-section-header h5 {
    font-weight: 600;
    margin: 0;
}

/* ============================================================
   Tooltip enhancements
   ============================================================ */
.tooltip-inner {
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
    }

    .topbar {
        padding: 0.6rem 1rem;
    }
}

@media (max-width: 575.98px) {
    .stat-card .stat-value {
        font-size: 1.6rem;
    }

    .table td,
    .table th {
        padding: 0.5rem 0.65rem;
        font-size: 0.85rem;
    }

    .content-area {
        padding: 0.75rem;
    }

    .toast-notification {
        min-width: unset;
        max-width: calc(100vw - 2rem);
        margin: 0 1rem;
    }

    .login-card {
        margin: 0.5rem;
    }
}

/* ============================================================
   Knowledge Base — Upload Zone / QA List
   ============================================================ */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--secondary-light);
}

.upload-zone:hover,
.upload-zone-active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone-icon {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.6;
    display: block;
    margin-bottom: 0.75rem;
}

.upload-zone-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-body);
    margin-bottom: 0.25rem;
}

.upload-zone-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* QA test result list */
#testResults .list-group-item {
    border-left: 3px solid var(--primary);
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
}

#testResults .list-group-item:hover {
    background: var(--primary-light);
}

/* QA table text truncation */
#qaTableBody td {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
