/* === CSS Variables === */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #242424;
    --bg-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent-primary: #8b5cf6;
    --accent-secondary: #a78bfa;
    --border-color: #333333;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* === Reset & Base === */
* {
    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);
    line-height: 1.6;
    min-height: 100vh;
}

/* === Dashboard Container === */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === Header === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.header-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.source-count {
    background: var(--accent-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
}


/* === Tab Navigation === */
.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: var(--radius-lg);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.95rem;
}

.tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.tab-icon {
    font-size: 1.25rem;
}

.tab-time {
    font-size: 0.75rem;
    opacity: 0.7;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 10px;
}


/* === Tab Panels === */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.panel-header {
    margin-bottom: 24px;
}

.panel-header h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.panel-header p {
    color: var(--text-secondary);
}

/* === Filters === */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.filter-select:hover {
    border-color: var(--accent-primary);
}


/* === Buttons === */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

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

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


/* === Sources Grid === */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.sources-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.source-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s ease;
}

.source-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.source-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.source-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.4;
    flex: 1;
}

.source-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.source-title a:hover {
    color: var(--accent-secondary);
}


/* === Source Card Tags === */
.urgency-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.urgency-critical { background: var(--danger); color: white; }
.urgency-high { background: var(--warning); color: black; }
.urgency-medium { background: var(--info); color: white; }
.urgency-low { background: var(--success); color: white; }

.source-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.pack-tag, .category-tag {
    font-size: 0.75rem;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: 12px;
    color: var(--text-secondary);
}

.pack-tag { border-left: 3px solid var(--accent-primary); }

.source-summary {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}


/* === Email Factory Layout === */
.email-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.email-sources, .email-angles {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
}

.email-sources h3, .email-angles h3, .source-picker h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.angles-list {
    margin-top: 16px;
}

.angle-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    border-left: 3px solid var(--accent-primary);
}

.angle-item h4 {
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.angle-item p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}


/* === Chat Interface === */
.chat-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 24px;
}

.chat-message {
    margin-bottom: 20px;
}

.chat-message.assistant .message-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    max-width: 80%;
}

.chat-message.user .message-content {
    background: var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    max-width: 80%;
    margin-left: auto;
}

.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul { margin-left: 20px; margin-top: 8px; }
.message-content li { margin-bottom: 4px; color: var(--text-secondary); }

.chat-input-area {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

#chatInput {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
}

#chatInput:focus {
    outline: none;
    border-color: var(--accent-primary);
}


/* === Footer === */
.footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 48px;
}

/* === Loading & Empty States === */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

/* === Responsive === */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 16px; text-align: center; }
    .tab-nav { flex-direction: column; }
    .tab-btn { justify-content: flex-start; }
    .email-layout { grid-template-columns: 1fr; }
    .sources-grid { grid-template-columns: 1fr; }
}

/* === Feature Toggle === */
.feature-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.feature-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}


/* === Notifications === */
.notification-bell {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    position: relative;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.notification-bell:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.notification-count {
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.notification-count.zero {
    background: var(--text-muted);
}

.notifications-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 380px;
    max-height: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 1000;
    overflow: hidden;
}

.notifications-panel.hidden {
    display: none;
}

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

.notifications-header h3 {
    font-size: 1rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.notifications-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
}

.notification-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    border-left: 3px solid var(--accent-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.notification-item:hover {
    background: var(--bg-hover);
}

.notification-item.unread {
    border-left-color: var(--success);
}

.notification-item.broken-link {
    border-left-color: var(--danger);
}

.notification-item.fresh-content {
    border-left-color: var(--success);
}

.notification-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.notification-type {
    display: inline-block;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
}

.notification-type.fresh-content {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.notification-type.broken-link {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}
