@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --green: #10b981;
    --green-glow: rgba(16, 185, 129, 0.3);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.3);
    --yellow: #f59e0b;
    --user-bubble: rgba(99, 102, 241, 0.15);
    --agent-bubble: rgba(16, 185, 129, 0.12);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* Background gradient animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.header-title h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-title p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.status-badge.disconnected {
    color: var(--text-muted);
}

.status-badge.connected {
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

.status-badge.speaking {
    color: var(--accent);
    border-color: var(--border-active);
    background: rgba(99, 102, 241, 0.08);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.status-badge.connected .status-dot {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse-green 2s infinite;
}

.status-badge.speaking .status-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    animation: pulse-accent 1s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-accent {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* Company Selector */
.company-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.company-selector label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.company-selector select {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.company-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

.company-selector select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Transcript Area */
.transcript-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
    scroll-behavior: smooth;
}

.transcript-area::-webkit-scrollbar {
    width: 6px;
}

.transcript-area::-webkit-scrollbar-track {
    background: transparent;
}

.transcript-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.transcript-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.transcript-empty .icon {
    font-size: 48px;
    opacity: 0.4;
}

.transcript-empty p {
    font-size: 14px;
    line-height: 1.6;
}

.transcript-message {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.transcript-message.user {
    align-items: flex-end;
}

.transcript-message.agent {
    align-items: flex-start;
}

.transcript-message .label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    padding: 0 8px;
}

.transcript-message.user .label {
    color: var(--accent);
}

.transcript-message.agent .label {
    color: var(--green);
}

.transcript-message .bubble {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
}

.transcript-message.user .bubble {
    background: var(--user-bubble);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-bottom-right-radius: 4px;
}

.transcript-message.agent .bubble {
    background: var(--agent-bubble);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-bottom-left-radius: 4px;
}

.transcript-message.system {
    align-items: center;
}

.transcript-message.system .bubble {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--yellow);
    font-size: 12px;
    border-radius: 8px;
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.btn-mic {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.btn-mic:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.05);
}

.btn-mic.active {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 30px var(--accent-glow);
    animation: mic-glow 2s ease-in-out infinite;
}

.btn-mic.active:hover {
    transform: scale(1.05);
}

@keyframes mic-glow {
    0%, 100% { box-shadow: 0 4px 30px var(--accent-glow); }
    50% { box-shadow: 0 4px 50px rgba(99, 102, 241, 0.5); }
}

/* Mic ripple when active */
.btn-mic.active::before,
.btn-mic.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent);
    transform: translate(-50%, -50%);
    animation: ripple 2s ease-out infinite;
}

.btn-mic.active::after {
    animation-delay: 1s;
}

@keyframes ripple {
    0% { width: 100%; height: 100%; opacity: 0.6; }
    100% { width: 160%; height: 160%; opacity: 0; }
}

.btn-end {
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-end:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.btn-end:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Audio Visualizer */
.visualizer {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 36px;
}

.visualizer .bar {
    width: 4px;
    height: 8px;
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.1s ease;
}

.visualizer.active .bar {
    animation: visualize 0.5s ease-in-out infinite alternate;
}

.visualizer.active .bar:nth-child(1) { animation-delay: 0.0s; }
.visualizer.active .bar:nth-child(2) { animation-delay: 0.1s; }
.visualizer.active .bar:nth-child(3) { animation-delay: 0.2s; }
.visualizer.active .bar:nth-child(4) { animation-delay: 0.3s; }
.visualizer.active .bar:nth-child(5) { animation-delay: 0.15s; }
.visualizer.active .bar:nth-child(6) { animation-delay: 0.05s; }
.visualizer.active .bar:nth-child(7) { animation-delay: 0.25s; }

@keyframes visualize {
    from { height: 6px; }
    to { height: 32px; }
}

/* Call info bar */
.call-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.call-timer {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.call-timer.active {
    color: var(--green);
}

/* Responsive */
@media (max-width: 600px) {
    .app {
        padding: 12px 16px;
    }

    .header-title h1 {
        font-size: 15px;
    }

    .transcript-message .bubble {
        max-width: 90%;
    }
}

/* Admin Styles */
.admin-app { max-width: 1000px; }
.admin-panel {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    backdrop-filter: blur(12px);
}
.kb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.kb-table th {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}
.kb-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: top;
}
.badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}
.actions-col { width: 80px; text-align: right; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.btn-icon:hover { opacity: 1; }
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}
.btn-primary:hover {
    background: #4f46e5;
}
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
}
.admin-actions { justify-content: space-between; }
.text-center { text-align: center; color: var(--text-muted); }

/* Modal */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.modal.visible { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 12px;
    width: 100%; max-width: 500px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content h2 { margin-bottom: 20px; font-size: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.form-group input, .form-group textarea {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-family: inherit;
}
.form-group input[readonly] { opacity: 0.5; cursor: not-allowed; }
.form-group input:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
}
.modal-actions {
    display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px;
}

/* Admin Specific */
.admin-tabs { display:flex; gap:10px; padding:20px 20px 0 20px; }
.prompt-panel { padding: 20px; background: white; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.prompt-panel h2 { margin-bottom:15px; font-size:1.2rem; color: #333; }
.prompt-panel p { margin-bottom:15px; color:#666; font-size:0.9rem; }
.prompt-panel textarea { width:100%; height:400px; padding:15px; font-family:monospace; border:1px solid #ddd; border-radius:6px; margin-bottom:15px; resize:vertical; }
