/* Basic structure and layout */
.livekit-agent-container {
    position: relative;
    width: 100%;
    min-height: 370px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Inter", Sans-serif;
}

.livekit-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
    text-align: center;
    padding: 20px 0;
}

.livekit-state.hidden {
    opacity: 0;
    pointer-events: none;
}

.livekit-wrapper {
    max-width: 629px;
    margin-bottom: 24px;
    padding: 0 10px;
}

@media screen and (max-width: 960px) {
    .livekit-wrapper {
        max-width: 292px;
    }
}

/* Back button styling */
.livekit-back-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: 102px;
    height: 40px;
    padding: 2px;
    border-radius: 99px;
    background: var(--back-btn-outer-bg, rgba(255, 255, 255, 0.1));
    box-shadow: var(--back-btn-outer-shadow, 0px 4px 6px -2px rgba(0, 0, 0, 0.03));
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.livekit-back-btn:hover .back-inner {
    background: var(--back-btn-inner-hover, rgba(255, 255, 255, 0.15));
}

.livekit-back-btn:active .back-inner {
    background: var(--back-btn-inner-pressed, rgba(255, 255, 255, 0.05));
}

.livekit-back-btn:disabled .back-inner {
    background: var(--back-btn-inner-disabled, rgba(255, 255, 255, 0.05));
}

.back-inner {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 98px;
    height: 36px;
    padding: 10px 14px;
    background: var(--back-btn-inner-rest, rgba(255, 255, 255, 0.1));
    border-radius: 99px;
    transition: background-color 0.2s ease;
}

.back-icon {
    width: 24px;
    height: 24px;
    font-size: 18px;
    line-height: 24px;
}

.back-text {
    width: 38px;
    height: 24px;
    font-weight: 500;
    font-size: 16px;
    line-height: 24px;
    color: #0D0F2C;
}

/* Typography */
.livekit-title {
    color: #0D0F2C;
    font-weight: 600;
    font-size: 32px;
    line-height: 38px;
    letter-spacing: -0.32px;
    margin: auto auto 8px auto;
}

.livekit-subtitle {
    font-weight: 400;
    font-size: 14px;
    line-height: 18px;
    letter-spacing: 0;
    color: #333B52;
    margin: 0;
}

@media screen and (max-width: 960px) {
    .livekit-title {
        max-width: 218px;
        font-size: 22px !important;
        line-height: 26px;
        letter-spacing: -0.22px;
    }
}

.livekit-preset-agents-wrapper {
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
    padding: 0 20px;
}

/* Preset agents styling */
.livekit-preset-agents {
    display: flex;
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.20);
    backdrop-filter: blur(20px);
    width: fit-content;
}

.livekit-custom-agent-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 99px;
    transition: all 0.3s ease;
    height: 36px;
    gap: 8px;
}

.livekit-custom-agent-badge:focus,
.livekit-custom-agent-badge:hover {
    border-color: #547FFF;
    background: #FFF;
    box-shadow: 0px 4px 12px rgba(31, 78, 218, 0.15);
}

.livekit-agent-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    height: 36px;
}

.livekit-agent-badge.selected {
    border: 1px solid #547FFF;
    background: #FFF;
    box-shadow: 0 6px 7px 0 rgba(0, 43, 173, 0.07);
}

.livekit-agent-badge.selected .agent-name {
    color: #1F4EDA;
}

.livekit-agent-badge:focus,
.livekit-agent-badge:hover {
    border-color: #547FFF;
    background: #FFF;
    box-shadow: 0px 4px 12px rgba(31, 78, 218, 0.15);
}

.agent-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-bottom: 8px;
}

.agent-name {
    font-weight: 500;
    font-size: 14px;
    line-height: 18px;
    color: #333B52;
}

