/* New Product Card Layout - Clean Structure */

/* Product Comparison Header */
.product-comparison-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    padding: 20px;
    background: #ffffff;
    border-bottom: 2px solid #f3f4f6;
    align-items: center;
}

/* Single product layout (no comparison) */
.product-comparison-header.single-product {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 20px 20px 16px 20px;
}

.product-comparison-header.single-product .product-side {
    text-align: left;
}

.product-side {
    text-align: center;
}

.product-type-label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 8px;
    font-weight: 500;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
    line-height: 1.4;
    cursor: pointer;
}

.product-name:hover {
    color: #4f46e5;
}

/* Editable product name styling */
.product-name.editable-field {
    cursor: text;
    transition: all 0.15s ease;
    position: relative;
    border-bottom: 1px solid transparent;
    padding: 4px 8px;
    border-radius: 4px;
    background: #fbfcfd;
    border: 1px solid #f1f3f5;
}

/* Desktop hover states */
@media (hover: hover) and (pointer: fine) {
    .product-name.editable-field:hover {
        border-bottom: 1px dotted #9ca3af;
        border-color: #e5e7eb;
        background: #f3f4f6;
    }

    .product-name.editable-field:hover::after {
        content: '';
        position: absolute;
        right: -18px;
        top: 50%;
        transform: translateY(-50%);
        width: 12px;
        height: 12px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'%3E%3C/path%3E%3Cpath d='M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'%3E%3C/path%3E%3C/svg%3E");
        background-size: 12px 12px;
        background-repeat: no-repeat;
        opacity: 0;
        animation: fadeIn 0.2s ease-in-out forwards;
    }
}

/* Mobile/touch devices - always show edit indicators */
@media (hover: none) or (pointer: coarse) {
    .product-name.editable-field::after {
        content: '';
        position: absolute;
        right: -18px;
        top: 50%;
        transform: translateY(-50%);
        width: 14px;
        height: 14px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'%3E%3C/path%3E%3Cpath d='M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'%3E%3C/path%3E%3C/svg%3E");
        background-size: 14px 14px;
        background-repeat: no-repeat;
        opacity: 0.6;
    }
    
    .product-name.editable-field {
        min-height: 44px; /* Touch-friendly size */
        padding: 8px 24px 8px 8px; /* Extra right padding for icon */
        display: flex;
        align-items: center;
    }
}

.product-name.editable-field:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
    border-color: #4f46e5;
    background: white;
}

.product-name.editable-field:focus::after {
    display: none;
}

.product-brand {
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
}

.vs-divider {
    width: 40px;
    height: 40px;
    background: #4f46e5;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Modern Category Section - Fintech Style */
.category-section-modern {
    padding: 16px 20px;
    background: linear-gradient(to bottom, #fafbfc, #f9fafb);
    border-bottom: 1px solid #e5e7eb;
}

.category-main {
    width: 100%;
}

.category-label-modern {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Subtle FSA Checkbox */
.fsa-checkbox-subtle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    user-select: none;
}

.fsa-checkbox-subtle input {
    display: none;
}

.checkbox-custom {
    width: 14px;
    height: 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 3px;
    background: white;
    position: relative;
    transition: all 0.15s ease;
}

.fsa-checkbox-subtle input:checked + .checkbox-custom {
    background: #10b981;
    border-color: #10b981;
}

.fsa-checkbox-subtle input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    color: #6b7280;
    transition: color 0.15s ease;
}

.fsa-checkbox-subtle:hover .checkbox-label {
    color: #374151;
}

.category-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.category-display:hover {
    border-color: #4f46e5;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.1);
}

.category-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-display:hover .category-text {
    color: #4f46e5;
}

/* FSA Badge */
.fsa-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
}

.fsa-badge.eligible {
    background: #dcfce7;
    color: #14532d;
}

.fsa-badge.not-eligible {
    background: #fee2e2;
    color: #7f1d1d;
}

.edit-indicator {
    color: #9ca3af;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.category-display:hover .edit-indicator {
    color: #4f46e5;
}


/* Compact mode for non-FSA eligible items */
.product-card:not(.fsa-eligible) .category-section-modern {
    padding: 12px 20px;
}

/* Stats Table */
.stats-table {
    padding: 20px;
    background: #ffffff;
}

.stats-header {
    margin-bottom: 12px;
}

.table-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Modern Table Styles */
.comparison-table,
.calculation-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

/* Table Headers */
.comparison-table thead,
.calculation-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e5e7eb;
}

