/* TASTE Voice Bot Styles */

:root {
  --color-user: #2196f3;
  --color-agent: #9c27b0;
  --color-success: #28a745;
  --color-error: #dc3545;
  --color-inactive: #666;
}

/* Base Styles */
* {
    font-family: 'JetBrains Mono', 'Roboto Mono', 'Consolas', 'Monaco', monospace;
}

body {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px;
    background-color: #000000;
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    width: 100%;
    height: 90vh;
    height: 90dvh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header h1 {
    margin: 0;
}

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

/* Buttons */
.header-controls button {
    width: 140px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 17px;
    color: white;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes connect-breathe {
    0%, 100% {
        background-color: #888;
        box-shadow: 0 0 6px rgba(136, 136, 136, 0.3);
    }
    50% {
        background-color: #28a745;
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.8);
    }
}

#connection-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background-color: #888;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: connect-breathe 2s ease-in-out infinite;
    user-select: none;
    -webkit-user-select: none;
}

#connection-btn:hover {
    background-color: #666;
}

#connection-btn.connected {
    background-color: #28a745;
    color: white;
    box-shadow: 0 0 16px rgba(40, 167, 69, 0.6);
    animation: none;
}

#connection-btn.connected:hover {
    background-color: #218838;
}

#start-conversation-btn {
    background-color: var(--color-success);
}

#start-conversation-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Status */
.status {
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
    background-color: #e9ecef;
}

/* Echo Warning */
.echo-warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-size: 1.0rem;
    padding: 8px 12px;
    text-align: center;
    margin-bottom: 8px;
}

/* Transcript Container */
.transcript-container {
    border: 1px solid #ddd;
    border-radius: 5px;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 15px;
    background-color: #fafafa;
}

/* Messages */
.message {
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
}

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

.user-message {
    justify-content: flex-end;
}

.agent-message {
    justify-content: flex-start;
}

.system-message {
    justify-content: center;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background-color: var(--color-user);
}

.agent-message .message-avatar {
    background-color: var(--color-agent);
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 18px;
    position: relative;
}

.user-message .message-bubble {
    background-color: #e3f2fd;
    border-bottom-right-radius: 4px;
}

.agent-message .message-bubble {
    background-color: #f3e5f5;
    border-bottom-left-radius: 4px;
}

.system-message .message-bubble {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    max-width: 90%;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 17px;
    color: #333;
}

.timestamp {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
}

.user-message .timestamp {
    text-align: right;
}

.agent-message .timestamp {
    text-align: left;
}

/* Waveform Section */
.waveform-section {
    margin: 8px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.waveform-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 6px 10px;
    background-color: #fafafa;
    text-align: center;
    min-width: 0;
}

.waveform-container.disabled {
    cursor: default;
}

.waveform-container h4 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 17px;
}

.canvas-wrapper {
    position: relative;
}

.waveform-container canvas {
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #000;
    width: 100%;
    max-width: 100%;
    height: 60px;
    display: block;
}

.waveform-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 17px;
    color: var(--color-inactive);
    pointer-events: none;
}

/* Session Timer */
.session-timer {
    font-size: 17px;
    color: var(--color-success);
    font-weight: 600;
    min-width: 3.5em;
    text-align: center;
}

.session-timer.warning {
    color: var(--color-error);
}

/* Push-to-Talk Section */
.ptt-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 8px;
    gap: 8px;
}

.ptt-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

#ptt-btn {
    flex: 1;
    height: 72px;
    border-radius: 14px;
    border: none;
    background-color: var(--color-success);
    color: white;
    font-size: 17px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#ptt-btn:not(:disabled):active,
#ptt-btn.recording {
    background-color: #1e7e34;
    transform: scale(0.96);
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.7);
}

#ptt-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

@keyframes ptt-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.5); }
    50%       { box-shadow: 0 0 0 12px rgba(40, 167, 69, 0); }
}

#ptt-btn.keep-locked {
    background-color: #1e7e34;
    transform: scale(0.96);
    transition: background-color 0.15s, transform 0.15s;
    animation: ptt-pulse 1.4s ease-in-out infinite;
}

.ptt-status {
    font-size: 17px;
    color: #555;
    margin-bottom: 12px;
    min-height: 1.4em;
    text-align: center;
}

/* Keep Listening checkbox row */
.keep-listen-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.keep-listen-row input[type="checkbox"] {
    display: none;
}

.keep-listen-box {
    width: 14px;
    height: 14px;
    border: 2px solid #aaa;
    border-radius: 4px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.keep-listen-row input[type="checkbox"]:checked + .keep-listen-box {
    background: var(--color-user);
    border-color: var(--color-user);
}

.keep-listen-row input[type="checkbox"]:checked + .keep-listen-box::after {
    content: '✓';
    color: white;
    font-size: 13px;
    line-height: 1;
}

.keep-listen-row input[type="checkbox"]:disabled + .keep-listen-box {
    border-color: #ddd;
    background: #f5f5f5;
}

.keep-listen-label {
    font-size: 13px;
    color: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .header-controls button {
        flex: 1;
        min-width: 80px;
    }

    .transcript-container {
        flex: 1 1 0;
        min-height: 100px;
        max-height: 60vh;
    }

    .message-bubble {
        max-width: 85%;
    }

    .message-text {
        font-size: 15px;
    }

    .waveform-container h4 {
        font-size: 15px;
    }

    .waveform-status {
        font-size: 15px;
    }

    #ptt-btn {
        font-size: 15px;
    }

    .keep-listen-label {
        font-size: 12px;
    }

    .keep-listen-box {
        width: 12px;
        height: 12px;
    }

    .keep-listen-row input[type="checkbox"]:checked + .keep-listen-box::after {
        font-size: 12px;
    }
}
