/* ============================================================
 * LEGALGO DASHBOARD – CSS
 * ============================================================ */


/* === Reset & base === */
.lgd-wrap, .lgd-wrap * { box-sizing: border-box; }

.lgd-wrap {
    display: flex;
    min-height: 100vh;
    background: #f4f5f7;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #1a1a2e;
    line-height: 1.5;
}

/* === Sidebar === */
.lgd-sidebar {
    width: 240px;
    background: #1b4f54;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.lgd-sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.lgd-logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 16px;
}

.lgd-user-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.lgd-user-piano {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
}

.lgd-piano-start  { background: #3b82f6; }
.lgd-piano-pro    { background: #f59e0b; color: #1a1a2e; }
.lgd-piano-elite  { background: #ef4444; }

/* Nav */
.lgd-nav {
    flex: 1;
    padding: 12px 0;
}

.lgd-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.lgd-nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

.lgd-nav-item.is-active {
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-right: 3px solid #fff;
}

.lgd-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.lgd-icon svg {
    width: 100%;
    height: 100%;
}

.lgd-badge {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: auto;
}

.lgd-sidebar-footer {
	margin-top: 50px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 8px 0;
}

.lgd-logout { color: rgba(255,255,255,0.4) !important; }
.lgd-logout:hover { color: rgba(255,255,255,0.8) !important; }

/* === Main content === */
.lgd-main {
    flex: 1;
    min-width: 0;
    padding: 32px;
}

.lgd-content {
    max-width: 1100px;
}

/* === Page header === */
.lgd-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.lgd-page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
}

.lgd-page-sub {
    font-size: 14px;
    color: #666;
    margin: 4px 0 0;
}

.lgd-count {
    font-weight: 400;
    color: #888;
}

/* === Cards === */
.lgd-card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.lgd-card-flush { padding: 0; }
.lgd-card-flush .lgd-table { margin: 0; }
.lgd-card-flush .lgd-table thead th:first-child { padding-left: 24px; }
.lgd-card-flush .lgd-table tbody td:first-child { padding-left: 24px; }

.lgd-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.lgd-card-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 16px;
    color: #1a1a2e;
}

.lgd-card-header .lgd-card-title { margin-bottom: 0; }

.lgd-card-link {
    font-size: 13px;
    color: #1b4f54;
    text-decoration: none;
    font-weight: 500;
}

.lgd-card-sub {
    font-size: 13px;
    color: #888;
    margin: -8px 0 16px;
}

/* === Stat cards === */
.lgd-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.lgd-stats-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.lgd-stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.lgd-stat-highlight {
    border-left: 3px solid #1b4f54;
}

.lgd-stat-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
}

