/* ===== Design Tokens ===== */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --bg-page: #f0f2f5;
    --bg-card: #ffffff;
    --bg-section: #f8f9fc;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --border-light: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* ===== Global Reset ===== */
* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ===== Navbar ===== */
.navbar {
    background: var(--primary-gradient) !important;
    border: none;
    box-shadow: var(--shadow-md);
    z-index: 1030;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ===== Page Header ===== */
.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    padding: 16px 0;
    position: sticky;
    top: 56px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.page-header h2 i {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Cards ===== */
.card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--bg-card);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: 20px;
}

/* ===== Customer Cards ===== */
.customer-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: none;
    box-shadow: var(--shadow-sm);
}

.customer-card .card-header {
    background: var(--bg-section);
    border-bottom: 1px solid var(--border-light);
    padding: 12px 16px;
}

.customer-card .card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.customer-card .card-body {
    padding: 16px;
}

.customer-card .card-footer {
    background: var(--bg-section);
    border-top: 1px solid var(--border-light);
    padding: 10px 16px;
}

.customer-card .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 500;
}

.customer-card .btn-group .btn {
    flex: 1;
    font-size: 0.82rem;
    padding: 6px 10px;
    border-radius: 6px;
}

#customer-cards-container {
    margin: 0 -6px;
}

#customer-cards-container > div {
    padding: 6px;
}

/* Add Customer Card */
.add-customer-card {
    border: 2px dashed var(--border-light);
    background: var(--bg-section);
    transition: all 0.3s ease;
    border-radius: var(--radius-md);
}

.add-customer-card:hover {
    border-color: var(--primary-color);
    background: #eef2ff;
    transform: translateY(-2px);
}

.add-customer-card .card-body {
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== Buttons ===== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b42a1 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.45);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #fc5c7d 0%, #e53e3e 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.3);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: #fff;
}

.btn-outline-info {
    color: #3182ce;
    border-color: #3182ce;
}

.btn-outline-info:hover {
    background: #3182ce;
    color: #fff;
}

.btn-secondary {
    background: var(--bg-section);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.btn-light {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.btn-light:hover {
    background: var(--bg-section);
}

/* ===== Modals ===== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    background: var(--primary-gradient);
    border: none;
    padding: 16px 24px;
}

.modal-header .modal-title {
    color: #fff;
    font-weight: 600;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-body {
    padding: 24px;
    background: var(--bg-card);
}

.modal-footer {
    background: var(--bg-section);
    border-top: 1px solid var(--border-light);
    padding: 16px 24px;
}

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    padding: 10px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

/* ===== Tables ===== */
.table {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table thead th {
    background: var(--bg-section);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-light);
    padding: 12px 16px;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.table tbody tr:hover {
    background: #f7f8fc;
}

/* ===== Alerts ===== */
.alert {
    border-radius: var(--radius-sm);
    border: none;
    padding: 14px 18px;
}

.alert-info {
    background: linear-gradient(135deg, #ebf4ff 0%, #e9d8fd 100%);
    color: #3182ce;
}

.alert-secondary {
    background: var(--bg-section);
    color: var(--text-secondary);
}

.alert-success {
    background: #f0fff4;
    color: #276749;
}

.alert-warning {
    background: #fffaf0;
    color: #975a16;
}

.alert-danger {
    background: #fff5f5;
    color: #c53030;
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
}

/* ===== Tabs ===== */
.nav-tabs {
    border-bottom: 2px solid var(--border-light);
}

.nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color);
    border-bottom-color: transparent;
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    background: transparent;
    border-bottom: 2px solid var(--primary-color);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay .spinner-border {
    color: var(--primary-color);
    width: 3rem;
    height: 3rem;
}

/* ===== Profile Content ===== */
.profile-content {
    max-height: 200px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.8;
}

/* ===== Login Page ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--primary-gradient);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    color: var(--text-primary);
    font-weight: 700;
}

/* ===== Section Headings ===== */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title i {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Feature List (Summary) ===== */
.feature-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.feature-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.feature-category {
    display: inline-block;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 10px;
    min-width: 60px;
    text-align: center;
}

/* ===== Tags ===== */
.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-section);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.tag:hover {
    border-color: var(--primary-color);
    background: #eef2ff;
    color: var(--primary-color);
}

.tag-primary {
    background: linear-gradient(135deg, #ebf4ff 0%, #e9d8fd 100%);
    color: var(--primary-color);
    border-color: transparent;
}

/* ===== Topic Detail Cards ===== */
.detail-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
    overflow: hidden;
}

.detail-card-header {
    background: var(--bg-section);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-card-header i {
    color: var(--primary-color);
}

.detail-card-body {
    padding: 16px;
}

/* ===== Chat Bubbles ===== */
.chat-bubble {
    max-width: 75%;
    padding: 10px 16px;
    border-radius: 16px;
    margin-bottom: 8px;
    line-height: 1.6;
    position: relative;
}

.chat-bubble-me {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-bubble-other {
    background: var(--bg-section);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .page-header {
        top: 56px;
    }
    
    .modal-dialog {
        margin: 8px;
    }
    
    .modal-xl {
        max-width: calc(100% - 16px);
    }
    
    .card-body {
        padding: 16px;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Animation ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.empty-state p {
    font-size: 1rem;
    margin: 0;
}
