/*
 * assets/css/app.css — Lead Hub v2
 * Bootstrap 5.3 base + custom theme
 */

/* ─── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
    --lh-primary:        #2563eb;
    --lh-primary-dark:   #1d4ed8;
    --lh-secondary:      #64748b;
    --lh-success:        #16a34a;
    --lh-warning:        #d97706;
    --lh-danger:         #dc2626;
    --lh-info:           #0891b2;

    --lh-bg:             #f1f5f9;
    --lh-card-bg:        #ffffff;
    --lh-navbar-bg:      #0f172a;
    --lh-navbar-text:    rgba(255,255,255,.87);
    --lh-border:         #e2e8f0;
    --lh-text:           #1e293b;
    --lh-text-muted:     #64748b;

    --lh-radius:         0.5rem;
    --lh-shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --lh-shadow:         0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.05);
    --lh-shadow-lg:      0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.05);

    --lh-transition:     .2s ease;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --lh-bg:         #0f172a;
        --lh-card-bg:    #1e293b;
        --lh-border:     #334155;
        --lh-text:       #f1f5f9;
        --lh-text-muted: #94a3b8;
    }
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background-color: var(--lh-bg);
    color: var(--lh-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────────── */
.lh-navbar {
    background-color: var(--lh-navbar-bg) !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.05);
}

.lh-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff !important;
    letter-spacing: -.3px;
}

.lh-navbar .nav-link {
    color: var(--lh-navbar-text) !important;
    font-size: .875rem;
    padding: .5rem .75rem !important;
    border-radius: var(--lh-radius);
    transition: background var(--lh-transition);
}

.lh-navbar .nav-link:hover,
.lh-navbar .nav-link.active {
    background-color: rgba(255,255,255,.1);
    color: #fff !important;
}

.lh-navbar .dropdown-menu {
    border: 1px solid var(--lh-border);
    border-radius: var(--lh-radius);
    box-shadow: var(--lh-shadow);
    padding: .375rem;
}

.lh-navbar .dropdown-item {
    border-radius: calc(var(--lh-radius) - 2px);
    font-size: .875rem;
    padding: .4rem .75rem;
    transition: background var(--lh-transition);
}

.lh-navbar .dropdown-item:hover {
    background-color: var(--lh-bg);
}

/* Badge notifiche */
.lh-notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: .65rem;
    min-width: 1.1rem;
    height: 1.1rem;
    line-height: 1.1rem;
    padding: 0 .25rem;
}

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.lh-card {
    background-color: var(--lh-card-bg);
    border: 1px solid var(--lh-border);
    border-radius: var(--lh-radius);
    box-shadow: var(--lh-shadow-sm);
}

.lh-card .card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--lh-border);
    font-weight: 600;
    font-size: .9rem;
    padding: .875rem 1.25rem;
}

/* Stat cards dashboard */
.lh-stat-card {
    border-radius: var(--lh-radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--lh-shadow-sm);
    transition: box-shadow var(--lh-transition), transform var(--lh-transition);
}

.lh-stat-card:hover {
    box-shadow: var(--lh-shadow);
    transform: translateY(-1px);
}

.lh-stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.lh-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.lh-stat-label {
    font-size: .8rem;
    color: var(--lh-text-muted);
    margin-top: .15rem;
}

/* ─── Tabelle (DataTables) ───────────────────────────────────────────────────── */
.lh-table-wrap {
    background: var(--lh-card-bg);
    border: 1px solid var(--lh-border);
    border-radius: var(--lh-radius);
    padding: 1rem;
    box-shadow: var(--lh-shadow-sm);
}

table.dataTable thead th {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--lh-text-muted);
    border-bottom: 2px solid var(--lh-border) !important;
    white-space: nowrap;
}

table.dataTable tbody tr:hover {
    background-color: rgba(37, 99, 235, .04);
}

