:root {
    --primary-color: #059669;
    --primary-hover: #047857;
    --danger-color: #EF4444;
    --danger-hover: #DC2626;
    --bg-color: #F8FAFC;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: rgba(203, 213, 225, 0.6);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(160, 100%, 94%, 1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, hsla(160, 100%, 94%, 0.8) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
}

.dashboard-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.sidebar-header {
    padding: 0 24px 20px;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.5px;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.divider {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.1);
    margin: 10px 12px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.2px;
}

.nav-btn:hover {
    background: rgba(5, 150, 105, 0.05);
    color: var(--primary-color);
    border-left: 3px solid rgba(5, 150, 105, 0.5);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
    border-left: 3px solid var(--primary-hover);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.topbar {
    height: 72px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}

.topbar h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #F1F5F9;
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: var(--shadow-sm);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile span {
    font-weight: 500;
    font-size: 0.9rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10B981, #047857);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
}

.content-wrapper {
    padding: 24px 32px;
    flex: 1;
    position: relative;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
.data-table th {
    padding: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 2px solid rgba(0,0,0,0.05);
}
.data-table td {
    padding: 16px;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.data-table tbody tr {
    transition: background-color 0.2s ease;
}
.data-table tbody tr:hover {
    background-color: rgba(5, 150, 105, 0.04);
}
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #E0E7FF;
    color: #3730A3;
    display: inline-block;
}

/* Chats Layout */
.chat-layout {
    display: flex;
    gap: 24px;
    height: calc(100vh - 160px);
}
.chat-list-card {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    padding: 0;
}
.chat-list-card h3 {
    padding: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.contact-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}
.contact-item {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
}
.contact-item:hover, .contact-item.active {
    background: rgba(255, 255, 255, 0.6);
}
.chat-detail-card {
    flex: 3;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
}
.chat-detail-card h3 {
    padding: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    background: rgba(255,255,255,0.4);
}
.messages-container {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}
.msg-assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid rgba(0,0,0,0.05);
    border-bottom-left-radius: 4px;
}
.msg-user {
    align-self: flex-end;
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}
.msg-time {
    display: block;
    font-size: 0.7rem;
    margin-top: 6px;
    opacity: 0.7;
    text-align: right;
}

/* Chat Input Area (Test AI) */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid rgba(0,0,0,0.05);
    background: rgba(255,255,255,0.3);
}
#test-ai-form {
    display: flex;
    gap: 12px;
}
#test-ai-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid rgba(0,0,0,0.1);
    outline: none;
    font-size: 0.95rem;
}
#test-ai-input:focus {
    border-color: var(--primary-color);
}

/* Grids & Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}
.product-card {
    background: rgba(255,255,255,0.5);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.6);
    position: relative;
}
.product-card-actions {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
}
.product-meta {
    display: flex;
    gap: 12px;
    margin: 12px 0;
}
.meta-tag {
    font-size: 0.8rem;
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
}

/* FAQ container */
.faq-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.faq-item {
    background: rgba(255,255,255,0.5);
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.4);
    display: flex;
    justify-content: space-between;
}
.faq-content h4 {
    margin-bottom: 8px;
}
.faq-actions {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.form-control {
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    background: rgba(255,255,255,0.8);
}
.form-control:focus {
    border-color: var(--primary-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 32px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* Status & Summary Cards */
.summary-cards {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 8px;
}
.summary-card {
    flex: 1;
    min-width: 150px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.summary-card::after {
    content: '';
    position: absolute;
    right: -10px;
    bottom: -10px;
    width: 80px;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.05;
    z-index: 0;
}
.summary-card > * {
    position: relative;
    z-index: 1;
}
.summary-card h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.summary-card .count {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}
.status-select {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(0,0,0,0.1);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 10px top 50%;
    background-size: 10px auto;
    padding-right: 30px;
}
/* Status Updates */
.status-Baru { color: #2563EB; background: #DBEAFE; border-color: #BFDBFE; }
.status-FollowUp { color: #D97706; background: #FEF3C7; border-color: #FDE68A; }
.status-PenawaranDikirim { color: #7C3AED; background: #EDE9FE; border-color: #DDD6FE; }
.status-Closing { color: #059669; background: #D1FAE5; border-color: #A7F3D0; }
.status-TidakJadi { color: #DC2626; background: #FEE2E2; border-color: #FECACA; }

/* Typing Indicator Animation */
@keyframes pulse-typing {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
#typing-indicator .content {
    animation: pulse-typing 1.5s infinite;
}

/* Timeline Activity Panel */
.timeline-item {
    position: relative;
    padding-left: 24px;
    margin-bottom: 20px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: -26px;
    width: 2px;
    background: var(--border-color);
}
.timeline-item:last-child::before {
    display: none;
}
.timeline-dot {
    position: absolute;
    left: 0;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 0 3px var(--card-bg);
}
.timeline-content {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.4;
}
.timeline-time {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Premium Side Drawer for Lead Details */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    justify-content: flex-end;
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.drawer-overlay.active {
    display: flex;
    opacity: 1;
}
.drawer-content {
    width: 100%;
    max-width: 520px;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 25px -5px rgba(0, 0, 0, 0.08), -4px 0 10px -5px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-overlay.active .drawer-content {
    transform: translateX(0);
}
.drawer-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.drawer-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}
.drawer-close {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.drawer-close:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
}
.drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Detail Elements inside Drawer */
.detail-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
    margin-bottom: 12px;
}
.lead-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
}
.lead-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lead-info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.lead-info-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Note Workspace and Note items */
.note-input-container {
    background: rgba(255, 255, 255, 0.45);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.notes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}
.note-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
}
.note-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: rgba(5, 150, 105, 0.25);
}
.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.note-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.note-meta strong {
    color: var(--text-main);
}
.note-actions {
    display: flex;
    gap: 8px;
}
.note-action-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.15s ease;
}
.note-action-btn:hover {
    color: var(--primary-color);
}
.note-action-btn.delete:hover {
    color: var(--danger-color);
}
.note-text {
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    color: var(--text-main);
}

/* Stylized Vertical Lead Activity Timeline */
.lead-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    padding-left: 20px;
}
.lead-timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-color);
}
.timeline-event {
    position: relative;
}
.timeline-event-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
}
.timeline-event.lead_created .timeline-event-dot {
    background: var(--primary-color);
}
.timeline-event.status_changed .timeline-event-dot {
    background: #7C3AED;
}
.timeline-event.note_added .timeline-event-dot {
    background: #D97706;
}
.timeline-event.note_edited .timeline-event-dot {
    background: #2563EB;
}
.timeline-event.note_deleted .timeline-event-dot {
    background: var(--danger-color);
}
.timeline-event-content {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-main);
}
.timeline-event-time {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Interactive Cursor for Leads Rows */
#leads-tbody tr {
    cursor: pointer;
}
#leads-tbody tr select.status-select {
    cursor: default; /* Keep default cursor for select elements inside table rows */
}