/* In-call interface */
.livekit-in-call {
    position: relative;
    z-index: 1;
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.livekit-incall-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Audio marble animation */
.livekit-audio-marble {
    position: relative;
    width: 150px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Persona information */
.livekit-persona {
    width: 136px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.persona-name {
    width: 100%;
    font-weight: 500;
    font-size: 18px;
    line-height: 24px;
    letter-spacing: 0;
    text-align: center;
    color: #0d0f2c;
}

.persona-timer {
    font-weight: 400;
    font-size: 14px;
    line-height: 18px;
    letter-spacing: 0;
    text-align: center;
    color: rgba(51, 59, 82, 1);
}

/* Call buttons */
.livekit-call-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 8px;
}

.livekit-hangup-btn {
    background: linear-gradient(138deg,#0040ff 15.18%,#547fff 91.01%),linear-gradient(0deg,#fff,#fff),radial-gradient(80.17% 50.73% at 48.51% 51.95%,#0040ff 0%,#547fff 100%),linear-gradient(90deg,#547fff,#1f4eda);
    border-radius: 99px;
    box-shadow: 0 0 8px 4px #99b3ff;
    height: 56px;
    width: 56px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.livekit-hangup-btn:hover {
    background: linear-gradient(138deg,#0034cf 15.18%,#4c73e6 91.01%),#fff;
}

.livekit-hangup-btn .hangup-icon {
    width: 18px;
    height: 18px;
}

.livekit-controls {
    margin-top: 24px;
    padding: 4px;
    border-radius: 99px;
    background: linear-gradient(136deg, rgba(190, 207, 255, 0.90) 14.61%, rgba(255, 255, 255, 0.90) 83.91%), #FFF;
    box-shadow: 0 4px 16px 0 rgba(2, 57, 223, 0.10);
}

.livekit-share-close {
    width: 100%;
    font-size: 14px !important;
}

.livekit-retry-btn {
    width: 157px;
    height: 52px;
    font-size: 16px !important;
}

/* Primary buttons */
.livekit-primary-btn,
.livekit-toggle-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 48px;
    gap: 8px;
    color: white;
    border: none;
    border-radius: 99px;
    padding: 10px 20px;
    font-weight: 500;
    font-size: 18px;
    line-height: 24px;
    transition: all 0.3s ease;
    background: linear-gradient(138deg, #0040FF 15.18%, #547FFF 91.01%), linear-gradient(0deg, #FFF 0%, #FFF 100%), radial-gradient(80.17% 50.73% at 48.51% 51.95%, #0040FF 0%, #547FFF 100%), linear-gradient(90deg, #547FFF 0%, #1F4EDA 100%);
    box-shadow: 0 0 8px 4px #99B3FF;
}

@media screen and (max-width: 960px) {
    .livekit-primary-btn,
    .livekit-toggle-btn {
        height: auto;
        font-size: 16px;
    }
}

.livekit-primary-btn:hover,
.livekit-toggle-btn:hover {
    background: linear-gradient(138deg,#0034cf 15.18%,#4c73e6 91.01%), #fff;
}

.livekit-primary-btn:disabled,
.livekit-toggle-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.livekit-primary-btn:disabled:hover,
.livekit-toggle-btn:disabled:hover {
    transform: none;
    background: linear-gradient(138deg, #0040FF 15.18%, #547FFF 91.01%), linear-gradient(0deg, #FFF 0%, #FFF 100%), radial-gradient(80.17% 50.73% at 48.51% 51.95%, #0040FF 0%, #547FFF 100%), linear-gradient(90deg, #547FFF 0%, #1F4EDA 100%);
}

/* Error state */
.livekit-error-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.livekit-back-to-selection {
    background: none !important;
    border: none;
    color: #333b52b3;
    font-size: 14px;
    line-height: 18px;
    text-decoration: underline;
    text-transform: uppercase;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s ease;
}

.livekit-back-to-selection:hover {
    color: #333b52;
    text-decoration: underline;
}

/* Share state */
.livekit-share-card {
    width: 100%;
    max-width: 363px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-radius: 24px;
    background-image:
        linear-gradient(0deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1)),
        linear-gradient(180deg, #F2F6FF 0%, #FFFFFF 92.63%);
    box-shadow: 0px 4px 6px -2px rgba(0, 0, 0, 0.03), 0px 12px 16px -4px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(100px);
    -webkit-backdrop-filter: blur(100px);
}

.share-text-block {
    width: 100%;
    max-width: 315px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.share-link-block {
    width: 100%;
    max-width: 315px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sharing-title {
    width: 100%;
    font-weight: 600;
    font-size: 36px !important;
    line-height: 44px;
    letter-spacing: -0.01em;
    text-align: center;
    margin: 0;
    background-image: linear-gradient(90deg, #547FFF 6.25%, #1F4EDA 59.13%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.share-subtitle {
    width: 100%;
    font-weight: 400;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
    color: rgba(51, 59, 82, 1);
    margin: 0;
}

.share-h6 {
    margin: 0;
    font-weight: 500;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
    color: rgba(51, 59, 82, 1);
}

.share-link-display {
    width: 100%;
    max-width: 315px;
    height: 44px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 0 16px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.05);

    background-clip: padding-box, border-box, border-box;
    background-image: linear-gradient(#fff, #fff), radial-gradient(94.87% 94.87% at 2.43% 14.29%, #1d55ff 0, #fff0), linear-gradient(0deg, #0000000d, #0000000d);
    background-origin: padding-box, border-box, border-box;
    border: 1px solid transparent;
}

.share-link-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #0D0F2C;
    font-size: 14px;
    line-height: 18px;
}

.copy-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent !important;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.copy-success {
    width: 20px;
    color: #10b981;
    font-weight: bold;
}

.copy-error {
    color: #ef4444;
    font-weight: bold;
}

/* Audio levels */
.livekit-audio-levels {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.level-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.level-container label {
    min-width: 60px;
    font-size: 14px;
    color: rgba(51, 59, 82, 1);
    font-weight: 500;
}

.level-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.level-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.1s ease;
}

.mic-level {
    background: linear-gradient(90deg, #10b981, #22c55e);
}

.assistant-level {
    background: linear-gradient(90deg, #3b82f6, #6366f1);
}

/* Dots animation */
@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

.dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

/* Error messages */
.livekit-error-message {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
}

.livekit-error {
    padding: 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #dc2626;
    text-align: center;
    font-weight: 500;
}

/* Status indicators */
.livekit-status {
    margin-top: 16px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.status-text {
    font-size: 14px;
    color: rgba(51, 59, 82, 1);
    font-weight: 500;
}

.waiting-permission {
    font-size: 14px;
    color: #f59e0b;
    font-weight: 500;
}

/* Mobile responsive adjustments */
@media (max-width: 960px) {
    .livekit-preset-agents {
        padding: 4px;
    }
}

@media (max-width: 1096px) {
    .livekit-share-card {
        max-width: 343px;
        padding: 24px;
        border-radius: 16px;
    }

    .share-text-block,
    .share-link-block {
        max-width: 295px;
    }

    .sharing-title {
        font-size: 26px;
        line-height: 32px;
    }

    .share-link-display {
        max-width: 295px;
    }
}

/* Custom CSS variables for easy theming */
:root {
    --livekit-primary-color: #1f4eda;
    --livekit-primary-light: #547fff;
    --livekit-background: rgba(255, 255, 255, 0.95);
    --livekit-text-primary: #0D0F2C;
    --livekit-text-secondary: rgba(51, 59, 82, 1);
    --livekit-text-muted: rgba(51, 59, 82, 0.7);
    --livekit-success: #10b981;
    --livekit-error: #ef4444;
    --livekit-warning: #f59e0b;
    
    --back-btn-outer-bg: linear-gradient(136.29deg,#becfff 14.61%,#e4eaff 83.91%),#fff;
    --back-btn-outer-shadow: 0px 4px 16px rgba(2,57,223,.1);
    --back-btn-inner-rest: linear-gradient(137.55deg,#d1ddff 15.18%,#fff 91.01%);
    --back-btn-inner-hover: #d9dade;
    --back-btn-inner-pressed: #cdced1;
    --back-btn-inner-disabled: rgba(230,231,235,.7);
}
