/* ===== BASE STYLES ===== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}
.skip-link:focus {
    top: 6px;
}

/* ===== LOADER ===== */
#loader {
    display: none;
}
#loader:not(.hidden) {
    display: block;
}

/* ===== RESULTS ===== */
#results {
    display: none;
}
#results:not(.hidden) {
    display: block;
}

#analogResults {
    display: none;
}
#analogResults:not(.hidden) {
    display: block;
}

/* ===== TABLE ROW STYLES ===== */
.table-row {
    transition: background-color 0.15s ease;
}
.table-row:hover {
    background-color: rgba(249, 250, 251, 0.8);
}

/* ===== SUPPLIER LOGO ===== */
.supplier-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    cursor: default;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.supplier-logo:hover {
    transform: scale(1.05);
    background-color: rgba(0, 0, 0, 0.03);
}

.supplier-logo span {
    line-height: 1;
}

.supplier-logo {
    position: relative;
}

.supplier-logo::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 0;
    padding: 4px 8px;
    background: #1f2937;
    color: white;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
    margin-bottom: 6px;
    z-index: 10;
}

.supplier-logo:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ===== PRICE DISPLAY ===== */
.price-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}
.price-supplier {
    font-size: 0.75rem;
    color: #9ca3af;
    font-variant-numeric: tabular-nums;
}
.price-main {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    font-variant-numeric: tabular-nums;
}

/* ===== CART BUTTON ===== */
.cart-btn {
    color: #9ca3af;
    padding: 0.5rem;
    border-radius: 9999px;
    transition: all 0.15s ease;
    background: transparent;
    border: none;
    cursor: pointer;
}
.cart-btn:hover {
    color: #6366f1;
    background-color: rgb(238 242 255);
}
.cart-btn:active {
    transform: scale(0.95);
}
.cart-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* ===== MODAL STYLES ===== */
.modal {
    transition: opacity 0.2s ease-in-out;
}
.modal.is-open {
    display: flex;
    opacity: 1;
}
.modal:not(.is-open) {
    opacity: 0;
    pointer-events: none;
}
.modal.active {
    display: flex;
    opacity: 1;
}

.modal-backdrop {
    animation: fadeIn 0.2s ease;
}

.modal-content {
    animation: modalSlideIn 0.2s ease forwards;
}

