﻿/* AI Price Trends Table Styles */
.ai-trends-table-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin: 20px 0;
    border: 1px solid #e5e7eb;
}

/* Trends Header and Controls */
.trends-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.trends-header h2 {
    margin: 0 0 16px 0;
    color: #1e293b;
    font-size: 24px;
    font-weight: 700;
}

.trends-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
}

.date-filters,
.location-filters,
.rooms-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}

.date-filters {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.trends-controls label {
    font-weight: 600;
    color: #374151;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trends-controls input,
.trends-controls select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
}

.trends-controls input:focus,
.trends-controls select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.trends-controls input:hover,
.trends-controls select:hover {
    border-color: #9ca3af;
}

.trends-controls .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.trends-controls .btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

.trends-controls .btn-secondary:hover {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-trends-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Mont', sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.ai-trends-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-trends-table thead th {
    padding: 16px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: relative;
}

.ai-trends-table thead th:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    height: 50%;
    width: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.ai-trends-table tbody tr {
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.2s ease;
}

.ai-trends-table tbody tr:hover {
    background-color: #f8fafc;
    transform: translateX(2px);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.05);
}

.ai-trends-table tbody tr:last-child {
    border-bottom: none;
}

.ai-trends-table td {
    padding: 14px 20px;
    vertical-align: middle;
    border: none;
    color: #374151;
    font-weight: 500;
}

/* Location column with grouping */
.ai-trends-location-cell {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-right: 3px solid #cbd5e1;
    font-weight: 600;
    color: #1e293b;
    text-align: center;
    vertical-align: middle;
    position: relative;
}

.ai-trends-location-cell::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Year column */
.ai-trends-year-cell {
    font-weight: 600;
    color: #4338ca;
    background: #faf5ff;
}

/* Subtype column */
.ai-trends-subtype-cell {
    color: #059669;
    font-weight: 500;
}

/* Rooms column */
.ai-trends-rooms-cell {
    text-align: center;
    font-weight: 600;
    color: #7c3aed;
    background: #faf5ff;
}

/* Price change column */
.ai-trends-price-cell {
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    padding: 12px 20px;
    position: relative;
}

.ai-trends-price-positive {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border-left: 4px solid #10b981;
}

.ai-trends-price-negative {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.ai-trends-price-neutral {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #64748b;
    border-left: 4px solid #94a3b8;
}

/* Price change icons */
.ai-trends-price-positive::before {
    content: 'â†— ';
    font-size: 16px;
    color: #059669;
    margin-right: 4px;
}

.ai-trends-price-negative::before {
    content: 'â†˜ ';
    font-size: 16px;
    color: #dc2626;
    margin-right: 4px;
}

.ai-trends-price-neutral::before {
    content: 'â†’ ';
    font-size: 16px;
    color: #6b7280;
    margin-right: 4px;
}

/* Empty state */
.ai-trends-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.ai-trends-empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #d1d5db;
}

.ai-trends-empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #374151;
}

.ai-trends-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Responsive design */
@media (max-width: 768px) {
    .trends-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .date-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .location-filters,
    .rooms-filters {
        min-width: auto;
    }
    
    .trends-controls .btn {
        justify-content: center;
    }
    
    .ai-trends-table {
        font-size: 12px;
    }
    
    .ai-trends-table th,
    .ai-trends-table td {
        padding: 10px 12px;
    }
    
    .ai-trends-location-cell {
        font-size: 12px;
    }
    
    .ai-trends-price-cell {
        font-size: 13px;
    }
}

/* Animation for row updates */
@keyframes ai-trends-row-highlight {
    0% {
        background-color: #fef3c7;
    }
    100% {
        background-color: transparent;
    }
}

.ai-trends-table tbody tr.ai-trends-new-row {
    animation: ai-trends-row-highlight 2s ease-out;
}

/* Loading state */
.ai-trends-loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.ai-trends-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    border-top-color: #667eea;
    animation: ai-trends-spin 1s ease-in-out infinite;
    margin-left: 10px;
}

