:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f4f5fb;
    --card: #ffffff;
    --text: #1e1b2e;
    --muted: #6b7280;
    --danger: #dc2626;
    --success: #16a34a;
    --border: #e5e7eb;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------- Auth (login) ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.auth-card {
    background: var(--card);
    padding: 40px;
    border-radius: var(--radius);
    width: 340px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    text-align: center;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.auth-card form { text-align: left; }
.auth-card label { font-size: 13px; font-weight: 600; margin-top: 12px; display: block; }
.auth-card input {
    width: 100%; padding: 10px; margin-top: 6px;
    border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 16px; text-align: center; }
.alert { padding: 10px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: 10px 18px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; margin-top: 18px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #eef0fb; color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 10px; font-size: 12px; margin-right: 6px; }

/* ---------- Admin dashboard ---------- */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--card); padding: 16px 32px; box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.container { max-width: 1100px; margin: 30px auto; padding: 0 20px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.search-bar { margin-bottom: 16px; }
.search-bar input {
    width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px;
}

.data-table {
    width: 100%; border-collapse: collapse; background: var(--card);
    border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.data-table th, .data-table td {
    padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top;
}
.data-table th { background: #f9fafb; font-weight: 700; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-active { background: #dcfce7; color: var(--success); }
.badge-inactive { background: #f3f4f6; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
    background: var(--card); border-radius: var(--radius); padding: 26px; width: 420px; max-width: 90vw;
}
.modal h3 { margin-top: 0; }
.modal label { font-size: 13px; font-weight: 600; display: block; margin-top: 12px; }
.modal input, .modal textarea, .modal select {
    width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; font-size: 14px; font-family: inherit;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Voice Agent frontend ---------- */
.agent-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.agent-wrap {
    background: var(--card); border-radius: 20px; padding: 36px; width: 420px; max-width: 92vw;
    text-align: center; box-shadow: 0 24px 50px rgba(0,0,0,0.25);
}
.agent-wrap h1 { margin: 0 0 4px; }
.agent-wrap .sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }

.mic-zone { margin-bottom: 20px; }
.mic-btn {
    width: 84px; height: 84px; border-radius: 50%; border: none; font-size: 34px;
    background: var(--primary); color: #fff; cursor: pointer; transition: 0.2s;
    box-shadow: 0 8px 20px rgba(79,70,229,0.4);
}
.mic-btn:hover { background: var(--primary-dark); }
.mic-active { animation: pulse 1.2s infinite; background: var(--danger); }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
    70% { box-shadow: 0 0 0 18px rgba(220,38,38,0); }
    100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

.text-fallback { display: flex; gap: 8px; margin-bottom: 18px; }
.text-fallback input {
    flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px;
}

.chat-box {
    text-align: left; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}
.chat-msg { padding: 10px 14px; border-radius: 14px; font-size: 14px; max-width: 85%; line-height: 1.4; }
.chat-user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-bot { background: #f1f2f9; color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; }
/* ---------- Upgraded Animations & Pure CSS Icons ---------- */

.hidden {
    display: none !important;
}

/* Pure CSS Microphone Icon (Replacing Emoji) */
.mic-icon {
    width: 16px; 
    height: 24px;
    border-radius: 8px;
    background: #ffffff;
    position: relative;
    margin: 0 auto;
}
.mic-icon::after {
    content: ''; 
    position: absolute;
    width: 24px; 
    height: 16px;
    border-bottom: 3px solid #ffffff;
    border-left: 3px solid #ffffff; 
    border-right: 3px solid #ffffff;
    border-radius: 0 0 12px 12px;
    top: 10px; 
    left: -7px;
}

/* Writing / Typing Animation */
.typing-indicator {
    display: flex; 
    gap: 4px; 
    padding: 10px 14px;
    background: #f1f2f9; 
    border-radius: 14px;
    width: fit-content; 
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}
.typing-indicator span {
    width: 8px; 
    height: 8px; 
    background: var(--primary);
    border-radius: 50%; 
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Speaking Visualizer Animation */
.visualizer {
    display: flex; 
    justify-content: center; 
    gap: 6px;
    margin: 0 auto 20px; 
    height: 40px; 
    align-items: flex-end;
}
.visualizer .bar {
    width: 8px; 
    background: var(--primary);
    border-radius: 4px; 
    animation: speakBar 0.5s infinite alternate ease-in-out;
}
.visualizer .bar:nth-child(1) { animation-delay: 0.0s; height: 15px; }
.visualizer .bar:nth-child(2) { animation-delay: 0.2s; height: 35px; }
.visualizer .bar:nth-child(3) { animation-delay: 0.1s; height: 20px; }
.visualizer .bar:nth-child(4) { animation-delay: 0.3s; height: 30px; }

@keyframes speakBar {
    0% { height: 10px; }
    100% { height: 40px; }
}