/* Badges stato lead */
.badge-stato-nuova       { background-color: #dbeafe; color: #1d4ed8; }
.badge-stato-assegnata   { background-color: #fef9c3; color: #854d0e; }
.badge-stato-completata  { background-color: #dcfce7; color: #166534; }
.badge-stato-annullata   { background-color: #fee2e2; color: #991b1b; }
.badge-stato-in-lavorazione { background-color: #ede9fe; color: #5b21b6; }

/* ─── Filtri / Form ──────────────────────────────────────────────────────────── */
.lh-filters {
    background: var(--lh-card-bg);
    border: 1px solid var(--lh-border);
    border-radius: var(--lh-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--lh-shadow-sm);
}

.lh-filters label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--lh-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .25rem;
}

/* Select2 con Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection {
    border-color: var(--lh-border) !important;
    border-radius: var(--lh-radius) !important;
}

/* ─── Stato appuntamenti ──────────────────────────────────────────────────────── */
.badge-appt-nuovo        { background-color: #dbeafe; color: #1d4ed8; }
.badge-appt-preso        { background-color: #fef9c3; color: #854d0e; }
.badge-appt-ok-vendita   { background-color: #dcfce7; color: #166534; }
.badge-appt-annullato    { background-color: #fee2e2; color: #991b1b; }
.badge-appt-rimandato    { background-color: #f3e8ff; color: #6b21a8; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */
.lh-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: #0f172a;
    overflow: hidden;
}

/* LEFT PANEL */
.lh-login-hero {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 3.5rem;
    background: linear-gradient(145deg, #0f172a 0%, #0f2960 55%, #1d4ed8 100%);
    overflow: hidden;
    min-height: 100vh;
}

.lh-login-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(37,99,235,.25) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(99,102,241,.2) 0%, transparent 45%);
    pointer-events: none;
}

/* Animated grid */
.lh-hero-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
}

.lh-hero-content {
    position: relative;
    z-index: 2;
}

.lh-hero-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 3rem;
}

.lh-hero-brand-icon {
    width: 2.75rem;
    height: 2.75rem;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: .625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(59,130,246,.25);
}

.lh-hero-brand-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.3px;
}

.lh-hero-tagline {
    font-size: .8rem;
    color: rgba(255,255,255,.5);
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: .75rem;
}

.lh-hero-headline {
    font-size: 2.4rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -.5px;
    margin-bottom: 1rem;
}

.lh-hero-headline span {
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lh-hero-sub {
    font-size: 1rem;
    color: rgba(255,255,255,.55);
    line-height: 1.6;
    max-width: 34ch;
    margin-bottom: 2.5rem;
}

/* Floating stat cards */
.lh-hero-stats {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.lh-hero-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: .75rem;
    padding: .875rem 1.25rem;
    backdrop-filter: blur(8px);
    transition: background .2s, transform .2s;
    animation: floatIn .6s ease both;
}

.lh-hero-stat:nth-child(1) { animation-delay: .1s; }
.lh-hero-stat:nth-child(2) { animation-delay: .2s; }
.lh-hero-stat:nth-child(3) { animation-delay: .3s; }

@keyframes floatIn {
    from { opacity: 0; transform: translateX(-16px); }
    to   { opacity: 1; transform: translateX(0); }
}

.lh-hero-stat:hover {
    background: rgba(255,255,255,.1);
    transform: translateX(4px);
}

.lh-hero-stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.lh-hero-stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.lh-hero-stat-lbl {
    font-size: .75rem;
    color: rgba(255,255,255,.5);
    margin-top: .15rem;
}

/* Glowing orbs */
.lh-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    opacity: .35;
    animation: pulse 6s ease-in-out infinite alternate;
}

.lh-orb-1 {
    width: 400px; height: 400px;
    background: #3b82f6;
    top: -100px; right: -100px;
    animation-delay: 0s;
}

.lh-orb-2 {
    width: 300px; height: 300px;
    background: #8b5cf6;
    bottom: -80px; left: -80px;
    animation-delay: 3s;
}

@keyframes pulse {
    from { opacity: .25; transform: scale(1); }
    to   { opacity: .45; transform: scale(1.08); }
}

/* RIGHT PANEL */
.lh-login-panel {
    width: 480px;
    min-width: 380px;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 2.75rem;
    position: relative;
    animation: slideInRight .5s ease both;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

.lh-login-panel-header {
    margin-bottom: 2rem;
}

.lh-login-panel-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -.4px;
    margin-bottom: .35rem;
}

.lh-login-panel-sub {
    font-size: .9rem;
    color: #64748b;
}

/* Input groups */
.lh-field {
    margin-bottom: 1.25rem;
}

.lh-field label {
    display: block;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #475569;
    margin-bottom: .45rem;
}

.lh-input-wrap {
    position: relative;
}

.lh-input-icon {
    position: absolute;
    left: .9rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: .85rem;
    pointer-events: none;
    transition: color .2s;
    z-index: 1;
}

.lh-input-wrap:focus-within .lh-input-icon {
    color: var(--lh-primary);
}

.lh-input {
    width: 100%;
    padding: .75rem .875rem .75rem 2.5rem;
    font-size: .925rem;
    border: 1.5px solid #e2e8f0;
    border-radius: .5rem;
    background: #f8fafc;
    color: #0f172a;
    transition: border-color .2s, box-shadow .2s, background .2s;
    outline: none;
    -webkit-appearance: none;
}

.lh-input:focus {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.lh-input::placeholder { color: #cbd5e1; }

.lh-input-toggle {
    position: absolute;
    right: .75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    padding: .25rem;
    cursor: pointer;
    font-size: .85rem;
    transition: color .2s;
    line-height: 1;
}

.lh-input-toggle:hover { color: #475569; }

/* Submit button */
.lh-btn-login {
    width: 100%;
    padding: .825rem 1rem;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
    border-radius: .5rem;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: transform .15s, box-shadow .15s, filter .15s;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.lh-btn-login:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37,99,235,.45);
}

.lh-btn-login:active { transform: translateY(0); }

/* SSO button */
.lh-btn-sso {
    width: 100%;
    padding: .75rem 1rem;
    background: #f8fafc;
    color: #334155;
    border: 1.5px solid #e2e8f0;
    border-radius: .5rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .15s;
}

.lh-btn-sso:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
    transform: translateY(-1px);
    text-decoration: none;
}

/* Divider */
.lh-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0;
    color: #94a3b8;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.lh-divider::before,
.lh-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

/* Alert error */
.lh-login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 3px solid #ef4444;
    border-radius: .5rem;
    padding: .75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: .875rem;
    color: #991b1b;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Footer note */
.lh-login-footer {
    margin-top: 2rem;
    font-size: .75rem;
    color: #94a3b8;
    text-align: center;
    line-height: 1.5;
}

/* Responsive — mobile */
@media (max-width: 768px) {
    .lh-login-wrapper { flex-direction: column; }
    .lh-login-hero {
        min-height: auto;
        padding: 2rem 1.5rem 1.75rem;
        flex-shrink: 0;
    }
    .lh-hero-headline { font-size: 1.7rem; }
    .lh-hero-sub { display: none; }
    .lh-hero-stats { flex-direction: row; flex-wrap: wrap; }
    .lh-hero-stat { flex: 1; min-width: 140px; }
    .lh-orb { display: none; }
    .lh-login-panel {
        width: 100%;
        min-width: 0;
        padding: 2rem 1.5rem 2.5rem;
    }
}

/* Legacy selector kept for safety */
.lh-login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255,255,255,.97);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    box-shadow: var(--lh-shadow-lg);
}

.lh-login-logo {
    font-size: 2rem;
    font-weight: 800;
    color: var(--lh-primary);
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: -.5px;
}

/* ─── Page header ───────────────────────────────────────────────────────────── */
.lh-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.lh-page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--lh-text);
    margin: 0;
}

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--lh-text-muted) !important; }
.fs-xs { font-size: .75rem; }
.fs-sm { font-size: .875rem; }

