/* =============================================
   CSS Variables
   ============================================= */
:root {
    --primary:          #2F80ED;
    --primary-dark:     #1F5FAF;
    --primary-gradient: linear-gradient(135deg, #2F80ED 0%, #1F5FAF 100%);
    --accent:           #1F5FAF;

    --white:    #FFFFFF;
    --success:  #22c55e;
    --danger:   #ef4444;
    --warning:  #f59e0b;
    --info:     #0ea5e9;

    --bg-page:  #F7FAFC;
    --bg-card:  #FFFFFF;
    --bg-muted: #f8f9fb;

    --text-primary:   #2D3748;
    --text-secondary: #718096;
    --text-muted:     #A0AEC0;

    --border:       #E2E8F0;
    --border-focus: var(--primary);

    --radius-sm: 6px;
    --radius:    12px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:    0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 30px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.05);

    --transition: all 0.2s ease;
}

/* =============================================
   Reset & Base
   ============================================= */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

h1 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0;
}

.subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* =============================================
   Page wrapper
   ============================================= */
#content {
    padding: 28px 24px 56px;
    padding-top: calc(64px + 28px);
}

/* =============================================
   Navbar
   ============================================= */
.navbar .nav-link:hover,
.navbar .nav-link:focus {
    background: #EBF4FF;
    color: var(--primary) !important;
}

/* =============================================
   Filter Panel
   ============================================= */
.filters-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    margin-bottom: 14px;
}

.filters-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-secondary);
}

.filter-row {
    display: grid;
    grid-template-columns: 2.5fr 1fr 2fr auto;
    gap: 10px;
    align-items: end;
    background: var(--bg-muted);
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    transition: var(--transition);
}

.filter-row:hover {
    border-color: var(--primary);
    background: #fafbff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.06);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

select,
input[type="text"],
input[type="number"],
input[type="password"] {
    padding: 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    transition: var(--transition);
    width: 100%;
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

.value-input-group {
    display: flex;
    align-items: stretch;
}

/* When a unit is present, reshape the input to connect with the addon */
.value-input-group.has-unit input {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
    width: auto; /* override the global width: 100% */
}

/* Sync focus ring colour across input + addon */
.value-input-group.has-unit input:focus + .unit-addon {
    border-color: var(--primary);
}

.unit-addon {
    display: none;
    padding: 0 10px;
    border: 1.5px solid var(--border);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: #f8f9fb;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    align-items: center;
}

.value-input-group.has-unit .unit-addon {
    display: flex;
}

/* =============================================
   Action bar
   ============================================= */
.action-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.action-bar .btn {
    flex: 1;
    padding: 9px 20px;
    font-weight: 600;
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

/* =============================================
   Results header
   ============================================= */
.results-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.results-count {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.results-count strong {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.95rem;
}

/* =============================================
   Results table
   ============================================= */
.results-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.results-wrapper .table {
    margin-bottom: 0;
    font-size: 13.5px;
}

.results-wrapper .table thead th {
    background: #1e2235;
    color: #b8c0d8;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 11px 14px;
    border: none;
    white-space: nowrap;
}

.results-wrapper .table tbody tr {
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.12s;
}

.results-wrapper .table tbody tr:last-child {
    border-bottom: none;
}

.results-wrapper .table tbody tr:hover {
    background: #f8f7ff;
}

.results-wrapper .table tbody td {
    padding: 9px 14px;
    vertical-align: middle;
    border: none;
}

/* =============================================
   Product table cells
   ============================================= */

/* Thumbnail */
.product-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    background: #f8f9fb;
    padding: 5px;
    border: 1px solid var(--border);
    display: block;
}

/* Merged name + company + version cell */
.product-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
}
.product-cell .name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.3;
}
.product-cell .company {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.product-cell .version {
    font-size: 11px;
    color: var(--text-muted);
}

/* Property value chip */
.prop-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    background: #eef0ff;
    color: #3730a3;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.prop-chip .unit {
    font-size: 10px;
    font-weight: 400;
    color: #6366f1;
    margin-left: 1px;
}

/* Empty value placeholder */
.no-data-dash {
    color: var(--text-muted);
    font-size: 13px;
}

/* Category / application badge */
.result-badge {
    display: inline-block;
    background: #dcfce7;
    color: #14532d;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin: 1px 2px 1px 0;
    white-space: nowrap;
    letter-spacing: 0.1px;
}

/* Actions cell */
.table-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

/* Comparison checkbox */
.compare-checkbox {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: 4px;
    margin: 0;
}

/* =============================================
   Comparison table
   ============================================= */
.best-value  { background-color: #dcfce7 !important; }
.worst-value { background-color: #fee2e2 !important; }

.property-label {
    font-weight: 600;
    font-size: medium;
    white-space: nowrap;
}

.property-unit {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}

.no-data {
    color: var(--text-muted);
    font-size: 13px;
}

.product-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
    min-width: 120px;
}

.remove-product-btn {
    align-self: flex-end;
    margin-bottom: 4px;
}

/* =============================================
   States
   ============================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 24px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state .state-icon {
    font-size: 2.4rem;
    opacity: 0.35;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.88rem;
    max-width: 260px;
    line-height: 1.5;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 24px;
    color: var(--primary);
    text-align: center;
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(102, 126, 234, 0.18);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin-bottom: 14px;
}

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

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--danger);
    text-align: center;
}

.error-icon { font-size: 2.4rem; margin-bottom: 10px; }

/* =============================================
   Modals
   ============================================= */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-footer {
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* Detail modal meta fields */
.product-meta-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.product-meta-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Comparison modal */
.comparison-table {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 13.5px;
}

.comparison-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
    border-color: var(--border);
}

.comparison-table td {
    padding: 10px 16px;
    border-color: var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}

.comparison-table tbody tr:hover {
    background: #f5f8ff;
}

.comparison-table .property-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    background: var(--bg-muted);
}

.comparison-scroll {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* =============================================
   Guide (guida_it)
   ============================================= */
.section {
    margin-bottom: 3.5rem;
}

.section_title {
    padding-bottom: 10px;
    color: var(--text-primary);
}

.step-card {
    background: var(--bg-muted);
    border-left: 4px solid var(--primary);
    padding: 1.2rem 1.4rem;
    margin-bottom: 1.2rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.step-card:hover {
    background: #f5f6ff;
    border-left-color: var(--accent);
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    margin-right: 8px;
    flex-shrink: 0;
    vertical-align: middle;
}

.tip-box {
    background: #e8f7fb;
    border-left: 4px solid var(--info);
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-sm);
    margin: 1.5rem 0;
    font-size: 0.88rem;
}

.warning-box {
    background: #fffbeb;
    border-left: 4px solid var(--warning);
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-sm);
    margin: 1.5rem 0;
    font-size: 0.88rem;
}

.code-block {
    background: #1e2235;
    color: #cdd5f0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 12.5px;
    line-height: 1.7;
    margin: 1rem 0;
    overflow-x: auto;
}

.code-block pre { margin: 0; color: inherit; }

/* Guide sidebar TOC */
.sidebar {
    position: sticky;
    top: 80px;
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-top: 30px;
}

.sidebar .nav-link {
    font-size: 0.83rem;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}

.sidebar .nav-link:hover {
    background: var(--bg-muted);
    color: var(--primary);
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .filter-row {
        grid-template-columns: 1fr;
    }
    .action-bar {
        flex-direction: column;
    }
    #content {
        padding: 16px 14px 40px;
    }
}
