/* ==========================================================================
   SMART CALCULATOR
   ========================================================================== */
.smart-calculator {
    background: var(--surface-white);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.smart-calc-header {
    background: var(--primary-navy);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.smart-calc-header i {
    color: var(--accent-gold);
}

.smart-calc-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.smart-calc-body {
    padding: 1rem;
}

/* Search Input */
.smart-calc-search-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.smart-calc-search {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--bg-off-white);
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.smart-calc-search:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.smart-calc-search::placeholder {
    color: var(--text-muted);
}

.smart-calc-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

/* Search Results Dropdown */
.smart-calc-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-white);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}

.smart-calc-results.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.smart-calc-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-subtle);
}

.smart-calc-result-item:last-child {
    border-bottom: none;
}

.smart-calc-result-item:hover,
.smart-calc-result-item.selected {
    background: var(--bg-off-white);
}

.smart-calc-result-item .result-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}

.smart-calc-result-item .result-name i {
    color: var(--accent-gold);
    font-size: 0.85rem;
}

.smart-calc-result-item .result-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-off-white);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Conditions List */
.smart-calc-list {
    min-height: 100px;
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.smart-calc-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.smart-calc-empty i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.smart-calc-empty p {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.smart-calc-empty span {
    font-size: 0.85rem;
}

.smart-calc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    background: var(--bg-off-white);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.smart-calc-item.bilateral {
    border-color: var(--info-border);
    background: var(--info-bg);
}

.smart-calc-item .item-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.smart-calc-item .item-info i {
    color: var(--accent-gold);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.smart-calc-item .item-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bilateral-badge {
    font-size: 0.65rem;
    background: var(--info-text);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
    flex-shrink: 0;
}

.smart-calc-item .item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.smart-calc-item .item-rating {
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 0.9rem;
}

.smart-calc-item .item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}

.smart-calc-item .item-remove:hover {
    color: var(--alert-red);
}

/* Result Display */
.smart-calc-result {
    background: var(--primary-navy);
    color: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 0.75rem;
}

.smart-calc-result-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.smart-calc-result-value {
    font-size: 2rem;
    font-weight: 800;
}

.smart-calc-result-actual {
    font-size: 0.85rem;
    opacity: 0.8;
}

.smart-calc-bilateral-note {
    font-size: 0.75rem;
    color: var(--accent-gold);
    margin-top: 0.25rem;
    display: none;
}

/* Action Buttons Row */
.smart-calc-actions {
    display: flex;
    gap: 0.5rem;
}

.smart-calc-export,
.smart-calc-clear {
    flex: 1;
    padding: 0.6rem;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.smart-calc-export:hover {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.smart-calc-clear:hover {
    background: var(--alert-red);
    border-color: var(--alert-red);
    color: white;
}

/* Export Toast Notification */
.smart-calc-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary-navy);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 10002;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.smart-calc-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.smart-calc-toast i {
    color: var(--success-green);
}

/* Rating Picker Modal */
.smart-calc-rating-picker {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.smart-calc-rating-picker.open {
    opacity: 1;
    visibility: visible;
}

.picker-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.picker-content {
    position: relative;
    background: var(--surface-white);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.smart-calc-rating-picker.open .picker-content {
    transform: scale(1);
}

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

.picker-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.picker-title i {
    color: var(--accent-gold);
}

.picker-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

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

.picker-meta {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-off-white);
    flex-wrap: wrap;
}

.picker-category {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--surface-white);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
}

.picker-bilateral {
    font-size: 0.8rem;
    color: var(--info-text);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.picker-bilateral-toggle {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.picker-bilateral-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.picker-bilateral-toggle input {
    accent-color: var(--primary-blue);
}

.picker-ratings {
    padding: 1rem 1.25rem;
}

.picker-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.rating-option {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-off-white);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.rating-option:hover {
    border-color: var(--primary-blue);
    background: white;
}

.rating-value {
    font-weight: 700;
    color: var(--primary-blue);
    min-width: 45px;
}

.rating-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.picker-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-subtle);
    color: var(--primary-blue);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
}

.picker-link:hover {
    background: var(--bg-off-white);
}

/* Mobile drawer calculator adjustments */
.drawer-calculator {
    margin-bottom: 1rem;
}

.drawer-calculator .smart-calculator {
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-off-white);
}

.drawer-calculator .smart-calc-header {
    display: none;
}

.drawer-calculator .smart-calc-body {
    padding: 0.75rem;
}

.drawer-calculator .smart-calc-list {
    max-height: 180px;
}

.drawer-calculator .smart-calc-search {
    background: var(--surface-white);
}

/* Modal calculator adjustments */
#smartCalcModal .smart-calculator {
    border: none;
    border-radius: 0;
}

#smartCalcModal .smart-calc-header {
    display: none;
}

/* FAB (Floating Action Button) */
.smart-calc-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: var(--primary-navy);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.smart-calc-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    background: var(--primary-blue);
}

.smart-calc-fab:active {
    transform: scale(0.95);
}

/* FAB tooltip */
.smart-calc-fab::before {
    content: 'Calculator';
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-navy);
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.smart-calc-fab:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Show FAB on all screens */
.smart-calc-fab {
    display: flex;
}

/* Mobile FAB adjustments */
@media (max-width: 768px) {
    .smart-calc-fab {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }

    /* Hide tooltip on mobile */
    .smart-calc-fab::before {
        display: none;
    }
}

/* Dark mode overrides */
[data-theme="dark"] .smart-calc-fab {
    background: #1e293b;
    color: white;
}

[data-theme="dark"] .smart-calc-fab:hover {
    background: var(--primary-blue);
}

/* Print: hide calculator */
@media print {
    .smart-calculator,
    .smart-calc-rating-picker,
    .drawer-calculator,
    .smart-calc-fab,
    .smart-calc-toast {
        display: none !important;
    }
}