/* Pulsanti azione compatti nelle tabelle */
.btn-action {
    padding: .2rem .5rem;
    font-size: .78rem;
    border-radius: .375rem;
}

/* Timeline commenti in visualizza_lead */
.lh-timeline {
    position: relative;
    padding-left: 2rem;
}

/* ─── Dettaglio appuntamento / pagine dettaglio ───────────────────────────────── */
.lh-detail-grid {
    display: grid;
    gap: 1rem 2rem;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.lh-detail-item {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.lh-detail-item dt,
.lh-detail-item .lh-detail-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--lh-text-muted);
    margin: 0;
}

.lh-detail-item dd,
.lh-detail-item .lh-detail-value {
    font-size: .95rem;
    line-height: 1.5;
    margin: 0;
    word-break: break-word;
}

.lh-card .card-body {
    padding: 1.25rem 1.5rem;
}

.lh-detail-text {
    font-size: .95rem;
    line-height: 1.65;
    color: var(--lh-text);
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 65ch;
}

.lh-detail-text + .lh-detail-text {
    margin-top: 1rem;
}

.lh-timeline::before {
    content: '';
    position: absolute;
    left: .6rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--lh-border);
}

.lh-timeline-item {
    position: relative;
    margin-bottom: 1.25rem;
}

.lh-timeline-dot {
    position: absolute;
    left: -1.65rem;
    top: .25rem;
    width: .8rem;
    height: .8rem;
    border-radius: 50%;
    background: var(--lh-primary);
    border: 2px solid var(--lh-card-bg);
}

