/* ========== UNIVERSAL BOOKS - RESPONSIVE FIXES ========== */
/* Additional responsive improvements for production-ready standards */

/* ========== GLOBAL RESPONSIVE IMPROVEMENTS ========== */

/* Ensure consistent font sizes across devices */
html {
    font-size: 16px;
}

@media (max-width: 1200px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

/* ========== TOAST/POPUP STANDARDIZATION ========== */

/* Override any conflicting toast styles */
.toast,
.shop-toast,
.cart-toast,
.wishlist-toast {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    max-width: 280px !important;
    min-width: 180px !important;
    width: auto !important;
    padding: 12px 18px !important;
    font-size: 0.875rem !important;
    z-index: 10000 !important;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

/* Ensure toast shows correctly */
.toast.show,
.shop-toast.show,
.cart-toast.show,
.wishlist-toast.show {
    transform: translateY(0) !important;
    opacity: 1 !important;
}

/* Large screens (1400px+) - keep toasts small */
@media (min-width: 1400px) {
    .toast,
    .shop-toast,
    .cart-toast,
    .wishlist-toast {
        max-width: 300px !important;
        bottom: 24px !important;
        right: 24px !important;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .toast,
    .shop-toast,
    .cart-toast,
    .wishlist-toast {
        left: 16px !important;
        right: 16px !important;
        bottom: 16px !important;
        max-width: calc(100vw - 32px) !important;
        font-size: 0.8125rem !important;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .toast,
    .shop-toast,
    .cart-toast,
    .wishlist-toast {
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;
        max-width: calc(100vw - 24px) !important;
        font-size: 0.75rem !important;
        padding: 12px 16px !important;
    }
}

/* ========== BOOK CARD STANDARDIZATION ========== */

/* Consistent book card sizing across all pages */
.book-card {
    transition: all 0.3s ease;
}

/* Action buttons consistency */
.btn-action,
.btn-cart,
.btn-wishlist {
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
}

@media (min-width: 1400px) {
    .btn-action,
    .btn-cart,
    .btn-wishlist {
        width: 38px !important;
        height: 38px !important;
    }
}

@media (max-width: 768px) {
    .btn-action,
    .btn-cart,
    .btn-wishlist {
        width: 34px !important;
        height: 34px !important;
    }
}

/* Icon sizes within buttons */
.btn-action svg,
.btn-cart svg,
.btn-wishlist svg {
    width: 16px !important;
    height: 16px !important;
}

@media (min-width: 1400px) {
    .btn-action svg,
    .btn-cart svg,
    .btn-wishlist svg {
        width: 18px !important;
        height: 18px !important;
    }
}

@media (max-width: 768px) {
    .btn-action svg,
    .btn-cart svg,
    .btn-wishlist svg {
        width: 14px !important;
        height: 14px !important;
    }
}

/* ========== GRID LAYOUT CONSISTENCY ========== */

/* Ensure consistent grid gaps */
.books-grid,
.books-preview-grid,
.wishlist-grid {
    gap: 20px !important;
}

@media (max-width: 1200px) {
    .books-grid,
    .books-preview-grid,
    .wishlist-grid {
        gap: 16px !important;
    }
}

@media (max-width: 768px) {
    .books-grid,
    .books-preview-grid,
    .wishlist-grid {
        gap: 12px !important;
    }
}

@media (max-width: 480px) {
    .books-grid,
    .books-preview-grid,
    .wishlist-grid {
        gap: 10px !important;
    }
}

/* ========== MODAL/DIALOG IMPROVEMENTS ========== */

.modal-content,
.dialog-content {
    max-width: 90vw !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
}

@media (min-width: 768px) {
    .modal-content,
    .dialog-content {
        max-width: 600px !important;
    }
}

@media (min-width: 1200px) {
    .modal-content,
    .dialog-content {
        max-width: 700px !important;
    }
}

/* ========== FORM ELEMENTS CONSISTENCY ========== */

input,
select,
textarea,
button {
    font-size: 1rem !important;
    min-height: 44px !important; /* WCAG touch target */
}

@media (max-width: 768px) {
    input,
    select,
    textarea,
    button {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
}

/* ========== HEADER/NAVIGATION IMPROVEMENTS ========== */

/* Ensure header stays accessible */
.header {
    min-height: 60px;
}

@media (max-width: 768px) {
    .header {
        min-height: 56px;
    }
    
    /* Ensure touch targets are large enough */
    .cart-link,
    .wishlist-link,
    .mobile-menu-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
    }
}

/* ========== TYPOGRAPHY SCALING ========== */

/* Responsive font sizes for headings */
h1 { 
    font-size: clamp(1.75rem, 4vw, 2.5rem); 
}

h2 { 
    font-size: clamp(1.5rem, 3.5vw, 2rem); 
}

h3 { 
    font-size: clamp(1.25rem, 3vw, 1.75rem); 
}

h4 { 
    font-size: clamp(1.125rem, 2.5vw, 1.5rem); 
}

h5 { 
    font-size: clamp(1rem, 2vw, 1.25rem); 
}

h6 { 
    font-size: clamp(0.875rem, 1.5vw, 1.125rem); 
}

p {
    font-size: clamp(0.875rem, 2vw, 1rem);
    line-height: 1.6;
}

/* ========== SPACING CONSISTENCY ========== */

/* Consistent padding for sections */
section,
.section {
    padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 3vw, 2rem);
}

/* ========== ACCESSIBILITY IMPROVEMENTS ========== */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100000;
}

.skip-to-content:focus {
    top: 0;
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .toast,
    .modal,
    .header-actions,
    .mobile-menu,
    .announcement-bar {
        display: none !important;
    }
    
    .book-card {
        break-inside: avoid;
    }
}

/* ========== DARK MODE SUPPORT (Future Enhancement) ========== */

@media (prefers-color-scheme: dark) {
    /* Prepare for dark mode support */
    :root {
        --dark-background: #1a1a1a;
        --dark-text: #e0e0e0;
    }
}

/* ========== LANDSCAPE ORIENTATION FIXES ========== */

@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: 300px;
    }
    
    .modal-content {
        max-height: 90vh !important;
        padding: 12px !important;
    }
}

/* ========== RETINA/HIGH-DPI DISPLAY OPTIMIZATIONS ========== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp borders and shadows */
    .book-card,
    .btn-action,
    .modal-content {
        border-width: 0.5px;
    }
}

/* ========== CONTAINER WIDTH STANDARDIZATION ========== */

.container,
.main-container {
    width: 100%;
    max-width: var(--container-max-width, 1400px);
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
}

/* ========== Z-INDEX HIERARCHY ========== */

/* Standardize z-index values to prevent conflicts */
.announcement-bar { z-index: 1000; }
.header { z-index: 999; }
.dropdown-menu { z-index: 998; }
.modal-overlay { z-index: 9998; }
.modal { z-index: 9999; }
.toast { z-index: 10000 !important; }
.mobile-menu { z-index: 1001; }

/* ========== SMOOTH SCROLLING ========== */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ========== FINAL OVERRIDES ========== */

/* Ensure no horizontal overflow on mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    * {
        max-width: 100vw !important;
    }
}
