/**
 * Fantasy Draft Board v4.0 - Trade Advisor Styles
 * 
 * Styles for the AI chat panel that appears alongside
 * the Trade Builder and Trade Evaluator.
 * 
 * @version 4.1
 */

/* ============================================
   CHAT PANEL CONTAINER
   ============================================ */

.ta-panel {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 580px;
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */

.ta-header {
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ta-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ta-header-icon {
    font-size: 1.1rem;
}

.ta-header-title {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.ta-usage-badge {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 0.2rem 0.65rem;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.85);
    cursor: default;
    white-space: nowrap;
}

/* ============================================
   CONTEXT BANNER
   ============================================ */

.ta-context-banner {
    padding: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 1px solid #475569;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.ta-context-icon {
    font-size: 0.7rem;
}

.ta-context-text {
    color: #94a3b8;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.ta-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.ta-messages::-webkit-scrollbar {
    width: 4px;
}

.ta-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ta-messages::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 2px;
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.ta-msg {
    display: flex;
    gap: 0.5rem;
    animation: taFadeIn 0.2s ease-out;
}

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

.ta-msg-user {
    flex-direction: row-reverse;
}

.ta-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.ta-msg-bubble {
    max-width: 85%;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #f1f5f9;
    word-wrap: break-word;
}

.ta-msg-jerry-bubble {
    background: #334155;
    border-radius: 2px 12px 12px 12px;
}

.ta-msg-user-bubble {
    background: rgba(59, 130, 246, 0.2);
    border-radius: 12px 2px 12px 12px;
}

.ta-msg-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ============================================
   THINKING INDICATOR
   ============================================ */

.ta-thinking-bubble {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
}

.ta-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #64748b;
    animation: taBounce 1.4s infinite ease-in-out;
}

.ta-dot:nth-child(1) { animation-delay: 0s; }
.ta-dot:nth-child(2) { animation-delay: 0.2s; }
.ta-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes taBounce {
    0%, 80%, 100% { 
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   INPUT AREA
   ============================================ */

.ta-input-area {
    padding: 0.65rem;
    border-top: 1px solid #475569;
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.ta-input {
    flex: 1;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    color: #f1f5f9;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s;
}

.ta-input:focus {
    border-color: #3b82f6;
}

.ta-input::placeholder {
    color: #64748b;
}

.ta-send-btn {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    border: none;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
    flex-shrink: 0;
}

.ta-send-btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

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

/* ============================================
   DISCLAIMER
   ============================================ */

.ta-disclaimer {
    padding: 0.4rem 0.75rem;
    border-top: 1px solid #475569;
    background: rgba(0, 0, 0, 0.15);
    text-align: center;
    color: #64748b;
    font-size: 0.6rem;
    flex-shrink: 0;
}

/* ============================================
   UPGRADE MODAL - TIER CARDS
   ============================================ */

.ta-tier-cards {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ta-tier-card {
    flex: 1;
    background: #334155;
    border: 2px solid #475569;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    position: relative;
}

.ta-tier-recommended {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.ta-tier-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #3b82f6;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.6rem;
    border-radius: 10px;
}

.ta-tier-name {
    color: #f1f5f9;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ta-tier-price {
    color: #f1f5f9;
    font-weight: 800;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.ta-tier-price span {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 400;
}

.ta-tier-highlight {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
    border-radius: 6px;
    padding: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.ta-tier-feature {
    color: #94a3b8;
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
}

.ta-tier-btn {
    margin-top: 0.75rem;
    width: 100%;
    background: transparent;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 0.5rem;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.ta-tier-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ta-tier-btn-primary {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    border: none;
    color: white;
}

.ta-tier-btn-primary:hover {
    filter: brightness(1.1);
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
}

/* League plan callout */
.ta-league-plan {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.ta-league-plan-title {
    color: #34d399;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.ta-league-plan-desc {
    color: #94a3b8;
    font-size: 0.75rem;
}

.ta-maybe-later {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 0.75rem;
    padding: 0.5rem;
}

.ta-maybe-later:hover {
    color: #f1f5f9;
}

/* ============================================
   LAYOUT: Side-by-side container
   Used by Trade Builder and Trade Evaluator
   to position the trade content + chat panel
   ============================================ */

.trade-with-advisor {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.trade-with-advisor .trade-main-content {
    flex: 1 1 58%;
    min-width: 0;
}

.trade-with-advisor .trade-advisor-panel {
    flex: 1 1 40%;
    min-width: 280px;
    max-width: 420px;
}

/* ============================================
   MOBILE: Stack vertically on small screens
   ============================================ */

@media (max-width: 768px) {
    .trade-with-advisor {
        flex-direction: column;
    }
    
    .trade-with-advisor .trade-advisor-panel {
        max-width: none;
        width: 100%;
    }
    
    .ta-panel {
        max-height: 400px;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .trade-with-advisor .trade-advisor-panel {
        flex: 1 1 35%;
        min-width: 260px;
    }
}

/* ============================================================
   WHEN RENDERED INSIDE THE EVALUATION MODAL ADVISOR TAB
   .te-advisor-container is added by trade_evaluation_modal_v4.js
   ============================================================ */

.te-advisor-container {
    height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ensure ta-panel fills the container and scrolls correctly */
.te-advisor-container .ta-panel {
    flex: 1;
    min-height: 0;        /* critical — allows flex children to shrink */
    max-height: none;     /* override the 580px cap from .ta-panel */
    border-radius: 0;
    border: none;
}

/* Ensure messages area can actually scroll inside the fixed-height container */
.te-advisor-container .ta-messages {
    min-height: 0;        /* critical — without this, flex won't shrink it */
}

.te-advisor-unavailable {
    padding: 2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
    font-size: 0.85rem;
}
