* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #bec2c5;
    background-image:
        radial-gradient(ellipse at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 0%, rgba(208, 208, 209, 0.8) 0%, transparent 60%);
    background-attachment: fixed;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(59, 130, 246, 0.03) 40px, rgba(59, 130, 246, 0.03) 41px),
        repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(59, 130, 246, 0.03) 40px, rgba(59, 130, 246, 0.03) 41px);
}

.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #bababa;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Hero Slider */
.banner-slider {
    -webkit-tap-highlight-color: transparent;
}

.banner-slide {
    transition: opacity 0.7s ease-in-out;
}

.banner-slide img {
    pointer-events: none;
}

/* Slider text shadow */
.dropShadow-md {
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Slider animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slider-fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Product card hover */
.product-card {
    transition: all 0.3s ease-out;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.product-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-card-body > .product-card-footer {
    margin-top: auto;
}

/* Star rating */
.star-rating {
    color: #F59E0B;
}

/* Toast animation */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-enter {
    animation: slideIn 0.3s ease-out;
}

.toast-exit {
    animation: slideOut 0.3s ease-in;
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3B82F6;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Quantity input */
.qty-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d1d5db;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.qty-btn:hover {
    background: #f3f4f6;
}

.qty-input {
    width: 48px;
    height: 32px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-left: none;
    border-right: none;
    font-size: 14px;
    outline: none;
}

/* Image zoom effect on product detail */
.img-zoom-container {
    overflow: hidden;
}

.img-zoom-container img {
    transition: transform 0.3s ease;
}

.img-zoom-container:hover img {
    transform: scale(1.05);
}

/* ===== Responsive Enhancements ===== */

/* Very small screens (< 400px) */
@media (max-width: 399px) {
    .product-card .line-clamp-2 {
        -webkit-line-clamp: 1;
    }
    .banner-slide h2 {
        font-size: 1rem !important;
    }
    .banner-slide p {
        font-size: 0.7rem !important;
        margin-bottom: 0.5rem !important;
    }
    .banner-slide a {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.8rem !important;
    }
    .banner-dot {
        width: 6px !important;
        height: 6px !important;
    }
    .pagination a {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.75rem !important;
    }
    .qty-input {
        width: 36px !important;
    }
    .qty-btn {
        width: 28px !important;
        height: 28px !important;
    }
    header .flex.items-center.gap-3.md\:gap-5 {
        gap: 0.5rem;
    }
    .text-xl.md\:text-2xl {
        font-size: 1rem;
    }
    .h-8.md\:h-10 {
        width: 2rem;
        height: 2rem;
    }
    #toastContainer {
        right: 0.5rem;
        left: 0.5rem;
    }
    #toastContainer > div {
        min-width: unset;
        max-width: unset;
        width: 100%;
    }
}

/* Small screens (400px - 639px) */
@media (min-width: 400px) and (max-width: 639px) {
    .banner-dot {
        width: 8px !important;
        height: 8px !important;
    }
    .banner-slide h2 {
        font-size: 1.25rem !important;
    }
    #toastContainer {
        right: 0.75rem;
        left: 0.75rem;
    }
    #toastContainer > div {
        min-width: unset;
        max-width: unset;
        width: 100%;
    }
}

/* Mobile general fixes (768px and below) */
@media (max-width: 768px) {
    .banner-slider .banner-prev,
    .banner-slider .banner-next {
        opacity: 1 !important;
    }
    .product-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
    .sticky {
        position: static !important;
    }
    .table-responsive {
        overflow-x: auto;
    }
    nav ul {
        -webkit-overflow-scrolling: touch;
    }
    table.w-full.text-sm.admin-table thead {
        display: none;
    }
    table.w-full.text-sm.admin-table tbody tr {
        display: block;
        padding: 0.75rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        margin-bottom: 0.5rem;
        background: white;
    }
    table.w-full.text-sm.admin-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
        text-align: right;
    }
    table.w-full.text-sm.admin-table tbody td:before {
        content: attr(data-label);
        font-weight: 500;
        color: #6b7280;
        font-size: 0.75rem;
        text-align: left;
    }
    table.w-full.text-sm.admin-table tbody td:first-child {
        padding-top: 0;
    }
    table.w-full.text-sm.admin-table tbody td:last-child {
        padding-bottom: 0;
    }
}

/* Cart: vertical layout on small screens */
@media (max-width: 500px) {
    .cart-item-row {
        flex-wrap: wrap;
    }
    .cart-item-row .item-details {
        width: calc(100% - 5rem);
    }
    .cart-item-row .item-actions {
        width: 100%;
        margin-top: 0.5rem;
        justify-content: flex-end;
    }
}

/* Cart items on very small screens */
@media (max-width: 480px) {
    [data-cart-item] {
        flex-wrap: wrap;
    }
    [data-cart-item] > .flex-1 {
        width: calc(100% - 5rem);
        margin-bottom: 0.5rem;
    }
    [data-cart-item] > div:last-child {
        width: 100%;
        justify-content: space-between;
    }
}

/* Better touch targets on mobile */
@media (pointer: coarse) {
    .banner-prev,
    .banner-next,
    .banner-dot {
        min-width: 44px;
        min-height: 44px;
    }
    .banner-prev,
    .banner-next {
        opacity: 1 !important;
    }
    button, a, input, select, textarea {
        font-size: 16px !important;
    }
}

/* Prevent zoom on input focus for iOS */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Landscape phone optimization */
@media (max-height: 480px) and (orientation: landscape) {
    .banner-slider .aspect-\[21\/9\] {
        aspect-ratio: 21/7;
    }
    .min-h-\[70vh\] {
        min-height: 85vh;
    }
}

/* Admin responsive table improvements - only for tables with .admin-table class */
@media (max-width: 640px) {
    .admin-table thead {
        display: none;
    }
    .admin-table tbody tr {
        display: block;
        padding: 0.75rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.5rem;
        margin-bottom: 0.5rem;
        background: white;
    }
    .admin-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.25rem 0;
        border: none;
        text-align: right;
    }
    .admin-table tbody td:before {
        content: attr(data-label);
        font-weight: 500;
        color: #6b7280;
        font-size: 0.75rem;
        text-align: left;
    }
    .admin-table tbody td:first-child {
        padding-top: 0;
    }
    .admin-table tbody td:last-child {
        padding-bottom: 0;
    }
}

/* Grid gap fix for very small screens */
@media (max-width: 360px) {
    .grid.grid-cols-2 {
        gap: 0.5rem !important;
    }
    .p-2.md\:p-3 {
        padding: 0.375rem !important;
    }
    .text-xs.md\:text-sm {
        font-size: 0.625rem !important;
    }
}
