/* ==========================================
   AI INSIGHTS TAB
   ========================================== */

/* Insights View Layout — only display when active */
.insights-view.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Insights History Bar */
.insights-history-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
}

.history-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.history-arrow {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.history-arrow:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.4);
}

.history-date-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    flex-wrap: wrap; /* Allow text to wrap if it overflows */
    justify-content: center;
    font-size: 0.95rem; /* Slightly smaller to fit better on standard mobile */
    text-align: center;
}

/* API Key Config */
.insights-api-config {
    padding: 1.25rem 1.5rem;
}

.api-config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.api-config-info h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.api-config-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.api-config-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.api-config-actions input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 0.6rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    width: 280px;
    transition: all 0.3s ease;
}

.api-config-actions input:focus {
    outline: none;
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.btn-save-key {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
    padding: 0.6rem 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.btn-save-key:hover {
    background: rgba(251, 191, 36, 0.3);
    transform: translateY(-1px);
}

/* Period Selector & Controls */
.insights-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.period-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.3rem;
    border-radius: 2rem;
    border: 1px solid var(--glass-border);
}

.period-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.period-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-generate {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Charts Grid */
.insights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--card-gap, 1.25rem);
}

@media (max-width: 768px) {
    .insights-grid {
        grid-template-columns: 1fr;
    }
}

.chart-panel {
    padding: 1.5rem;
}

.chart-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.chart-panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 250px;
}

/* AI Feedback Panel */
.ai-feedback-panel {
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.05);
}

.ai-feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--card-gap, 1.25rem);
}

.ai-feedback-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* AI Star Rating */
.ai-rating-container {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(0, 0, 0, 0.2));
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: var(--card-gap, 1.25rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 10px 25px rgba(251, 191, 36, 0.05);
    animation: fadeIn 0.5s ease-out forwards;
}

.ai-rating-score {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.ai-rating-total {
    font-size: 1.5rem;
    font-weight: 600;
    -webkit-text-fill-color: var(--text-secondary);
}

.ai-rating-stars {
    display: flex;
    gap: 0.25rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    flex-wrap: wrap; /* Stars wrap on very small screens instead of overflowing */
    justify-content: center;
}

@media (max-width: 420px) {
    .ai-rating-score { font-size: 2rem; }
    .ai-rating-total { font-size: 1.1rem; }
    .ai-rating-stars { font-size: 1.1rem; gap: 0.15rem; }
    .ai-rating-container { padding: 1rem; }
}


.ai-rating-stars .fa-star.filled {
    color: #fbbf24;
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5));
}

.ai-rating-label {
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 2px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* AI Loading Animation */
.ai-loading {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.ai-loading-dot {
    width: 8px;
    height: 8px;
    background: #6366f1;
    border-radius: 50%;
    animation: aiPulse 1.4s ease-in-out infinite;
}

.ai-loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aiPulse {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* AI Feedback Content */
.ai-feedback-content {
    line-height: 1.7;
    color: var(--text-primary);
}

.ai-feedback-content h1,
.ai-feedback-content h2,
.ai-feedback-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.ai-feedback-content h1 {
    font-size: 1.4rem;
    color: #a5b4fc;
}

.ai-feedback-content h2 {
    font-size: 1.2rem;
    color: #c4b5fd;
}

.ai-feedback-content h3 {
    font-size: 1.05rem;
    color: #93c5fd;
}

.ai-feedback-content p {
    margin-bottom: 0.75rem;
}

.ai-feedback-content ul,
.ai-feedback-content ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

.ai-feedback-content li {
    margin-bottom: 0.4rem;
}

.ai-feedback-content strong {
    color: #fbbf24;
    font-weight: 600;
}

.ai-feedback-content em {
    color: var(--text-secondary);
}

.ai-feedback-content code {
    background: rgba(99, 102, 241, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.9em;
    color: #a5b4fc;
}

/* AI Placeholder */
.ai-placeholder {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.ai-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.3;
    background: linear-gradient(to right, #6366f1, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-placeholder p {
    font-size: 1.05rem;
    max-width: 400px;
    margin: 0 auto;
}

/* API Key status variants */
.api-key-active {
    color: #34d399 !important;
}

.api-key-missing {
    color: #fca5a5 !important;
}