.comparison-table th,
.calculation-table th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    text-align: left;
}

.metric-header,
.calc-header {
    width: 40%;
    text-align: left;
}

.value-header,
.amount-header {
    width: 30%;
    text-align: center;
}

.formula-header {
    width: 30%;
    text-align: center;
}

/* Table Body */
.comparison-table tbody tr,
.calculation-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
}

.comparison-table tbody tr:last-child,
.calculation-table tbody tr:last-child {
    border-bottom: none;
}

.comparison-table td,
.calculation-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: #111827;
}

.metric-label,
.calc-label {
    font-weight: 500;
    color: #6b7280;
    text-align: left;
}

.value-cell,
.amount-cell,
.formula-cell {
    text-align: center;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.value-cell.editable {
    cursor: text;
    transition: all 0.15s ease;
    position: relative;
    border-bottom: 1px solid transparent;
    background: #fbfcfd; /* Subtle always-visible background */
    border: 1px solid #f1f3f5; /* Light border to show it's interactive */
}

/* Desktop hover states */
@media (hover: hover) and (pointer: fine) {
    .value-cell.editable:hover {
        background: #f3f4f6;
        border-bottom: 1px dotted #9ca3af;
        border-color: #e5e7eb;
    }

    .value-cell.editable:hover::after {
        content: '';
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 12px;
        height: 12px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'%3E%3C/path%3E%3Cpath d='M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'%3E%3C/path%3E%3C/svg%3E");
        background-size: 12px 12px;
        background-repeat: no-repeat;
        opacity: 0;
        animation: fadeIn 0.2s ease-in-out forwards;
    }
}

/* Mobile/touch devices - always show edit indicators */
@media (hover: none) or (pointer: coarse) {
    .value-cell.editable::after {
        content: '';
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
        width: 14px;
        height: 14px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'%3E%3C/path%3E%3Cpath d='M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'%3E%3C/path%3E%3C/svg%3E");
        background-size: 14px 14px;
        background-repeat: no-repeat;
        opacity: 0.6;
    }
    
    .value-cell.editable {
        min-height: 44px; /* Touch-friendly size */
        padding: 12px 24px 12px 16px; /* Extra right padding for icon */
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.value-cell.editable:focus {
    background: white;
    outline: 2px solid #4f46e5;
    outline-offset: -2px;
    border-color: #4f46e5;
}

.value-cell.editable:focus::after {
    display: none;
}

.total-row {
    background: #f8f9fa;
    border-top: 2px solid #e5e7eb;
}

.premium-amount {
    background: #f0fdf4;
    color: #15803d;
    font-weight: 700;
    font-size: 16px;
}

/* Edit Helper Tooltip */
.edit-helper {
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    pointer-events: none;
    white-space: nowrap;
    animation: fadeInUp 0.2s ease-out;
}

.edit-helper kbd {
    background: #374151;
    color: #e5e7eb;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-family: monospace;
    border: 1px solid #4b5563;
}

/* Mobile responsive edit helper */
@media (max-width: 768px) {
    .edit-helper {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: auto !important;
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 8px;
        max-width: 280px;
        text-align: center;
    }
    
    .edit-helper kbd {
        padding: 4px 8px;
        font-size: 12px;
        margin: 0 2px;
    }
}

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


/* FSA Control Section */
.fsa-control-section {
    padding: 16px 20px;
    background: #fafbfc;
    border-top: 1px solid #e5e7eb;
}

.fsa-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    justify-content: center;
}

.fsa-checkbox input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    accent-color: #10b981;
}

.fsa-text {
    margin-right: 16px;
}

.fsa-amount {
    font-size: 18px;
    font-weight: 700;
    color: #15803d;
    background: #f0fdf4;
    padding: 6px 12px;
    border-radius: 6px;
    margin-left: 8px;
}

/* Non-FSA Message Section */
.non-fsa-message {
    padding: 20px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.non-fsa-content {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    text-align: left;
}

.non-fsa-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.non-fsa-text h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #475569;
}

.non-fsa-text p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .product-comparison-header {
        grid-template-columns: 1fr;
        gap: 16px;
        text-align: center;
    }
    
    .vs-divider {
        margin: 0 auto;
    }
    
    .stats-grid {
        font-size: 12px;
    }
    
    .stat-cell {
        padding: 8px;
    }
    
    .category-value-container {
        padding: 10px 12px;
    }
    
    .non-fsa-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
}