/* Customer Browser Component Styles */

.customers-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 24px;
    gap: 20px;
    font-family: 'Open Sans', sans-serif;
}

/* Header */
.customers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.customers-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary, #333);
}

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

/* Tabs */
.customers-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color, #e0e0e0);
}

.customers-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary, #888);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.customers-tab:hover {
    color: var(--text-primary, #333);
}

.customers-tab.active {
    color: var(--primary-purple, #8B7EC8);
    border-bottom-color: var(--primary-purple, #8B7EC8);
}

.customers-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary-purple, #8B7EC8);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Search bar */
.customers-search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    padding: 8px 14px;
    gap: 8px;
    flex: 1;
    max-width: 360px;
    transition: border-color 0.2s;
}

.customers-search-bar:focus-within {
    border-color: var(--primary-purple, #8B7EC8);
    box-shadow: 0 0 0 2px rgba(139, 126, 200, 0.15);
}

.customers-search-bar input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    flex: 1;
    color: var(--text-primary, #333);
}

.customers-search-icon {
    color: var(--text-secondary, #888);
    font-size: 1rem;
}

/* Add customer button */
.customers-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary-purple, #8B7EC8);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.customers-add-btn:hover {
    background: #7a6cb8;
    transform: translateY(-1px);
}

.customers-capture-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-purple, #8B7EC8), var(--primary-green, #7FB069));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    white-space: nowrap;
}

.customers-capture-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Stats row */
.customers-stats {
    display: flex;
    gap: 16px;
    color: var(--text-secondary, #888);
    font-size: 0.8rem;
}

.customers-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Table */
.customers-table-wrapper {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 10px;
    overflow: hidden;
}

.customers-table {
    width: 100%;
    border-collapse: collapse;
}

.customers-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary, #888);
    background: var(--bg-secondary, #f8f9fa);
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    user-select: none;
    cursor: pointer;
}

.customers-table thead th:hover {
    color: var(--primary-purple, #8B7EC8);
}

.customers-table tbody tr {
    border-bottom: 1px solid var(--border-light, #f0f0f0);
    transition: background 0.15s;
    cursor: pointer;
}

.customers-table tbody tr:hover {
    background: var(--bg-hover, #f5f3ff);
}

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

.customers-table td {
    padding: 12px 16px;
    font-size: 0.9rem;
    color: var(--text-primary, #333);
    vertical-align: middle;
}

.customers-table td.empty-cell {
    color: var(--text-tertiary, #bbb);
    font-style: italic;
}

.customer-name-cell {
    font-weight: 500;
}

/* Status badge */
.customer-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.customer-status-badge.prospect { background: #e8f0fe; color: #1a73e8; }
.customer-status-badge.active { background: #e6f4ea; color: #1e8e3e; }
.customer-status-badge.lead { background: #fef3e0; color: #e37400; }
.customer-status-badge.inactive { background: #f0f0f0; color: #888; }

/* Inline edit panel */
.customer-edit-row td {
    padding: 0;
}

.customer-edit-panel {
    padding: 16px 20px;
    background: var(--bg-secondary, #f8f9fa);
    border-top: 1px solid var(--border-color, #e0e0e0);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.customer-edit-panel .field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.customer-edit-panel .field-group.full-width {
    grid-column: 1 / -1;
}

.customer-edit-panel label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary, #888);
}

.customer-edit-panel input,
.customer-edit-panel textarea {
    padding: 8px 10px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
    font-family: inherit;
}

.customer-edit-panel input:focus,
.customer-edit-panel textarea:focus {
    outline: none;
    border-color: var(--primary-purple, #8B7EC8);
    box-shadow: 0 0 0 2px rgba(139, 126, 200, 0.15);
}

.customer-edit-panel textarea {
    resize: vertical;
    min-height: 60px;
}

.customer-edit-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

.customer-edit-actions button {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.btn-save {
    background: var(--primary-purple, #8B7EC8);
    color: #fff;
}

.btn-save:hover { background: #7a6cb8; }

.btn-cancel {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e0e0e0) !important;
    color: var(--text-primary, #333);
}

.btn-cancel:hover { background: var(--bg-hover, #f5f3ff); }

.btn-delete {
    background: transparent;
    color: #d93025;
    margin-right: auto;
}

.btn-delete:hover { background: #fce8e6; }

.btn-export-email {
    background: transparent;
    color: var(--primary-purple, #8B7EC8);
    border: 1px solid var(--primary-purple, #8B7EC8) !important;
}

.btn-export-email:hover:not(:disabled) { background: rgba(139, 126, 200, 0.08); }
.btn-export-email:disabled { opacity: 0.4; cursor: not-allowed; }

/* Activity timeline */
.customer-activity-timeline {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.customer-activity-timeline label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary, #888);
}

.activity-timeline-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.82rem;
    color: var(--text-primary, #333);
}

.activity-icon {
    flex-shrink: 0;
    font-size: 0.9rem;
}

.activity-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-date {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
}

.activity-empty, .activity-loading {
    font-size: 0.82rem;
    color: var(--text-tertiary, #bbb);
    font-style: italic;
}

/* AI Chat panel */
.customers-ai-panel {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 10px;
    overflow: hidden;
}

.customers-ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.08), rgba(127, 176, 105, 0.08));
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.customers-ai-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.customers-ai-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-secondary, #888);
    padding: 4px;
}

.customers-ai-messages {
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-msg {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 85%;
}

.ai-msg.user {
    background: var(--primary-purple, #8B7EC8);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-msg.assistant {
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #333);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.customers-ai-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color, #e0e0e0);
}

.customers-ai-input-area input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
}

.customers-ai-input-area input:focus {
    outline: none;
    border-color: var(--primary-purple, #8B7EC8);
}

.customers-ai-send-btn {
    padding: 8px 16px;
    background: var(--primary-purple, #8B7EC8);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
}

.customers-ai-send-btn:hover { background: #7a6cb8; }
.customers-ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Empty state */
.customers-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary, #888);
}

.customers-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.customers-empty h3 {
    margin: 0 0 8px;
    color: var(--text-primary, #333);
    font-size: 1.1rem;
}

.customers-empty p {
    margin: 0 0 20px;
    font-size: 0.9rem;
}

/* Loading spinner */
.customers-loading {
    display: flex;
    justify-content: center;
    padding: 32px;
}

.customers-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e0e0e0);
    border-top-color: var(--primary-purple, #8B7EC8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 640px) {
    .customers-container { padding: 16px; }
    .customers-header { flex-direction: column; align-items: stretch; }
    .customers-search-bar { max-width: none; }
    .customer-edit-panel { grid-template-columns: 1fr; }
    .customers-table td:nth-child(4),
    .customers-table th:nth-child(4) { display: none; }
}