/* ─── Sidebar Lead da gestire ────────────────────────────────────────────────── */
.lh-main-wrapper {
    display: flex;
    flex: 1;
    position: relative;
    min-height: 0;
}

.lh-main-content {
    flex: 1;
    min-width: 0;
}

.lh-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--lh-navbar-bg);
    color: var(--lh-navbar-text);
    border-left: 1px solid rgba(255,255,255,.1);
    display: flex;
    flex-direction: column;
    transition: transform .25s ease, min-width .25s ease, opacity .25s ease;
    box-shadow: -4px 0 12px rgba(0,0,0,.15);
}

.lh-sidebar-collapsed {
    transform: translateX(100%);
    min-width: 0;
    width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.lh-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
}

.lh-sidebar-filter {
    padding: .6rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.lh-sidebar-filter .form-select {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.2);
    color: #fff;
    font-size: .8rem;
}

.lh-sidebar-filter .form-select option {
    background: var(--lh-navbar-bg);
    color: #fff;
}

.lh-sidebar-empty {
    color: rgba(255,255,255,.6) !important;
}

.lh-sidebar-title {
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
}

.lh-sidebar-toggle {
    padding: .25rem .5rem;
    font-size: .8rem;
}

.lh-sidebar-body {
    padding: .75rem;
    overflow-y: auto;
    flex: 1;
}

.lh-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .85rem;
    margin-bottom: .35rem;
    border-radius: var(--lh-radius);
    color: inherit;
    text-decoration: none;
    transition: background .15s ease;
}

.lh-sidebar-item:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.lh-sidebar-item-label {
    font-size: .875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: .5rem;
}

/* Linguetta laterale destra quando sidebar è compressa */
.lh-sidebar-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    padding: 1rem .5rem;
    background: var(--lh-navbar-bg);
    color: var(--lh-navbar-text);
    border: none;
    border-left: 1px solid rgba(255,255,255,.15);
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 12px rgba(0,0,0,.15);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    z-index: 999;
    transition: background .2s ease, width .2s ease;
}

.lh-sidebar-tab:hover {
    background: rgba(15, 23, 42, .95);
    width: 44px;
}

.lh-sidebar-tab i {
    font-size: 1.25rem;
}

.lh-sidebar-tab .lh-sidebar-tab-badge {
    background: var(--lh-primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 600;
    min-width: 1.25rem;
    height: 1.25rem;
    line-height: 1.25rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lh-sidebar:not(.lh-sidebar-collapsed) ~ .lh-sidebar-tab {
    display: none;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.lh-footer {
    background: var(--lh-navbar-bg);
    color: rgba(255,255,255,.5);
    font-size: .8rem;
    padding: .875rem 0;
    margin-top: auto;
}
