/* ====================================
   Buttons
   ==================================== */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-weight: var(--font-weight-medium);
    text-align: center;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-family);
    font-size: 0.95rem;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: white;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-2xl);
    font-size: 1.125rem;
}

/* ====================================
   Forms
   ==================================== */
.form-control {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: var(--font-weight-medium);
    color: var(--text-dark);
}

/* ====================================
   Cards & Products
   ==================================== */
.product-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xs);
}

.product-card .btn {
    height: 40px;
    padding-top: 0;
    padding-bottom: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.product-card .btn.btn-stacked {
    height: 40px;
    padding-top: 0;
    padding-bottom: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-direction: row;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.product-image {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* Aspect ratio 16:9 */
    overflow: hidden;
    background: var(--bg-gray);
    border-radius: var(--radius-lg);
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-placeholder,
.category-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-gray), var(--bg-light));
}

.discount-badge {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: var(--error-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: var(--font-weight-bold);
    z-index: 1;
}

.product-info {
    padding: var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 1rem;
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-sm);
    line-height: 1.4;
}

.product-name a {
    color: var(--text-dark);
}

.product-price {
    margin-bottom: var(--spacing-md);
}

.price-original {
    text-decoration: line-through;
    color: var(--text-medium);
    font-size: 0.875rem;
    margin-right: var(--spacing-xs);
}

.price-current {
    font-size: 1.25rem;
    font-weight: var(--font-weight-bold);
    color: var(--primary-color);
}

.product-card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.product-card-actions .btn {
    width: 100%;
}

.btn-add-cart {
    margin-top: auto;
    width: 100%;
}

/* ====================================
   Grids
   ==================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    padding: var(--spacing-md) 0;
}

@media (min-width: 1024px) {
    .categories-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: var(--spacing-lg);
    }
}

.categories-grid::-webkit-scrollbar {
    display: none;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    width: 100%;
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: none;
}

.category-card img {
    position: relative;
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xs);
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
}

.category-card h3 {
    position: relative;
    background: none;
    color: var(--text-dark);
    padding: 0;
    margin: 0;
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    text-align: center;
    width: 100%;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.25;
    max-height: calc(2 * 1.25em);
    min-height: calc(2 * 1.25em);
}

/* Category placeholder style */
.category-placeholder {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-xs);
    background: linear-gradient(135deg, var(--bg-gray), var(--bg-light));
}

/* ====================================
   Sections
   ==================================== */
.section-title {
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--spacing-md);
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.products-section {
    padding: var(--spacing-lg) 0 var(--spacing-2xl);
}

.products-section.bg-light {
    background: var(--bg-white);
}

.categories-section {
    padding: var(--spacing-lg) 0;
    margin: 2.5rem var(--spacing-lg) 0 var(--spacing-lg);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.empty-message {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-medium);
    grid-column: 1 / -1;
}

/* ====================================
   Badges & Labels
   ==================================== */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-error {
    background: var(--error-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

/* Mobile optimizations for product cards */
@media (max-width: 768px) {
    .discount-badge {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        font-weight: 700;
        letter-spacing: 0.5px;
    }
}

/* ====================================
   Pagination
   ==================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-2xl);
}

.page-link {
    padding: var(--spacing-xs) var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.page-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-link.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.support-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.support-chat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: none;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #ffffff;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 600;
}

.support-chat-toggle-icon {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.support-chat-toggle-text {
    display: inline-block;
}

.support-chat-panel {
    width: 320px;
    max-width: calc(100vw - 32px);
    height: 420px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.support-chat-panel.open {
    display: flex;
}

.support-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.support-chat-title {
    font-weight: 700;
    font-size: 0.98rem;
}

.support-chat-subtitle {
    font-size: 0.8rem;
    color: var(--text-medium);
}

.support-chat-close {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    border-radius: 999px;
}

.support-chat-close:hover {
    background: var(--bg-light);
}

.support-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.support-chat-messages {
    padding: 12px 12px 4px 12px;
    overflow-y: auto;
    flex: 1;
    background: var(--bg-light);
}

.support-chat-message-row {
    display: flex;
    margin-bottom: 6px;
}

.support-chat-message-row.customer {
    justify-content: flex-end;
}

.support-chat-message-row.admin {
    justify-content: flex-start;
}

.support-chat-message {
    max-width: 260px;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.support-chat-message.customer {
    background: var(--primary-color);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.support-chat-message.admin {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    margin-right: auto;
}

.support-chat-meta {
    font-size: 0.7rem;
    color: var(--text-medium);
    margin-top: 1px;
}

.support-chat-input-row {
    padding: 6px 10px;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
}

.support-chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    padding: 6px 12px 6px 14px;
    background: var(--bg-light);
}

.support-chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9rem;
}

.support-chat-input::placeholder {
    color: var(--text-medium);
}

.support-chat-attach {
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-medium);
    cursor: pointer;
}

.support-chat-send {
    border-radius: 999px;
    border: none;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
}

.support-chat-send:disabled {
    opacity: 0.4;
    cursor: default;
}

.support-chat-footer-note {
    padding: 0 12px 8px 12px;
    font-size: 0.75rem;
    color: var(--text-medium);
}

@media (max-width: 640px) {
    .support-chat-widget {
        right: 16px;
        bottom: 76px;
    }

    .support-chat-panel {
        width: calc(100vw - 32px);
        height: auto;
        max-height: 65vh;
    }
}

/* ====================================
   Responsive
   ==================================== */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: var(--spacing-md);
    }

    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-sm);
    }

    .section-title {
        font-size: 1.5rem;
        margin-bottom: var(--spacing-sm);
    }

    .categories-section {
        padding: var(--spacing-md) 0;
        margin: 2rem var(--spacing-md) 0 var(--spacing-md);
        border-radius: var(--radius-md);
    }

    .products-section {
        padding: var(--spacing-sm) 0 var(--spacing-md);
    }

    .btn.btn-add-cart {
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .product-price {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        margin-bottom: 8px;
    }

    /* Stack buttons vertically on mobile */
    .product-info > div[style*="display: flex"] {
        flex-direction: column;
        gap: 0.5rem !important;
    }

    .product-info .btn {
        width: 100%;
        margin: 0;
    }

    .product-card .btn.btn-stacked {
        height: auto;
        min-height: 40px;
        flex-direction: column;
        line-height: 1.1;
        white-space: normal;
        padding: 4px 0;
        gap: 0;
    }
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-pending { background-color: #FEF3C7; color: #D97706; }
.status-processing { background-color: #DBEAFE; color: #2563EB; }
.status-completed, .status-delivered { background-color: #D1FAE5; color: #059669; }
.status-failed, .status-cancelled { background-color: #FEE2E2; color: #DC2626; }
.status-refunded { background-color: #F3F4F6; color: #4B5563; }
.status-verification_pending { background-color: #E0E7FF; color: #4F46E5; }

