/* Design Tokens & Theme Variables */
:root {
    --bg-dark: #0f0812;
    --bg-deep: #160d1b;
    --primary: #ff4081;
    --primary-glow: rgba(255, 64, 129, 0.4);
    --primary-light: #ff8da1;
    --accent: #ec407a;
    --text-main: #fce4ec;
    --text-muted: #d8b8cc;
    --glass-bg: rgba(24, 12, 28, 0.6);
    --glass-border: rgba(255, 64, 129, 0.15);
    --glass-active: rgba(255, 64, 129, 0.25);
    --msg-user: linear-gradient(135deg, #ff4081, #d81b60);
    --msg-gf: rgba(255, 182, 193, 0.08);
    --danger: #e91e63;
    --success: #26a69a;
    --warning: #ffab40;
    --transition-speed: 0.3s;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-deep);
}

*::-webkit-scrollbar {
    width: 6px;
}
*::-webkit-scrollbar-track {
    background: var(--bg-deep);
}
*::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 20px;
}

body {
    background: radial-gradient(circle at 50% 50%, #200f28 0%, var(--bg-dark) 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

h1, h2, h3, .brand-logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* App Container Layout */
#app-container {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    height: 100vh;
    padding: 15px;
    gap: 15px;
    position: relative;
}

/* Glassmorphism Panel styles */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebars general styling */
aside {
    height: calc(100vh - 30px);
}

.sidebar-header {
    padding: 18px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Sessions elements */
.session-item {
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 64, 129, 0.05);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.session-item:hover, .session-item.active {
    background: var(--glass-active);
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 64, 129, 0.15);
}

.session-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 170px;
}

.session-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.session-item:hover .session-actions {
    opacity: 1;
}

/* Chat container styling */
#chat-container {
    height: calc(100vh - 30px);
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    gap: 12px;
}

#chat-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    min-height: 70px;
}

.brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 8px var(--primary-glow));
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.brand-info h1 {
    font-size: 1.3rem;
    background: linear-gradient(to right, #ffffff, var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.model-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 64, 129, 0.12);
    border: 1px solid rgba(255, 64, 129, 0.3);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.status-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}

#status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-idle { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }
.status-idle .status-dot { background: var(--text-muted); }

.status-listening { 
    background: rgba(38, 166, 154, 0.15); 
    color: #4db6ac; 
    animation: heartbeat 1.5s infinite;
}
.status-listening .status-dot { background: #26a69a; }

.status-thinking { 
    background: rgba(255, 171, 64, 0.15); 
    color: #ffb74d; 
}
.status-thinking .status-dot { 
    background: #ffab40; 
    animation: flash 1s infinite alternate;
}

.status-speaking { 
    background: rgba(255, 64, 129, 0.15); 
    color: var(--primary-light); 
}
.status-speaking .status-dot { 
    background: var(--primary); 
    animation: flash 0.6s infinite alternate;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(38, 166, 154, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 8px 2px rgba(38, 166, 154, 0.2); }
}

@keyframes flash {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* Chat Feed */
#message-feed {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    max-width: 450px;
    margin: 0 auto;
    gap: 15px;
    color: var(--text-muted);
}

.large-logo {
    font-size: 5rem;
    filter: drop-shadow(0 0 15px var(--primary-glow));
    margin-bottom: 10px;
}

.tip-box {
    background: rgba(255, 64, 129, 0.05);
    border: 1px solid rgba(255, 64, 129, 0.15);
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: left;
}

.tip-box i {
    color: var(--primary-light);
    margin-right: 5px;
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: slideIn 0.3s cubic-bezier(0.1, 1, 0.1, 1);
    position: relative;
}

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

.message.user {
    align-self: flex-end;
}

.message.gf {
    align-self: flex-start;
}

.message-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding: 0 5px;
    display: flex;
    justify-content: space-between;
}

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.message.user .message-bubble {
    background: var(--msg-user);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(255, 64, 129, 0.2);
}

.message.gf .message-bubble {
    background: var(--msg-gf);
    color: var(--text-main);
    border: 1px solid rgba(255, 64, 129, 0.1);
    border-bottom-left-radius: 4px;
}

.message.gf.interrupted .message-bubble {
    border-color: rgba(233, 30, 99, 0.4);
    background: linear-gradient(180deg, rgba(255, 182, 193, 0.08) 0%, rgba(233, 30, 99, 0.05) 100%);
}

.message-interrupted-tag {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--danger);
    text-transform: uppercase;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 5px;
    padding: 0 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s;
}

.message-action-btn:hover {
    color: var(--primary-light);
}

/* Web Audio Visualizer Panel */
#visualizer-container {
    height: 60px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--glass-border);
    background: rgba(10, 5, 15, 0.4);
}

#visualizer-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Chat Footer Control Row */
#chat-footer {
    padding: 12px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-input-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
}

textarea#text-input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: var(--text-main);
    resize: none;
    max-height: 100px;
    font-size: 0.95rem;
}

textarea#text-input::placeholder {
    color: rgba(216, 184, 204, 0.5);
}

.barge-in-indicators {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 5px;
}

.level-indicator-track {
    flex: 1;
    height: 4px;
    background: rgba(255, 64, 129, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.level-indicator-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, var(--primary-light), var(--primary));
    transition: width 0.05s ease;
}

.debug-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Settings configuration styling (Right Sidebar) */
#sidebar-right {
    height: calc(100vh - 30px);
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-section {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 64, 129, 0.06);
    border-radius: 12px;
    padding: 15px;
}

.section-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group.half {
    flex: 1;
    margin-bottom: 0;
}

label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-control {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(255, 64, 129, 0.2);
}

