/**
 * Confidence Talk - Frontend Dashboard CSS
 *
 * Gold Series frontend overrides — relies on gold-series.css for base styles.
 * Only contains frontend-specific overrides and theme compatibility fixes.
 *
 * @package ConfidenceTalk
 */

/* ============================================
   THEME OVERRIDE FIXES
   ============================================ */

/* Force transparent backgrounds on all theme containers */
body:has(.ct-gold-series) .entry-content,
body:has(.ct-gold-series) .site-content,
body:has(.ct-gold-series) .content-area,
body:has(.ct-gold-series) .site-main,
body:has(.ct-gold-series) .page-content,
body:has(.ct-gold-series) .post-content,
body:has(.ct-gold-series) article,
body:has(.ct-gold-series) .hentry,
body:has(.ct-gold-series) .type-page,
body:has(.ct-gold-series) .status-publish,
body:has(.ct-gold-series) .entry,
body:has(.ct-gold-series) .page-body,
body:has(.ct-gold-series) .main-content,
body:has(.ct-gold-series) .container,
body:has(.ct-gold-series) .wrapper,
body:has(.ct-gold-series) .content-wrapper,
body:has(.ct-gold-series) .page-wrapper,
body:has(.ct-gold-series) .site-inner,
body:has(.ct-gold-series) .wrap {
    background: transparent !important;
    background-color: transparent !important;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
    width: 100%;
    box-shadow: none;
    border: none;
}

body.ct-dashboard-active,
body:has(.ct-gold-series) {
    background: #eef2f6;
}

/* ============================================
   FRONTEND-SPECIFIC OVERRIDES
   ============================================ */

/* Gold Series container — no max-width constraint (inherits from content area) */

