/* ===========================
   Retell AI Calls - Styles
   =========================== */

/* ===========================
   Call Pages Layout
   =========================== */

.retell-call-layout {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.retell-call-layout .left-panel {
    flex: 0 0 400px;
}

.retell-call-layout .right-panel {
    flex: 1;
    min-width: 0;
}

/* ===========================
   Call Control Panel
   =========================== */

.call-control-panel {
    background: var(--surface-color);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Mode Selector */
.call-mode-selector {
    display: flex;
    background: var(--bg-color);
    border-radius: 0.75rem;
    padding: 0.25rem;
    gap: 0.25rem;
}

.mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--surface-color);
    color: var(--primary-color);
    box-shadow: var(--shadow);
}

/* Agent Selector */
.agent-selector-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agent-selector-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.agent-selector {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 2.5rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.agent-selector:focus {
    outline: none;
    border-color: var(--aurora-bright-blue);
    box-shadow: 0 0 0 3px rgba(15, 158, 213, 0.2);
}

/* Phone Dialer */
.phone-dialer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.phone-dialer-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.phone-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1.125rem;
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    color: var(--text-primary);
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.phone-input:focus {
    outline: none;
    border-color: var(--aurora-bright-blue);
    box-shadow: 0 0 0 3px rgba(15, 158, 213, 0.2);
}

.phone-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Call Controls */
.call-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 0;
}

.call-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.call-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.call-btn.start-btn {
    background: linear-gradient(135deg, var(--aurora-green) 0%, #147a1f 100%);
    color: white;
}

.call-btn.start-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.call-btn.end-btn {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
    color: white;
}

.call-btn.end-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.call-btn.mute-btn {
    background: var(--bg-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.call-btn.mute-btn:hover:not(:disabled) {
    background: var(--border-color);
}

.call-btn.mute-btn.muted {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}

/* Call Status Indicator */
.call-status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-radius: 2rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.call-status-indicator.idle .status-dot {
    background: var(--text-secondary);
}

.call-status-indicator.connecting .status-dot {
    background: #f59e0b;
    animation: pulse-dot 1s infinite;
}

.call-status-indicator.active .status-dot {
    background: var(--aurora-green);
    animation: pulse-dot 1.5s infinite;
}

.call-status-indicator.ended .status-dot {
    background: var(--danger-color);
}

.call-timer {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ===========================
   Transcript Panel
   =========================== */

.transcript-panel {
    background: var(--surface-color);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 400px;
    max-height: calc(100vh - 250px);
}

.transcript-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.transcript-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.transcript-clear-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.transcript-clear-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.transcript-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.transcript-content::-webkit-scrollbar {
    width: 8px;
}

.transcript-content::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.transcript-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.transcript-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.transcript-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Transcript Messages */
.transcript-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
    animation: messageAppear 0.3s ease-out;
}

.transcript-message.user {
    flex-direction: row-reverse;
}

.transcript-message.agent {
    flex-direction: row;
}

.transcript-speaker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.transcript-message.user .transcript-speaker {
    background: linear-gradient(135deg, var(--aurora-navy) 0%, var(--aurora-blue) 100%);
    color: white;
}

.transcript-message.agent .transcript-speaker {
    background: linear-gradient(135deg, var(--aurora-orange) 0%, #d96229 100%);
    color: white;
}

.transcript-text {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
}

.transcript-message.user .transcript-text {
    background: var(--aurora-navy);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.transcript-message.agent .transcript-text {
    background: var(--aurora-gray);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

/* Agent Speaking Indicator */
.agent-speaking-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-color);
    border-radius: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.speaking-dots {
    display: flex;
    gap: 4px;
}

.speaking-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.speaking-dots span:nth-child(1) { animation-delay: -0.32s; }
.speaking-dots span:nth-child(2) { animation-delay: -0.16s; }
.speaking-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* ===========================
   Inbound Calls Monitor
   =========================== */

.inbound-monitor {
    background: var(--surface-color);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.inbound-monitor h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inbound-phone-number {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

.inbound-phone-number .phone-icon {
    font-size: 1.25rem;
}

.inbound-phone-number .phone-number {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.inbound-phone-number .phone-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.monitor-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--aurora-navy);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.monitor-btn:hover {
    background: var(--aurora-blue);
}

.monitor-btn.active {
    background: var(--aurora-green);
}

.monitor-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Active Calls List */
.active-calls-list {
    margin-top: 1rem;
}

.active-call-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    animation: slideIn 0.3s ease-out;
}

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

.active-call-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.active-call-icon {
    font-size: 1.25rem;
}

.active-call-number {
    font-family: monospace;
    font-weight: 500;
}

.active-call-duration {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.active-call-actions button {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.active-call-actions button:hover {
    background: var(--border-color);
}

/* ===========================
   Responsive
   =========================== */

@media (max-width: 1024px) {
    .retell-call-layout {
        flex-direction: column;
    }

    .retell-call-layout .left-panel {
        flex: none;
        width: 100%;
    }

    .transcript-panel {
        min-height: 300px;
        max-height: 400px;
    }
}

@media (max-width: 640px) {
    .call-control-panel {
        padding: 1rem;
    }

    .call-btn {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    .transcript-message .transcript-text {
        max-width: 85%;
    }
}

/* ===========================
   Call Summary Panel
   =========================== */

.call-summary-panel {
    margin-top: 1rem;
    background: var(--surface-color);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

.call-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--aurora-navy) 0%, var(--aurora-blue) 100%);
    cursor: pointer;
    transition: background 0.2s;
}

.call-summary-header:hover {
    background: linear-gradient(135deg, var(--aurora-blue) 0%, var(--aurora-bright-blue) 100%);
}

.call-summary-header h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.call-summary-toggle-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.25rem;
    transition: transform 0.2s;
}

.call-summary-panel.collapsed .call-summary-toggle-btn {
    transform: rotate(-90deg);
}

.call-summary-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.call-summary-panel.collapsed .call-summary-content {
    display: none;
}

/* Summary Stats Row */
.summary-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.75rem;
    text-align: center;
}

.summary-stat .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

.summary-stat .stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Summary Section */
.summary-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-section h5 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.summary-text {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.75rem;
    border-left: 3px solid var(--aurora-bright-blue);
    margin: 0;
}

/* Latency Section */
.latency-section {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.latency-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.latency-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
    text-align: center;
}

.latency-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.latency-value {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--aurora-green);
}

/* Loading States */
.loading-dots {
    display: inline-block;
    animation: loadingPulse 1.5s ease-in-out infinite;
    color: var(--text-secondary);
}

.loading-indicator {
    display: inline-block;
    color: var(--text-secondary);
    font-style: italic;
}

.loading-indicator::after {
    content: '';
    animation: loadingEllipsis 1.5s steps(4, end) infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

@keyframes loadingEllipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Responsive for Call Summary */
@media (max-width: 640px) {
    .summary-stats-row {
        grid-template-columns: 1fr;
    }

    .latency-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .call-summary-content {
        padding: 1rem;
    }
}
