/* Calculator V2 Styles */

/* Smart Search */
#smart-search:focus + #search-tokens {
    display: none;
}

#search-tokens .token {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 4px;
    font-size: 14px;
}

#search-tokens .token-valid {
    background-color: rgba(34, 197, 94, 0.2);
    color: #16a34a;
}

#search-tokens .token-invalid {
    background-color: rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

#search-tokens .token-warning {
    background-color: rgba(234, 179, 8, 0.2);
    color: #ca8a04;
}

.dark #search-tokens .token-valid {
    background-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.dark #search-tokens .token-invalid {
    background-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.dark #search-tokens .token-warning {
    background-color: rgba(234, 179, 8, 0.3);
    color: #facc15;
}

/* Autocomplete */
#search-autocomplete .autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.15s;
}

#search-autocomplete .autocomplete-item:hover,
#search-autocomplete .autocomplete-item.selected {
    background-color: rgba(186, 34, 37, 0.1);
}

.dark #search-autocomplete .autocomplete-item:hover,
.dark #search-autocomplete .autocomplete-item.selected {
    background-color: rgba(186, 34, 37, 0.2);
}

#search-autocomplete .autocomplete-item-highlight {
    font-weight: 600;
    color: #ba2225;
}

/* Form mode toggle animation */
#form-chevron.rotated {
    transform: rotate(180deg);
}

#form-mode {
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    overflow: hidden;
}

/* Calculation breakdown */
#calculation-lines .calc-line {
    display: flex;
    justify-content: space-between;
    color: #64748b;
}

.dark #calculation-lines .calc-line {
    color: #94a3b8;
}

#calculation-lines .calc-line-value {
    font-weight: 500;
}

#calculation-lines .calc-line-positive {
    color: #ef4444;
}

#calculation-lines .calc-line-negative {
    color: #22c55e;
}

/* Cart items */
.cart-item {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.15s;
}

.dark .cart-item {
    border-bottom-color: #334155;
}

.cart-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.dark .cart-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.cart-item-title {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
}

.dark .cart-item-title {
    color: #f1f5f9;
}

.cart-item-actions {
    display: flex;
    gap: 4px;
}

.cart-item-btn {
    padding: 4px;
    border-radius: 4px;
    color: #94a3b8;
    transition: color 0.15s, background-color 0.15s;
}

.cart-item-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.dark .cart-item-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.cart-item-btn-edit:hover {
    color: #3b82f6;
}

.cart-item-btn-delete:hover {
    color: #ef4444;
}

.cart-item-details {
    font-size: 12px;
    color: #64748b;
}

.dark .cart-item-details {
    color: #94a3b8;
}

.cart-item-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
}

.cart-item-weight {
    color: #64748b;
}

.dark .cart-item-weight {
    color: #94a3b8;
}

.cart-item-value {
    font-weight: 600;
    color: #ba2225;
}

/* Toast notifications */
.toast {
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toast-slide-in 0.3s ease-out;
    max-width: 320px;
}

.toast-success {
    background-color: #dcfce7;
    color: #166534;
}

.toast-error {
    background-color: #fee2e2;
    color: #991b1b;
}

.toast-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.dark .toast-success {
    background-color: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.dark .toast-error {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.dark .toast-info {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-exit {
    animation: toast-slide-out 0.2s ease-in forwards;
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Mobile responsiveness */
@media (max-width: 1023px) {
    #cart-panel {
        display: none;
    }

    #mobile-cart-trigger {
        display: block;
    }

    /* Add bottom padding for mobile cart trigger */
    main {
        padding-bottom: 64px;
    }
}

@media (min-width: 1024px) {
    #mobile-cart-trigger {
        display: none !important;
    }
}

/* Input focus states */
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #ba2225;
    box-shadow: 0 0 0 3px rgba(186, 34, 37, 0.1);
}

/* Number input spinners (optional styling) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

/* Loading shimmer effect */
.shimmer {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.dark .shimmer {
    background: linear-gradient(
        90deg,
        #334155 25%,
        #475569 50%,
        #334155 75%
    );
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Checkbox custom styling */
input[type="checkbox"] {
    cursor: pointer;
}

input[type="checkbox"]:checked {
    background-color: #ba2225;
    border-color: #ba2225;
}

/* Swipe to delete hint (mobile) */
@media (max-width: 1023px) {
    .cart-item {
        position: relative;
    }

    .cart-item::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background-color: transparent;
        transition: background-color 0.15s;
    }

    .cart-item.swiping::before {
        background-color: #ef4444;
    }
}

/* Sticky cart on large screens */
@media (min-width: 1024px) {
    #cart-panel {
        max-height: calc(100vh - 6rem);
        overflow-y: auto;
    }
}