.lgd-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.lgd-stat-trend {
    font-size: 13px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.lgd-stat-trend.is-up { color: #16a34a; background: #dcfce7; }
.lgd-stat-trend.is-down { color: #dc2626; background: #fee2e2; }

.lgd-stat-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: #1b4f54;
    text-decoration: none;
    font-weight: 500;
}

/* === Chart === */
.lgd-chart-card canvas {
    width: 100% !important;
    max-height: 200px;
}

/* === Tables === */
.lgd-table {
    width: 100%;
    border-collapse: collapse;
}

.lgd-table thead th {
    text-align: center;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    padding: 12px 12px;
    border-bottom: 1px solid #eee;
}

.lgd-table tbody td {
    padding: 12px 12px;
    border-bottom: 1px solid #f4f4f6;
    font-size: 13px;
    vertical-align: middle;
}

.lgd-table tbody tr:last-child td { border-bottom: none; }

.lgd-row-new td { background: #fefce8; }

.lgd-date-main { display: block; }
.lgd-date-time { display: block; font-size: 11px; color: #aaa; }
.lgd-sub { display: block; font-size: 12px; color: #888; margin-top: 2px; }

/* === Status badges === */
.lgd-stato {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.lgd-stato-nuovo      { background: #dbeafe; color: #1d4ed8; }
.lgd-stato-contattato  { background: #dcfce7; color: #16a34a; }
.lgd-stato-archiviato  { background: #f3f4f6; color: #6b7280; }
.lgd-stato-chiuso    { background: #f3f4f6; color: #6b7280; }

.lgd-priority {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
}

.lgd-priority-alta  { background: #fee2e2; color: #dc2626; }
.lgd-priority-media { background: #fef3c7; color: #d97706; }
.lgd-priority-bassa { background: #dcfce7; color: #16a34a; }
.lgd-priority-none  { background: #f3f4f6; color: #9ca3af; }

.lgd-source {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    background: #fce7f3;
    color: #be185d;
}

.lgd-source-landing_pro { background: #dbeafe; color: #1d4ed8; }
.lgd-source-elite       { background: #fce7f3; color: #be185d; }

/* === Buttons === */
.lgd-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.lgd-btn-primary {
    background: #1b4f54;
    color: #fff;
}
.lgd-btn-primary:hover { background: #163f43; }

.lgd-btn-secondary {
    background: #f4f5f7;
    color: #1a1a2e;
    border: 1px solid #ddd;
}
.lgd-btn-secondary:hover { background: #e8e9eb; }

.lgd-btn-ghost {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
}
.lgd-btn-ghost:hover { background: #f9f9f9; }

.lgd-btn-block { width: 100%; justify-content: center; }
.lgd-btn-sm { padding: 6px 12px; font-size: 12px; }

/* === Filters === */
.lgd-filters {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.lgd-filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.lgd-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.lgd-filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lgd-filter-group input,
.lgd-filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

.lgd-filter-actions {
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

/* === Lead detail === */
.lgd-lead-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

.lgd-lead-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.lgd-lead-name {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.lgd-lead-date {
    font-size: 13px;
    color: #888;
}

.lgd-lead-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lgd-lead-text {
    font-size: 14px;
    line-height: 1.7;
    color: #333;
    background: #f9f9fb;
    padding: 16px;
    border-radius: 8px;
    margin: 0;
}

.lgd-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
    text-decoration: none;
    font-weight: 500;
}
.lgd-back:hover { color: #1b4f54; }

/* Q&A */
.lgd-qa-list { display: flex; flex-direction: column; gap: 12px; }

.lgd-qa-item {
    padding: 14px;
    background: #f9f9fb;
    border-left: 3px solid #1b4f54;
    border-radius: 0 8px 8px 0;
}

.lgd-qa-q {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.lgd-qa-a {
    font-size: 13px;
    color: #555;
}

/* Pre-analisi */
.lgd-preanalisi {
    font-size: 14px;
    line-height: 1.7;
    color: #333;
    background: #f0fdf4;
    padding: 16px;
    border-radius: 8px;
    border-left: 3px solid #16a34a;
}

/* Contact list */
.lgd-contact-list { display: flex; flex-direction: column; gap: 12px; }

.lgd-contact-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lgd-contact-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.lgd-contact-item a {
    color: #1b4f54;
    text-decoration: none;
    font-weight: 500;
}

/* Actions */
.lgd-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* === Piano === */
.lgd-piano-active {
    border-left-width: 4px;
    border-left-style: solid;
}

.lgd-piano-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.lgd-piano-badge {
    display: inline-block;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lgd-piano-prezzo {
    font-size: 18px;
    font-weight: 700;
    margin-left: 12px;
    color: #1a1a2e;
}

.lgd-check-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lgd-check-list li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
    font-size: 13px;
}

.lgd-check-yes::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #16a34a;
    font-weight: 700;
}

.lgd-check-no::before {
    content: '✗';
    position: absolute;
    left: 0;
    color: #dc2626;
    font-weight: 700;
}

.lgd-table-compare td,
.lgd-table-compare th {
    text-align: center;
}

.lgd-table-compare td:first-child,
.lgd-table-compare th:first-child {
    text-align: left;
}

/* === API settings === */
.lgd-api-key-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lgd-api-key {
    background: #f4f5f7;
    padding: 10px 16px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    word-break: break-all;
    flex: 1;
}

.lgd-note {
    font-size: 12px;
    color: #999;
    margin-left: 8px;
}

.lgd-code-block {
    background: #1b4f54;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    overflow-x: auto;
    white-space: pre-wrap;
    line-height: 1.6;
    margin: 12px 0;
}

.lgd-domini-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.lgd-domain-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lgd-domain-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.lgd-domini-actions {
    display: flex;
    gap: 8px;
}

.lgd-table-sm td, .lgd-table-sm th {
    padding: 8px;
    font-size: 12px;
}

.lgd-table-sm code {
    background: #f4f5f7;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* === Pagination === */
.lgd-pagination {
    display: flex;
    gap: 4px;
    margin-top: 16px;
    justify-content: center;
}

.lgd-page-link {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    color: #666;
}

.lgd-page-link.is-active {
    background: #1b4f54;
    color: #fff;
    border-color: #1b4f54;
}

/* === Empty state === */
.lgd-empty {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
    font-size: 14px;
}

/* === Auth screens === */
.lgd-auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f4f5f7;
    padding: 20px;
}

.lgd-auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    text-align: center;
}

.lgd-auth-logo {
    font-size: 24px;
    font-weight: 700;
    color: #1b4f54;
    margin-bottom: 20px;
}

.lgd-auth-card h1 {
    font-size: 20px;
    margin: 0 0 8px;
}

.lgd-auth-card p {
    color: #666;
    font-size: 14px;
}

.lgd-auth-card form {
    margin-top: 20px;
    text-align: left;
}

.lgd-auth-card label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.lgd-auth-card input[type="text"],
.lgd-auth-card input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
}

.lgd-auth-card input[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #1b4f54;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.lgd-auth-card input[type="submit"]:hover {
    background: #163f43;
}

.lgd-auth-note {
    margin-top: 16px;
    font-size: 13px;
}

.lgd-auth-note a {
    color: #1b4f54;
    text-decoration: none;
}

/* === Responsive === */
@media (max-width: 900px) {
    .lgd-wrap { flex-direction: column; }

    .lgd-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .lgd-sidebar-header {
        padding: 12px 16px;
        border-bottom: none;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .lgd-logo { margin-bottom: 0; }

    .lgd-nav {
        display: flex;
        flex-wrap: wrap;
        padding: 4px 8px;
        gap: 0;
    }

    .lgd-nav-item {
        padding: 8px 14px;
    }

    .lgd-nav-item.is-active { border-right: none; border-bottom: 2px solid #fff; }

    .lgd-sidebar-footer { border-top: none; padding: 4px 8px; }

    .lgd-main { padding: 20px 16px; }

    .lgd-stats-grid { grid-template-columns: 1fr; }

    .lgd-lead-layout {
        grid-template-columns: 1fr;
    }

    .lgd-filter-row { flex-direction: column; }
}

/* === Profilo form === */
.lgd-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.lgd-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    grid-column: span 2;
}

.lgd-form-half  { grid-column: span 1; }
.lgd-form-quarter { grid-column: span 1; }

@media (min-width: 600px) {
    .lgd-form-grid {
        grid-template-columns: 1fr 1fr 1fr 1fr;
    }
    .lgd-form-group { grid-column: span 4; }
    .lgd-form-half  { grid-column: span 2; }
    .lgd-form-quarter { grid-column: span 1; }
}

.lgd-form-group label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lgd-form-group input[type="text"],
.lgd-form-group input[type="url"],
.lgd-form-group textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s;
}

.lgd-form-group input:focus,
.lgd-form-group textarea:focus {
    border-color: #1b4f54;
    outline: none;
}

.lgd-form-group input[type="file"] {
    font-size: 13px;
    padding: 6px 0;
}

.lgd-current-value {
    font-size: 14px;
    color: #333;
    padding: 8px 12px;
    background: #f9f9fb;
    border-radius: 6px;
    border-left: 3px solid #1b4f54;
    min-height: 20px;
}

.lgd-current-text {
    white-space: pre-wrap;
    line-height: 1.6;
}

.lgd-field-note {
    font-size: 11px;
    color: #999;
}

/* Foto */
.lgd-current-photo {
    margin-bottom: 4px;
}

.lgd-current-photo img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #eee;
}

.lgd-no-photo {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    background: #f4f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #aaa;
    text-align: center;
    border: 2px dashed #ddd;
}

/* Color picker */
.lgd-current-color {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
}

.lgd-color-dot {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #ddd;
}

.lgd-color-picker {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.lgd-color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.15s;
}

.lgd-color-option:hover {
    background: #f9f9fb;
}

.lgd-color-option.is-active,
.lgd-color-option:has(input:checked) {
    border-color: #1b4f54;
    background: #f0f9fa;
}

.lgd-color-option input[type="radio"] {
    display: none;
}

.lgd-color-swatch {
    display: block;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.1);
}

.lgd-color-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
}

/* Submit */
.lgd-form-submit {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
    margin-bottom: 40px;
}

/* Alerts */
.lgd-alert {
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
}

.lgd-alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.lgd-alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Char counter */
.lgd-char-count {
    transition: color 0.15s;
}

.lgd-char-count.is-near { color: #d97706; }
.lgd-char-count.is-over { color: #dc2626; font-weight: 600; }

@media (max-width: 900px) {
    .lgd-form-grid { grid-template-columns: 1fr; }
    .lgd-form-group,
    .lgd-form-half,
    .lgd-form-quarter { grid-column: span 1; }
    .lgd-form-submit { flex-direction: column; align-items: flex-start; }
    .lgd-color-picker { gap: 8px; }
}
