/**
 * Catalog Table Styles
 * Table view for product listing
 * Premium design with subtle shadows and smooth transitions
 */

/* ============================================================================
   TABLE VIEW
   ============================================================================ */

.catalog-table-container {
    overflow-x: auto;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    transition: box-shadow 0.2s ease;
}

.catalog-table-container:hover {
    box-shadow: var(--shadow-md);
}

.catalog-table {
    width: 100%;
    border-collapse: collapse;
}

/* Table Header - Sticky with blur effect */
.catalog-table thead {
    background-color: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

@supports (backdrop-filter: blur(8px)) {
    .catalog-table thead {
        background-color: rgba(var(--bg-secondary-rgb), 0.85);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

.catalog-table th {
    padding: 14px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, background-color 0.15s ease;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.catalog-table th:hover {
    color: var(--accent);
    background-color: var(--bg-hover);
}

.catalog-table th.col-image,
.catalog-table th.col-action {
    cursor: default;
}

.catalog-table th.col-image:hover,
.catalog-table th.col-action:hover {
    color: var(--text-muted);
    background-color: transparent;
}

/* Sort Indicator */
.catalog-table th[data-sort]::after {
    content: '';
    margin-left: 6px;
    opacity: 0.3;
}

.catalog-table th.sorted-asc::after {
    content: '\25B2';
    opacity: 1;
    color: var(--accent);
}

.catalog-table th.sorted-desc::after {
    content: '\25BC';
    opacity: 1;
    color: var(--accent);
}

/* Active sort column highlight */
.catalog-table th.sorted-asc,
.catalog-table th.sorted-desc {
    color: var(--accent);
    background-color: var(--accent-light);
}

/* Table Body */
.catalog-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

/* Subtle row separator */
.catalog-table tbody tr::after {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    height: 1px;
    background-color: var(--border);
    opacity: 0.5;
}

.catalog-table tbody tr:last-child::after {
    display: none;
}

/* Row hover with gradient accent effect */
.catalog-table tbody tr:hover {
    background: linear-gradient(
        90deg,
        var(--accent-light) 0%,
        var(--bg-hover) 30%,
        var(--bg-hover) 100%
    );
}

.catalog-table tbody tr:hover::after {
    opacity: 0;
}

.catalog-table td {
    padding: 14px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    vertical-align: middle;
}

/* Image Column */
.catalog-table .col-image {
    width: 60px;
    padding: 10px;
}

.catalog-table .col-image img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 8px;
    background-color: var(--bg-tertiary);
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.catalog-table tbody tr:hover .col-image img {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Name Column */
.catalog-table .col-name {
    min-width: 220px;
    max-width: 300px;
}

/* Product link - SEO-friendly anchor wrapping product name */
.catalog-table .product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.catalog-table .col-image .product-link {
    display: flex;
    align-items: center;
    justify-content: center;
}

.catalog-table .product-brand {
    display: block;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.catalog-table .product-model {
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: normal;
    line-height: 1.3;
    transition: color 0.15s ease;
}

.catalog-table tbody tr:hover .product-model,
.catalog-table .product-link:hover .product-model {
    color: var(--accent);
}

/* Price Column - More prominent styling */
.catalog-table .col-price {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* Price with subtle background on hover */
.catalog-table tbody tr:hover .col-price {
    color: var(--accent-hover);
}

/* Action Column */
.catalog-table .col-action {
    width: 60px;
    text-align: center;
}

/* ============================================================================
   TABLE VIEW - UNAVAILABLE PRODUCT STYLING
   ============================================================================ */

.col-price--unavailable {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9375rem;
}

/* ============================================================================
   TABLE - LOADING STATE
   ============================================================================ */

.catalog-table-container.is-loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ============================================================================
   TABLE - VISIBILITY CONTROL
   ============================================================================ */

/* Hide container when Alpine switches to different view mode */
.catalog-table-container.is-hidden {
    display: none;
}

/* Ensure table is visible by default (no JS) */
.catalog-table-container {
    display: block;
}

/* SSR row visibility */
.ssr-row {
    /* SSR rows shown by default (no JS) */
}

/* When Alpine initializes, x-show handles visibility */

/* ============================================================================
   ACTION COLUMN BUTTONS
   ============================================================================ */

.col-action__buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Price Alert Button */
.catalog-alert-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 150ms ease;
    text-decoration: none;
}

.catalog-alert-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--accent);
}

.catalog-alert-btn.is-alert-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.catalog-alert-btn.is-alert-active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.catalog-alert-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.catalog-alert-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================================================
   PRICE ALERT POPOVER MODAL
   ============================================================================ */

.catalog-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.catalog-alert-popover {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.catalog-alert-popover__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.catalog-alert-popover__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.catalog-alert-popover__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 150ms ease;
}

.catalog-alert-popover__close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.catalog-alert-popover__body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.catalog-alert-popover__product {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.catalog-alert-popover__description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.catalog-alert-popover__current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.catalog-alert-popover__current-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.catalog-alert-popover__current-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
}

.catalog-alert-popover__types {
    display: flex;
    gap: 8px;
}

.catalog-alert-popover__type {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 150ms ease;
}

.catalog-alert-popover__type input {
    display: none;
}

.catalog-alert-popover__type span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.catalog-alert-popover__type:hover {
    border-color: var(--border-light);
}

.catalog-alert-popover__type.is-selected {
    background: var(--accent-light);
    border-color: var(--accent);
}

.catalog-alert-popover__type.is-selected span {
    color: var(--accent);
}

.catalog-alert-popover__input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.catalog-alert-popover__input-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.catalog-alert-popover__input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.catalog-alert-popover__input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    width: 80px;
    text-align: center;
    -moz-appearance: textfield;
}

.catalog-alert-popover__input::-webkit-outer-spin-button,
.catalog-alert-popover__input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.catalog-alert-popover__input:focus {
    outline: none;
    border-color: var(--accent);
}

.catalog-alert-popover__input--price {
    width: 120px;
    text-align: left;
}

.catalog-alert-popover__input-prefix,
.catalog-alert-popover__input-suffix {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.catalog-alert-popover__hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.catalog-alert-popover__hint span {
    color: var(--accent);
    font-weight: 600;
}

.catalog-alert-popover__error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--error-light, rgba(248, 113, 113, 0.1));
    border-radius: 8px;
    color: var(--error);
    font-size: 0.875rem;
}

.catalog-alert-popover__error svg {
    flex-shrink: 0;
}

.catalog-alert-popover__footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.catalog-alert-popover__btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.catalog-alert-popover__btn--cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.catalog-alert-popover__btn--cancel:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.catalog-alert-popover__btn--create {
    background: var(--accent);
    border: none;
    color: #000;
}

.catalog-alert-popover__btn--create:hover {
    background: var(--accent-hover);
}

.catalog-alert-popover__btn--create:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .catalog-table-container,
    .catalog-table th,
    .catalog-table tbody tr,
    .catalog-table .col-image img,
    .catalog-table .product-model,
    .catalog-table .col-price,
    .catalog-alert-btn,
    .catalog-alert-popover,
    .catalog-alert-popover__btn {
        transition: none;
    }

    .catalog-table tbody tr:hover .col-image img {
        transform: none;
    }
}