textarea.form-control {
    resize: vertical;
}

/* Slider Controls */
.slider-control {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 64, 129, 0.15);
    outline: none;
}

.slider-control::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 5px var(--primary);
    transition: transform 0.1s;
}

.slider-control::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3px;
}

.slider-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-light);
}

.help-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Custom Checkboxes */
.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    accent-color: var(--primary);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* Debug Cards */
.debug-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 64, 129, 0.15);
    border-radius: 8px;
    padding: 10px;
    font-family: monospace;
    font-size: 0.75rem;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.debug-row {
    display: flex;
    justify-content: space-between;
}

.state-active { color: var(--success); font-weight: bold; }
.state-inactive { color: var(--danger); }
.state-speaking-lbl { color: var(--primary); font-weight: bold; }

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 64, 129, 0.6);
}

.btn-secondary {
    background: rgba(255, 64, 129, 0.08);
    border: 1px solid rgba(255, 64, 129, 0.2);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 64, 129, 0.15);
    border-color: var(--primary);
}

.btn-danger {
    background: rgba(233, 30, 99, 0.1);
    border: 1px solid rgba(233, 30, 99, 0.3);
    color: #ff8a80;
}

.btn-danger:hover {
    background: rgba(233, 30, 99, 0.25);
    border-color: var(--danger);
}

button {
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    outline: none;
}

button:active {
    transform: scale(0.96);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    font-size: 1.1rem;
}

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

.btn-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
}

.btn-pill {
    border-radius: 20px;
    font-size: 0.78rem;
    padding: 4px 12px;
    border: 1px solid rgba(255, 64, 129, 0.2);
    background: rgba(255, 64, 129, 0.05);
    color: var(--text-main);
}

#handsfree-toggle.active {
    background: rgba(38, 166, 154, 0.15);
    border-color: #26a69a;
    color: #4db6ac;
    box-shadow: 0 0 10px rgba(38, 166, 154, 0.25);
}

/* Mic Buttons states */
.mic-idle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 64, 129, 0.2);
    color: var(--text-muted);
}

.mic-idle:hover {
    background: rgba(255, 64, 129, 0.1);
    color: var(--primary);
}

.mic-active {
    background: linear-gradient(135deg, #26a69a, #00897b);
    color: white;
    border: none;
    box-shadow: 0 0 15px rgba(38, 166, 154, 0.6);
    animation: mic-pulse 1.8s infinite;
}

@keyframes mic-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(38, 166, 154, 0.5); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(38, 166, 154, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(38, 166, 154, 0); }
}

.mobile-only-btn {
    display: none;
}

/* Responsive Rules */
@media (max-width: 1024px) {
    #app-container {
        grid-template-columns: 1fr;
        padding: 8px;
        gap: 8px;
        height: 100vh;
        overflow: hidden;
    }

    aside {
        position: fixed;
        top: 8px;
        bottom: 8px;
        z-index: 1000;
        width: 280px;
        max-width: calc(100vw - 16px);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.85);
    }

    #sidebar-left {
        left: -300px;
    }

    #sidebar-left.open {
        left: 8px;
    }

    #sidebar-right {
        right: -360px;
        width: 310px;
        max-width: calc(100vw - 16px);
    }

    #sidebar-right.open {
        right: 8px;
    }

    /* Adjust chat panels for mobile viewports */
    #chat-container {
        height: calc(100vh - 16px);
        gap: 8px;
    }

    #chat-header {
        padding: 8px 12px;
        min-height: 60px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .brand-info {
        gap: 8px;
    }

    .brand-logo {
        font-size: 1.8rem;
    }

    .brand-info h1 {
        font-size: 1.1rem;
    }

    .status-panel {
        gap: 6px;
        width: 100%;
        justify-content: space-between;
    }

    #handsfree-toggle {
        padding: 3px 8px;
        font-size: 0.72rem;
    }

    #message-feed {
        padding: 12px;
        border-radius: 12px;
    }

    .message {
        max-width: 88%;
    }

    /* Visualizer adjust */
    #visualizer-container {
        height: 45px;
    }

    /* Input box adjust */
    #chat-footer {
        padding: 8px;
    }

    .text-input-container {
        padding: 6px 12px;
    }

    textarea#text-input {
        font-size: 0.88rem;
    }

    .btn-circle {
        width: 38px;
        height: 38px;
    }

    .mobile-only-btn {
        display: flex;
        position: fixed;
        bottom: 80px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: rgba(255, 64, 129, 0.15);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid var(--primary);
        color: var(--text-main);
        z-index: 99;
        font-size: 1.1rem;
        box-shadow: 0 4px 15px rgba(255, 64, 129, 0.3);
    }

    #sidebar-left-toggle {
        left: 15px;
    }

    #sidebar-right-toggle {
        right: 15px;
    }
}

/* Typing Indicator Animation */
.message-bubble.typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 20px;
    min-height: 42px;
}
.typing-indicator-dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary-light);
    border-radius: 50%;
    animation: typing-bounce 1s infinite ease-in-out;
}
.typing-indicator-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

/* Lock Screen overlay styling */
#lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, #291234 0%, #08030b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.lock-card {
    width: 90%;
    max-width: 400px;
    padding: 35px 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.lock-logo {
    font-size: 4rem;
    filter: drop-shadow(0 0 15px var(--primary-glow));
    animation: float 4s ease-in-out infinite;
}

.lock-card h2 {
    font-size: 1.6rem;
    color: var(--primary-light);
}

.lock-card p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 10px;
}

.password-input-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

#password-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    text-align: center;
}

#password-input:focus {
    border-color: var(--primary);
}

.error-text {
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}
