/* 
   Malagueta Continuous Discovery Hub
   UI Styles overriding/extending styles-swiss.css
*/

:root {
    --sidebar-width: 260px;
    --header-height: 80px;
    --color-border: #e5e5e5;
    --color-bg-app: #fbfbfb;
    
    /* Semantic Colors */
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-success: #10b981;
    --color-info: #3b82f6;
}

/* Layout Geral */
body {
    background: var(--color-bg-app);
    overflow: hidden; /* App feel */
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-white);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--grid-4);
    border-bottom: 1px solid var(--color-border);
    font-weight: 800;
    font-size: var(--type-lg);
    letter-spacing: var(--tracking-tighter);
}

.brand-icon {
    margin-right: var(--grid-2);
    font-size: 24px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--grid-4);
}

.nav-section {
    margin-bottom: var(--grid-6);
}

.nav-section-title {
    font-size: var(--type-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-text-muted);
    margin-bottom: var(--grid-2);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: var(--grid-2);
    margin-bottom: var(--grid-1);
    color: var(--color-text-strong);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--type-sm);
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.nav-item svg {
    margin-right: var(--grid-2);
    stroke: currentColor;
}

.nav-item:hover {
    background: var(--color-surface-2);
}

.nav-item.active {
    background: var(--color-black);
    color: var(--color-white);
}

.sidebar-footer {
    padding: var(--grid-4);
    border-top: 1px solid var(--color-border);
}

.user-profile {
    display: flex;
    align-items: center;
}

.avatar {
    width: 32px;
    height: 32px;
    background: var(--color-accent);
    color: var(--color-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-right: var(--grid-2);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: var(--type-sm);
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* Main Content */
.app-main {
    flex: 1;
    overflow-y: auto;
    background: var(--color-bg-app);
}

.view-section {
    padding: var(--grid-6) var(--grid-8);
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.view-section.hidden {
    display: none;
}

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

/* Headers */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--grid-6);
}

.header-title h1 {
    font-size: var(--type-3xl);
    margin-bottom: var(--grid-1);
}

.header-title p {
    color: var(--color-text-muted);
    margin-bottom: 0;
}

/* Filters */
.filters-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--grid-6);
    padding-bottom: var(--grid-4);
    border-bottom: 1px solid var(--color-border);
}

.filter-group {
    display: flex;
    gap: var(--grid-3);
}

.filter-select {
    padding: var(--grid-1) var(--grid-3);
    border: 1px solid var(--color-border);
    background: var(--color-white);
    font-family: inherit;
    font-size: var(--type-sm);
    border-radius: 0; /* Swiss style */
    outline: none;
}

.ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.green { background: var(--color-success); }
.status-dot.orange { background: var(--color-warning); }

/* Metrics */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-4);
    margin-bottom: var(--grid-8);
}

.metric-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    padding: var(--grid-4);
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: var(--type-3xl);
    font-weight: 800;
    line-height: 1;
    margin-bottom: var(--grid-1);
}

.metric-label {
    font-size: var(--type-sm);
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: var(--grid-2);
}

.metric-trend {
    font-size: 12px;
    font-weight: 500;
}
.metric-trend.positive { color: var(--color-success); }
.metric-trend.neutral { color: var(--color-text-muted); }

/* Themes List (Dashboard) */
.themes-list {
    display: flex;
    flex-direction: column;
    gap: var(--grid-3);
}

.theme-row {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    padding: var(--grid-4);
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1fr auto;
    align-items: center;
    gap: var(--grid-4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.theme-row:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-subtle);
    border-color: var(--color-black);
}

.theme-info-main h3 {
    font-size: var(--type-lg);
    margin-bottom: var(--grid-1);
    line-height: 1.2;
}

.theme-tags {
    display: flex;
    gap: var(--grid-1);
}

.tag {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--color-surface-2);
    color: var(--color-text-strong);
    font-weight: 600;
    text-transform: uppercase;
}

.tag.high-impact { background: #fee2e2; color: #b91c1c; }
.tag.opp { background: #dbeafe; color: #1d4ed8; }

.theme-stat {
    display: flex;
    flex-direction: column;
}

.theme-stat-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.theme-stat-val {
    font-size: var(--type-md);
    font-weight: 600;
}

/* Detail View */
.btn-back {
    background: none;
    border: none;
    font-family: inherit;
    font-size: var(--type-sm);
    font-weight: 600;
    cursor: pointer;
    margin-bottom: var(--grid-4);
    color: var(--color-text-muted);
}
.btn-back:hover { color: var(--color-black); }

.detail-header {
    border-bottom: 2px solid var(--color-black);
    padding-bottom: var(--grid-4);
    margin-bottom: var(--grid-6);
}

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--grid-6);
}