@keyframes ai-trends-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== AI Analysis Modal ===== */
.ai-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    backdrop-filter: blur(4px);
}

.ai-modal-content {
    background: var(--colorNeutralBackground1, #fff);
    border-radius: 16px;
    width: 94%;
    max-width: 720px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 48px rgba(0,0,0,0.18);
    overflow: hidden;
}

.ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--colorNeutralStroke1, #e5e7eb);
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
}

.ai-modal-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-modal-title h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--colorNeutralForeground1, #1a1a2e);
}

.ai-subtitle {
    font-size: 13px;
    color: var(--colorNeutralForeground2, #6b7280);
}

.ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    flex-shrink: 0;
}

.ai-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--colorNeutralForeground2, #6b7280);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.ai-modal-close:hover {
    background: rgba(0,0,0,0.08);
}

.ai-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Chat bubble blocks */
.ai-block {
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(12px);
    animation: aiFadeIn 0.4s ease forwards;
}

.ai-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ai-block-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}
.ai-block-icon.competitors { background: #3b82f6; }
.ai-block-icon.sold        { background: #10b981; }
.ai-block-icon.clients     { background: #f59e0b; }

.ai-block-label {
    font-weight: 700;
    font-size: 15px;
    color: var(--colorNeutralForeground1, #1a1a2e);
}

.ai-block-body {
    background: var(--colorNeutralBackground2, #f8fafc);
    border: 1px solid var(--colorNeutralStroke1, #e5e7eb);
    border-radius: 12px;
    padding: 16px;
}

.ai-summary-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--colorNeutralForeground1, #1e293b);
    margin-bottom: 12px;
}
.ai-summary-text strong {
    color: #6366f1;
}

/* Typing dots animation */
.ai-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 8px 0;
}
.ai-typing-dot {
    width: 8px; height: 8px;
    background: #6366f1;
    border-radius: 50%;
    animation: aiTypingBounce 1.2s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

@keyframes aiFadeIn {
    to { opacity: 1; transform: translateY(0); }
}

/* Thinking step */
.ai-thinking-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    font-size: 14px;
    color: var(--colorNeutralForeground2, #6b7280);
}
.ai-thinking-step i {
    color: #6366f1;
    font-size: 18px;
}

/* Mini table inside AI blocks */
.ai-mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
.ai-mini-table th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    color: var(--colorNeutralForeground2, #6b7280);
    border-bottom: 2px solid var(--colorNeutralStroke1, #e5e7eb);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ai-mini-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--colorNeutralStroke1, #f1f3f5);
    color: var(--colorNeutralForeground1, #1e293b);
}
.ai-mini-table tr:last-child td { border-bottom: none; }
.ai-mini-table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

/* Badge pills */
.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.ai-badge.higher { background: #fef2f2; color: #dc2626; }
.ai-badge.lower  { background: #f0fdf4; color: #16a34a; }
.ai-badge.equal  { background: #f0f4ff; color: #6366f1; }
.ai-badge.neutral { background: #f3f4f6; color: #6b7280; }

/* Stats row */
.ai-stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 10px 0;
}
.ai-stat-card {
    flex: 1;
    min-width: 100px;
    background: #fff;
    border: 1px solid var(--colorNeutralStroke1, #e5e7eb);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}
.ai-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #6366f1;
}
.ai-stat-label {
    font-size: 11px;
    color: var(--colorNeutralForeground2, #6b7280);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Client list in AI */
.ai-client-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--colorNeutralStroke1, #f1f3f5);
}
.ai-client-item:last-child { border-bottom: none; }
.ai-client-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ai-client-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--colorNeutralForeground1, #1e293b);
}
.ai-client-criteria {
    font-size: 12px;
    color: var(--colorNeutralForeground2, #6b7280);
}
.ai-client-action .btn {
    font-size: 12px;
    padding: 4px 12px;
}

/* Responsive */
@media (max-width: 600px) {
    .ai-modal-content { width: 100%; max-height: 100vh; border-radius: 0; }
    .ai-stats-row { flex-direction: column; }
    .ai-stat-card { min-width: unset; }
}
