:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-hover: #202020;
    --border-color: rgba(255,255,255,0.08);
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-muted: #666666;
    --accent-primary: #10a37f;
    --accent-blue: #0084ff;
    --accent-red: #ff4444;
    --accent-yellow: #ffb800;
    --accent-purple: #8b5cf6;
    --sidebar-width: 380px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Logo */
.logo-container {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    height: 70px;
}

.logo {
    max-height: 45px;
    width: auto;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Base */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.25rem;
}

/* Add Button */
.add-btn {
    width: 100%;
    padding: 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.add-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.12);
}

/* Events List */
.events-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.empty-events {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-events i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-events p {
    font-size: 0.8125rem;
    line-height: 1.5;
}

.event-category {
    margin-bottom: 1.5rem;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.category-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.625rem;
}

.event-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.event-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.15s ease;
}

.event-item:hover {
    background: var(--bg-hover);
    border-color: rgba(255,255,255,0.12);
    transform: translateX(2px);
}

.event-item:hover::before {
    background: var(--accent-primary);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.event-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    margin-right: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-influence {
    font-size: 0.7rem;
    color: var(--accent-primary);
    line-height: 1.4;
    margin-top: 0.5rem;
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.event-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.event-time i {
    font-size: 0.625rem;
}

.event-badge {
    font-size: 0.625rem;
    padding: 0.1875rem 0.5rem;
    border-radius: 100px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-alto { background: rgba(255, 68, 68, 0.2); color: #ff6666; }
.badge-medio { background: rgba(255, 184, 0, 0.2); color: #ffc933; }
.badge-basso { background: rgba(16, 163, 127, 0.2); color: #10d998; }
.badge-critical { background: rgba(255, 68, 68, 0.2); color: #ff6666; }
.badge-high { background: rgba(255, 184, 0, 0.2); color: #ffc933; }
.badge-medium { background: rgba(16, 163, 127, 0.2); color: #10d998; }
.badge-low { background: rgba(136, 136, 136, 0.2); color: #999999; }

/* Loading State */
.loading-events {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Event Stats */
.event-stats {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.stat-item {
    flex: 1;
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Chat Header with Date Range */
.chat-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.chat-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-date-range {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-date-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-date-input {
    padding: 0.375rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
    width: 120px;
    transition: all 0.15s ease;
}

.header-date-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.clear-btn {
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.clear-btn:hover {
    background: var(--bg-tertiary);
    border-color: rgba(255,255,255,0.12);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Empty State */
.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.empty-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.empty-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    max-width: 320px;
    line-height: 1.5;
}

/* Messages */
.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    animation: messageIn 0.2s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.avatar-user {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.avatar-ai {
    background: var(--accent-primary);
    color: white;
}

.message-content {
    flex: 1;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.message-author {
    font-weight: 600;
    font-size: 0.8125rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-text {
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-data {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.data-item {
    text-align: center;
}

.data-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.data-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s ease infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
    30% { opacity: 1; transform: scale(1.2); }
}

/* Chat Input */
.chat-input-container {
    padding: 1.25rem 2rem;
    border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.625rem 0.875rem;
    transition: all 0.15s ease;
}

.chat-input-wrapper:focus-within {
    background: var(--bg-secondary);
    border-color: rgba(255,255,255,0.12);
}

.chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.875rem;
    outline: none;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

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

/* Updated Filters Section */
.filters-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.filter-group {
    margin-bottom: 0.75rem;
}

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

.filter-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.category-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.category-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    transition: all 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: rgba(255,255,255,0.12);
    background: var(--bg-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Date Range Picker */
.date-range-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.date-input-group {
    position: relative;
}

.date-input-group i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.date-input-group input {
    padding-left: 2.5rem;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #0e8f6b;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: rgba(255,255,255,0.12);
}

/* Source Types Grid */
.source-types {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.source-type-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.source-type-card:hover {
    background: var(--bg-hover);
    border-color: rgba(255,255,255,0.12);
}

.source-type-card.selected {
    border-color: var(--accent-primary);
    background: rgba(16, 163, 127, 0.1);
}

.source-type-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.source-type-card.selected .source-type-icon {
    color: var(--accent-primary);
}

.source-type-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.source-type-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Priority Select */
.priority-select {
    display: flex;
    gap: 0.5rem;
}

.priority-option {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.priority-option:hover {
    background: var(--bg-hover);
}

.priority-option.selected {
    border-color: transparent;
}

.priority-option.selected.critical { background: rgba(255, 68, 68, 0.2); color: #ff6666; }
.priority-option.selected.high { background: rgba(255, 184, 0, 0.2); color: #ffc933; }
.priority-option.selected.medium { background: rgba(16, 163, 127, 0.2); color: #10d998; }
.priority-option.selected.low { background: rgba(136, 136, 136, 0.2); color: #999999; }

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.2s ease;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
}

@keyframes toastIn {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.toast-icon {
    color: var(--accent-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

/* Icon specific colors by category */
.icon-finanza { background: rgba(0, 132, 255, 0.2); color: #4da3ff; }
.icon-economia { background: rgba(255, 184, 0, 0.2); color: #ffc933; }
.icon-innovazione { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }
.icon-mercati { background: rgba(16, 163, 127, 0.2); color: #10d998; }
.icon-risorse { background: rgba(236, 72, 153, 0.2); color: #ec4899; }
.icon-normativa { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.icon-customer { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.icon-sostenibilita { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.icon-geopolitica { background: rgba(255, 68, 68, 0.2); color: #ff6666; }
.icon-business { background: rgba(168, 85, 247, 0.2); color: #a855f7; }