/*
 * CreaCom — Stylesheet
 * Estetica: terminale industriale + precisione analitica
 * Font: Syne (display) + DM Mono (dati)
 */

/* ── Reset e variabili ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0a0a0f;
    --bg-2:        #111118;
    --bg-3:        #1a1a24;
    --border:      #2a2a3a;
    --border-2:    #3a3a50;
    --text:        #e8e8f0;
    --text-2:      #9090b0;
    --text-3:      #5a5a70;
    --accent:      #6c63ff;
    --accent-2:    #4a43cc;
    --green:       #2dd4a0;
    --yellow:      #f5c842;
    --red:         #ff5566;
    --orange:      #ff8c42;

    --radius:      4px;
    --radius-lg:   8px;
    --font-display: 'Syne', sans-serif;
    --font-mono:    'DM Mono', monospace;
}

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 60px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-mark {
    color: var(--accent);
    font-size: 1.2rem;
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

.nav {
    display: flex;
    gap: 2px;
    justify-content: center;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.nav-btn:hover { color: var(--text); background: var(--bg-3); }
.nav-btn.active { color: var(--accent); background: rgba(108, 99, 255, 0.1); }

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    justify-self: end;
}

.badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Main layout ───────────────────────────────────────────── */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 60px - 53px);
}

/* ── Views ─────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

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

.view-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
}

/* ── Search hero ───────────────────────────────────────────── */
.search-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    transition: all 0.4s ease;
    width: 100%;
}

.search-hero.has-results {
    min-height: auto;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.search-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-3);
    margin-bottom: 0.75rem;
    width: 100%;
    max-width: 800px;
}

.search-box {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    max-width: 800px;
}

.search-textarea {
    flex: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 12px 16px;
    resize: none;
    line-height: 1.5;
    transition: border-color 0.2s;
    outline: none;
    height: 48px;
}

.search-textarea:focus { border-color: var(--accent); }
.search-textarea::placeholder { color: var(--text-3); }

.search-btn {
    background: var(--accent);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.15s;
    height: 48px;
    flex-shrink: 0;
}

.search-btn:hover { background: var(--accent-2); transform: translateY(-1px); }
.search-btn:active { transform: translateY(0); }
.search-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.search-hints {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 800px;
}

.hint {
    font-size: 0.72rem;
    color: var(--text-3);
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hint:hover { color: var(--accent); border-color: var(--accent); }

/* ── Job status ────────────────────────────────────────────── */
.job-status {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
    max-width: 800px;
    width: 100%;
}

.job-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.job-spinner { position: relative; width: 36px; height: 36px; flex-shrink: 0; }

.spinner-ring {
    width: 36px; height: 36px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.job-info { flex: 1; }

.job-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
}

.job-subtitle {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 2px;
}

.job-percent {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-steps {
    display: flex;
    gap: 1.5rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.step-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--border-2);
    transition: background 0.3s;
}

.step.active .step-dot { background: var(--accent); }
.step.done .step-dot { background: var(--green); }
.step.active { color: var(--text-2); }
.step.done { color: var(--green); }

/* ── Results header ────────────────────────────────────────── */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.results-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
}

.action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

/* ── Leads grid ────────────────────────────────────────────── */
.leads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}

/* ── Lead card ─────────────────────────────────────────────── */
.lead-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.lead-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--score-color, var(--border));
}

.lead-card:hover {
    border-color: var(--border-2);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.lead-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.lead-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.3;
    flex: 1;
}