/* Frontend nav items are divs (not anchor tags like backend) */
.ct-nav-item {
    cursor: pointer;
    border: none;
    width: 100%;
    text-align: left;
}
/* Frontend input class mapping to backend ct-form-group input styles */
.ct-input {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.ct-input:focus {
    border-color: rgba(205, 133, 63, 0.5);
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.ct-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Chat input field - extra specificity to override theme CSS */
#ct-chat-input-field.ct-input {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

#ct-chat-input-field.ct-input:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

#ct-chat-input-field.ct-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

select.ct-input option {
    background: #2c3e50;
    color: #ffffff;
}

textarea.ct-input {
    min-height: 80px;
    resize: vertical;
}

/* ============================================
   CHAT INTERFACE
   ============================================ */
.ct-chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    background: var(--metallic-steel-gradient);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    position: relative;
}

.ct-chat-container.ct-has-portrait .ct-chat-header,
.ct-chat-container.ct-has-portrait .ct-messages,
.ct-chat-container.ct-has-portrait .ct-chat-input {
    position: relative;
    z-index: 1;
}
.ct-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.ct-chat-title {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.ct-chat-agents {
    display: flex;
    gap: 4px;
}

.ct-chat-agent-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ct-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ct-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.ct-message-user {
    align-self: flex-end;
    background: rgba(139, 69, 19, 0.12);
    border: 1px solid rgba(205, 133, 63, 0.25);
    color: rgba(255, 255, 255, 0.9);
}

.ct-message-agent {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
}

.ct-message-system {
    align-self: center;
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid rgba(192, 57, 43, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    text-align: center;
}

.ct-message .ct-message-text {
    flex: 1;
    min-width: 0;
}

.ct-message .ct-message-time {
    font-size: 9px;
    opacity: 0.5;
    margin-top: 4px;
    text-align: right;
}

.ct-chat-input {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.ct-chat-input .ct-input {
    flex: 1;
}

/* ============================================
   3-WAY MODE SWITCH (Voice / Auto / Text)
   Metallic Bronze Gradient segmented button
   ============================================ */
.ct-mode-switch {
    display: inline-flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.2);
}
.ct-mode-btn {
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.5);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
    white-space: nowrap;
    line-height: 1.4;
    border-right: 1px solid rgba(255,255,255,0.08);
}
.ct-mode-btn:last-child {
    border-right: none;
}
.ct-mode-btn:hover {
    color: rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.05);
}
.ct-mode-btn.ct-mode-active {
    background: linear-gradient(135deg, #8B4513, #A0522D, #CD853F);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Voice-only mode — hide message text/bubbles so portrait shines through */
.ct-mode-voice-only .ct-message {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}
.ct-mode-voice-only .ct-message-text {
    color: transparent !important;
}
.ct-mode-voice-only .ct-message-welcome,
.ct-mode-voice-only .ct-message-return-banner {
    opacity: 0;
}
.ct-mode-voice-only .ct-speak-btn {
    opacity: 0.3;
}

/* Text-only mode — hide speak buttons, they serve no purpose */
.ct-mode-text-only .ct-speak-btn {
    display: none !important;
}

/* ============================================
   WELCOME CARD — Greeting messages
   ============================================ */
.ct-message.ct-message-welcome {
    border-left: 3px solid #CD853F;
    background: linear-gradient(135deg, rgba(205,133,63,0.08) 0%, rgba(205,133,63,0.02) 100%) !important;
    position: relative;
    overflow: hidden;
    animation: ctGreetingEntrance 0.4s ease forwards;
}
.ct-message.ct-message-welcome .ct-message-text {
    font-size: 15px;
    line-height: 1.7;
    color: rgba(255,255,255,0.95) !important;
}
.ct-message.ct-message-welcome .ct-message-text strong {
    color: #CD853F;
}

/* ============================================
   FRONTEND BUTTON STYLING - User Dashboard
   Bronze gradient primary, lifted hover
   ============================================ */
.ct-gold-series .ct-btn {
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.ct-gold-series .ct-btn-primary {
    background: linear-gradient(135deg, #8B4513, #A0522D, #CD853F);
    border-color: transparent;
    box-shadow: 0 3px 8px rgba(139, 69, 19, 0.35);
}
.ct-gold-series .ct-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(139, 69, 19, 0.45);
}
.ct-gold-series .ct-btn-secondary {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
}
.ct-gold-series .ct-btn-secondary:hover {
    background: rgba(205,133,63,0.2);
    border-color: rgba(205,133,63,0.4);
    color: #fff;
    transform: translateY(-1px);
}

/* Profile save button */
.ct-gold-series .ct-form-group + .ct-btn-primary {
    margin-top: 8px;
}

/* User message in chat — bronze accent */
.ct-message.ct-message-user {
    background: rgba(139, 69, 19, 0.15);
    border: 1px solid rgba(205, 133, 63, 0.25);
}

/* ============================================
   RETURN BANNER — Old conversation re-opened
   ============================================ */
.ct-message.ct-message-return-banner {
    max-width: 100%;
    align-self: center;
    text-align: center;
    background: linear-gradient(135deg, rgba(205,133,63,0.1) 0%, rgba(205,133,63,0.03) 100%) !important;
    border: 1px solid rgba(205,133,63,0.25);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255,255,255,0.85);
    animation: ctGreetingEntrance 0.5s ease forwards;
}
.ct-message.ct-message-return-banner .ct-message-text {
    font-size: 13px;
    line-height: 1.6;
    color: rgba(255,255,255,0.85) !important;
}

/* ============================================
   PORTRAIT REVEAL ANIMATION (Enhancement 4)
   ============================================ */
.ct-messages.ct-has-portrait {
    position: relative;
    animation: ctPortraitReveal 1.2s ease-out forwards;
}
@keyframes ctPortraitReveal {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}
.ct-messages.ct-has-portrait > * {
    position: relative;
    z-index: 1;
}

/* ============================================
   PORTRAIT LIVING EFFECT (Clean Pseudo-Element)
   Portrait in ::before with inset: 0 (no overflow).
   No extra gradients or overlays on the messages container.
   ============================================ */

.ct-chat-container.ct-has-portrait::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: var(--ct-portrait-url);
    background-size: 103% auto;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    animation: ctBreathingZoom 50s ease-in-out infinite;
    pointer-events: none;
}

@keyframes ctBreathingZoom {
    0%   { background-size: 103% auto; }
    50%  { background-size: 110% auto; }
    100% { background-size: 103% auto; }
}

/* Greeting entrance animation */
@keyframes ctGreetingEntrance {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SPEAK BUTTON — Circular Play/Pause
   ============================================ */
.ct-speak-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(205, 133, 63, 0.3);
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    color: #cd853f;
    font-size: 13px;
    padding: 0;
    line-height: 1;
}
.ct-speak-btn::before {
    content: '▶';
    display: block;
    line-height: 1;
    transition: transform 0.2s ease;
}
.ct-speak-btn.playing::before {
    content: '⏸';
}
.ct-speak-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #cd853f;
}
.ct-speak-btn:hover::before {
    transform: scale(1.15);
}
.ct-speak-btn:active {
    transform: scale(0.95);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media screen and (max-width: 768px) {
    .ct-chat-container {
        height: 500px;
    }

    .ct-message {
        max-width: 90%;
    }
}