/* Comment textarea in modal */
.comment-section textarea {
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
}
.comment-section textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}
.comment-section textarea.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Modal buttons */
.btn-add-to-cart:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-add-to-cart.loading {
    position: relative;
    color: transparent;
}
.btn-add-to-cart.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.95) translateY(-10px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

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

/* ===== NOTIFICATION TOAST ===== */
.notification-toast {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===== CONFIRMATION DIALOG ===== */
.confirmation-dialog .relative {
    animation: confirmationSlideIn 0.2s ease-out forwards;
}

@keyframes confirmationSlideIn {
    from {
        transform: scale(0.95) translateY(-10px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ===== MOBILE STYLES ===== */
@media screen and (max-width: 768px) {
    /* Hide table headers */
    .table-header {
        display: none !important;
    }
    
    /* Convert rows to cards */
    .table-row {
        display: block !important;
        background: white !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 1rem !important;
        margin-bottom: 1rem !important;
        padding: 1rem !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }
    
    .table-cell {
        display: flex !important;
        align-items: flex-start !important;
        padding: 0.5rem 0 !important;
        border-bottom: 1px solid #f3f4f6 !important;
    }
    
    .table-cell:last-child {
        border-bottom: none !important;
        justify-content: center !important;
        padding-top: 1rem !important;
    }
    
    .table-cell::before {
        content: attr(data-label);
        font-weight: 600;
        color: #374151;
        font-size: 0.875rem;
        width: 90px;
        flex-shrink: 0;
        margin-right: 0.75rem;
    }
    
    .table-cell-content {
        flex: 1;
    }
    
    .table-cell.actions::before {
        display: none;
    }
    
    /* Mobile cart button */
    .cart-btn {
        background: #111827 !important;
        color: white !important;
        padding: 0.75rem 1.5rem !important;
        border-radius: 0.5rem !important;
        font-size: 0.875rem !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }
    .cart-btn:hover {
        background: #000 !important;
    }
    .cart-btn svg {
        color: white !important;
    }
    .cart-btn-text {
        display: inline !important;
    }
    
    /* Mobile price display */
    .price-display {
        align-items: stretch;
        width: 100%;
    }
    
    /* Mobile modal */
    .modal-content {
        width: 95% !important;
        margin: 1rem !important;
        max-height: 90vh !important;
    }
    
    .modal .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .modal .py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    .modal .p-6 {
        padding: 1rem !important;
    }
    
    .modal .gap-3 {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .modal .btn-cancel,
    .modal .btn-add-to-cart {
        width: 100% !important;
        padding: 0.75rem !important;
    }
    
    .modal .btn-add-to-cart {
        order: -1;
    }
}

/* Extra small screens */
@media screen and (max-width: 480px) {
    .table-row {
        padding: 0.75rem !important;
    }
    
    .table-cell::before {
        width: 70px;
        font-size: 0.75rem;
    }
    
    header .h-16 {
        height: auto !important;
        padding: 0.75rem 0 !important;
    }
    
    header .flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-contrast: high) {
    .modal-backdrop {
        background: rgba(0, 0, 0, 0.8);
    }
    .modal-content {
        border: 2px solid #000;
    }
    .comment-section textarea {
        border-width: 2px;
    }
    .notification-toast {
        border-width: 2px;
        border-color: currentColor;
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal,
    .modal-content,
    .modal-backdrop,
    .notification-toast,
    .confirmation-dialog .relative,
    .table-row,
    .cart-btn {
        transition: none !important;
        animation: none !important;
    }
    .modal.active,
    .modal.is-open {
        opacity: 1;
    }
    .modal-content {
        transform: none;
    }
}

/* Focus indicators */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    button:focus-visible,
    input:focus-visible,
    textarea:focus-visible,
    a:focus-visible {
        outline: 3px solid currentColor;
    }
}

/* Markup editors container */
.markup-editors-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 16px 20px;
    background: #fff;
    border-radius: 1rem;
    border: 1px solid rgb(243 244 246);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    align-items: center;
}

.markup-editors-row > span {
    display: none;
}

.markup-editor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: rgb(249 250 251);
    padding: 8px 12px;
    border-radius: 0.5rem;
    border: 1px solid rgb(229 231 235);
    transition: all 0.15s ease;
    box-sizing: border-box;
    min-width: 0;
}

.markup-editor-item:hover {
    border-color: rgb(199 210 254);
    background: rgb(238 242 255 / 0.5);
}

.markup-editor-item .supplier-name {
    color: #374151;
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.markup-editor-item .markup-input {
    width: 44px;
    padding: 4px 6px;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.375rem;
    background: #fff;
    color: #111827;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: all 0.15s ease;
}

.markup-editor-item .markup-input:hover {
    border-color: rgb(165 180 252);
}

.markup-editor-item .markup-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

.markup-editor-item .markup-input::-webkit-inner-spin-button,
.markup-editor-item .markup-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.markup-editor-item .markup-input[type=number] {
    -moz-appearance: textfield;
}

.markup-editor-item > span {
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
}

.markup-reset {
    background: transparent;
    border: 1px solid rgb(229 231 235);
    color: #6b7280;
    width: 28px;
    height: 28px;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    margin-left: 4px;
    flex-shrink: 0;
}

.markup-reset:hover:not(.invisible) {
    background: rgb(254 242 242);
    border-color: rgb(252 165 165);
    color: #dc2626;
}

.markup-reset.invisible {
    visibility: hidden;
}

.custom-markup-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    margin-left: 6px;
}

@media screen and (max-width: 900px) {
    .markup-editors-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 600px) {
    .markup-editors-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }
}

@media screen and (max-width: 400px) {
    .markup-editors-row {
        grid-template-columns: 1fr;
    }
    
    .markup-editor-item .markup-input {
        width: 50px;
    }
}