.card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    margin-bottom: var(--grid-6);
}

.card-header {
    padding: var(--grid-3) var(--grid-4);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: var(--type-md);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: var(--grid-4);
}

/* AI Synthesis Card */
.ai-synthesis-card {
    border-color: var(--color-accent);
}
.ai-synthesis-card .card-header {
    background: rgba(0, 140, 255, 0.05);
}
.sparkle { color: var(--color-accent); }

.summary-text {
    font-size: var(--type-md);
    line-height: 1.6;
}

/* Quotes */
.quotes-list {
    display: flex;
    flex-direction: column;
    gap: var(--grid-4);
}

.quote-item {
    padding-bottom: var(--grid-4);
    border-bottom: 1px solid var(--color-surface-2);
}
.quote-item:last-child { border: none; padding-bottom: 0; }

.quote-text {
    font-size: var(--type-md);
    font-style: italic;
    color: var(--color-text-strong);
    margin-bottom: var(--grid-2);
    line-height: 1.5;
}

.quote-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Canvas Sidebar */
.canvas-field { margin-bottom: var(--grid-4); }
.canvas-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: var(--grid-2);
}
.canvas-field textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    padding: var(--grid-2);
    font-family: inherit;
    font-size: var(--type-sm);
    resize: vertical;
    min-height: 60px;
}
.canvas-field textarea:focus {
    outline: none; border-color: var(--color-black);
}

.checklist { list-style: none; }
.checklist li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--type-sm);
    margin-bottom: 8px;
}

/* Impact */
.impact-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--type-sm);
    font-weight: 500;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--color-surface-2);
}
.impact-tag .red { color: var(--color-danger); font-weight: bold; }
.impact-tag .orange { color: var(--color-warning); font-weight: bold; }

/* Add Insight Form */
.add-insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--grid-8);
}

.form-group { margin-bottom: var(--grid-4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--grid-4); }
.form-group label {
    display: block;
    font-size: var(--type-sm);
    font-weight: 700;
    margin-bottom: var(--grid-2);
}
.form-group textarea, .form-group select, .form-group input {
    width: 100%;
    padding: var(--grid-2);
    border: 1px solid var(--color-border);
    font-family: inherit;
    font-size: var(--type-md);
}
.form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: var(--color-black);
}

/* AI Preview Container */
.ai-preview-container {
    background: var(--color-surface-1);
    border: 1px dashed var(--color-border);
    padding: var(--grid-4);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.ai-state { width: 100%; }
.ai-state.hidden { display: none; }
#ai-empty {
    text-align: center;
    color: var(--color-text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.5; }

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 140, 255, 0.2);
    border-radius: 50%;
    border-top-color: var(--color-accent);
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
#ai-loading { text-align: center; color: var(--color-text-strong); font-weight: 500; }

.suggested-theme, .suggested-summary, .suggested-tags { margin-bottom: var(--grid-4); }
.suggested-theme label, .suggested-summary label, .suggested-tags label {
    display: block; font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--color-text-muted); margin-bottom: 8px;
}
.theme-match {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px; background: var(--color-surface-2); border: 1px solid var(--color-border);
}
.theme-match-title { font-weight: 600; font-size: var(--type-sm); }
.match-score { font-size: 12px; color: var(--color-success); font-weight: 700; }
.helper-text { font-size: 11px; color: var(--color-text-muted); display: block; margin-top: 4px; }
#ai-summary-edit { width: 100%; border: 1px solid var(--color-border); padding: 8px; font-family: inherit; font-size: var(--type-sm); resize: vertical; }

.tags-input-mock {
    display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px solid var(--color-border); background: var(--color-white);
}
.tags-input-mock input { border: none; outline: none; font-size: 12px; font-family: inherit; width: 100px; }

/* Buttons Overrides */
.btn-sm { padding: 8px 16px; font-size: 11px; }
.btn-full { width: 100%; display: block; margin-top: var(--grid-4); }
.mt-4 { margin-top: var(--grid-4); }

/* Toast */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--color-black); color: var(--color-white);
    padding: 12px 24px; font-weight: 600; font-size: var(--type-sm);
    z-index: 9999; transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; transform: translateY(20px); pointer-events: none; }

/* Responsive adjustments */
@media (max-width: 900px) {
    .app-container { flex-direction: column; }
    .app-sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--color-border); }
    .sidebar-nav { display: none; }
    .sidebar-footer { display: none; }
    
    .metrics-row { grid-template-columns: 1fr; }
    .theme-row { grid-template-columns: 1fr; gap: var(--grid-2); }
    .detail-grid { grid-template-columns: 1fr; }
    .add-insight-grid { grid-template-columns: 1fr; }
}