.score-badge {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: var(--radius);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.score-high   { background: rgba(45, 212, 160, 0.15); color: var(--green); }
.score-medium { background: rgba(245, 200, 66, 0.15); color: var(--yellow); }
.score-low    { background: rgba(90, 90, 112, 0.15);  color: var(--text-3); }

.lead-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.lead-tag {
    font-size: 0.68rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lead-why {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.5;
    border-left: 2px solid var(--accent);
    padding-left: 10px;
    margin-top: 8px;
}

.lead-signals {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.signal-pill {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.signal-opportunità { background: rgba(108, 99, 255, 0.15); color: var(--accent); }
.signal-problema    { background: rgba(255, 85, 102, 0.15); color: var(--red); }
.signal-crescita    { background: rgba(45, 212, 160, 0.15); color: var(--green); }
.signal-transizione { background: rgba(255, 140, 66, 0.15); color: var(--orange); }

/* ── Filters ───────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; }

.filter-select {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 6px 10px;
    cursor: pointer;
    outline: none;
}

/* ── History list ──────────────────────────────────────────── */
.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.history-item:hover { border-color: var(--border-2); }

.history-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-done    { background: var(--green); }
.status-running { background: var(--yellow); animation: pulse 1s infinite; }
.status-failed  { background: var(--red); }
.status-pending { background: var(--text-3); }

.history-info { flex: 1; }

.history-query {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 2px;
}

.history-meta {
    font-size: 0.7rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-count {
    font-size: 0.8rem;
    color: var(--text-3);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-lg);
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.15s;
}

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

.modal-company-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.modal-sector {
    font-size: 0.75rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
}

.modal-score-bar {
    background: var(--bg-3);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-score-number {
    font-size: 2rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.modal-score-label {
    font-size: 0.72rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section-title {
    font-size: 0.68rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.modal-why {
    font-size: 0.85rem;
    color: var(--text-2);
    line-height: 1.6;
    background: var(--bg-3);
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.modal-approach {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.6;
    background: var(--bg-3);
    border-left: 3px solid var(--green);
    padding: 0.75rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.modal-contacts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.contact-label {
    font-size: 0.68rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    width: 60px;
    flex-shrink: 0;
}

.contact-value {
    color: var(--text-2);
    text-decoration: none;
}

.contact-value:hover { color: var(--accent); }

.modal-signals {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-signal {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.8rem;
}

.modal-signal-type {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-3);
}

.empty-icon {
    font-size: 2rem;
    color: var(--border-2);
    margin-bottom: 1rem;
}

/* ── New leads banner ──────────────────────────────────────── */
.new-leads-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(45, 212, 160, 0.1);
    border: 1px solid var(--green);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: var(--green);
}

.new-leads-banner button {
    background: var(--green);
    border: none;
    border-radius: var(--radius);
    color: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 4px 12px;
    cursor: pointer;
}

/* ── Footer ────────────────────────────────────────────────── */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
    padding: 1rem 2rem;
    background: var(--bg);
    z-index: 50;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-3);
}

.footer-inner strong {
    color: var(--text-2);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Search center box ─────────────────────────────────────── */
.search-center-box {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

.search-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    width: 100%;
    transition: all 0.4s ease;
}

.search-hero.has-results {
    min-height: auto;
    justify-content: flex-start;
    margin-bottom: 2rem;
}

#search-results {
    width: 100%;
    margin-top: 1.5rem;
}

.job-status {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
    width: 100%;
}

/* ── Azioni rapide modal ──────────────────────────────────────── */
.action-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 1rem;
}

.action-gen-btn {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 10px 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.action-gen-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(108, 99, 255, 0.08);
}

.action-gen-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(108, 99, 255, 0.1);
}

.message-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    flex-wrap: wrap;
    gap: 8px;
}

.message-content-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 1rem 1.25rem;
    font-size: 0.82rem;
    color: var(--text-2);
    line-height: 1.8;
    white-space: pre-line;
    min-height: 80px;
}




@media (max-width: 768px) {
    .logo-text { font-size: 1.1rem; }
    .header-inner { padding: 0 0.75rem; gap: 0.5rem; }
    .header-badge { display: none; }
    .nav-btn { padding: 4px 6px; font-size: 0.65rem; }
    .search-hero { 
        min-height: auto;
        padding: 2rem 1rem 1rem;
        justify-content: flex-start;
    }
    .search-center-box { width: 100%; max-width: 100%; }
    .search-box { flex-direction: column; gap: 8px; width: 100%; }
    .search-textarea { width: 100%; height: 80px; font-size: 14px; }
    .search-btn { width: 100%; justify-content: center; height: 48px; }
    .search-label { text-align: center; }
    .search-hints { justify-content: center; }
    .leads-grid { grid-template-columns: 1fr; }
    .main { padding: 1rem 1rem 70px 1rem; }
    .footer { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg); border-top: 1px solid var(--border); z-index: 50; padding: 5px 1rem; }
    .footer-inner { flex-direction: column; gap: 1px; text-align: center; font-size: 0.6rem; }
}
