/* ========================================
   C2G Logistics - UI Improvements
   Comprehensive fixes for UI/UX issues
   ======================================== */

/* ----------------------------------------
   1. HERO SECTION - Tablet Responsiveness
   ---------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) {
    .hero-section .hero-grid {
        grid-template-columns: 1fr;
        gap: 40px;
        text-align: center;
    }
    
    .hero-content {
        order: 1;
    }
    
    .hero-visual {
        order: 2;
        max-width: 500px;
        margin: 0 auto;
    }
    
    .hero-title {
        font-size: 2.5rem !important;
    }
    
    .hero-actions {
        justify-content: center;
    }
    
    .hero-features {
        justify-content: center;
    }
    
    /* Floating cards on tablet */
    .floating-card {
        transform: scale(0.9);
    }
    
    .floating-card.card-shipping {
        right: 5%;
        top: 10%;
    }
    
    .floating-card.card-customers {
        left: 5%;
        bottom: 10%;
    }
}

/* ----------------------------------------
   2. SKELETON LOADER IMPROVEMENTS
   ---------------------------------------- */
.skeleton-timeout-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.skeleton-timeout-message i {
    font-size: 2rem;
    margin-bottom: 15px;
    display: block;
    color: var(--primary-blue);
}

.skeleton-timeout-message p {
    margin-bottom: 15px;
}

/* Pulsing animation for skeleton */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.skeleton-card,
.skeleton-box,
.skeleton-line,
.skeleton-img {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ----------------------------------------
   3. CHECKOUT - Keyboard Accessible Shipping
   ---------------------------------------- */
.shipping-option {
    cursor: pointer;
    transition: all 0.2s ease;
}

.shipping-option:focus {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.shipping-option:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(0, 82, 255, 0.15);
}

.shipping-option[aria-checked="true"],
.shipping-option.selected {
    border-color: var(--primary-blue);
    background-color: rgba(0, 82, 255, 0.05);
}

/* ----------------------------------------
   4. DASHBOARD - Sidebar Mobile Fix
   ---------------------------------------- */
/* 
    /* 
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1050;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--white, #fff);
        box-shadow: none;
    }
    
    /* ,
    /* 
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
    
    /* 
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    /* Ensure proper stacking */
    .dashboard-main {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ----------------------------------------
   5. FORM VALIDATION - Scroll to Error
   ---------------------------------------- */
.form-error-highlight {
    animation: shake 0.5s ease-in-out;
    border-color: #dc3545 !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.error-message-visible {
    scroll-margin-top: 100px;
}

/* ----------------------------------------
   6. PRODUCT DETAIL - Mobile Actions Bar
   ---------------------------------------- */
.mobile-product-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white, #fff);
    border-top: 1px solid var(--border-color, #e9ecef);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    gap: 12px;
}

.mobile-product-actions .action-icons {
    display: flex;
    gap: 8px;
}

.mobile-product-actions .action-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-width: 50px;
}

.mobile-product-actions .action-icon-btn i {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.mobile-product-actions .action-icon-btn:hover,
.mobile-product-actions .action-icon-btn:focus {
    color: var(--primary-blue);
}

.mobile-product-actions .action-buttons {
    display: flex;
    flex: 1;
    gap: 8px;
}

.mobile-product-actions .btn-action {
    flex: 1;
    padding: 14px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
}

/* Ensure back-to-top button doesn't overlap */
body:has(.mobile-product-actions) .back-to-top-btn {
    bottom: 90px !important;
}

/* ----------------------------------------
   7. CART PAGE - Responsive Layout
   ---------------------------------------- */
@media (max-width: 768px) {
    .cart-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .cart-items-list {
        width: 100%;
    }
    
    .cart-summary-wrapper {
        width: 100%;
        position: sticky;
        bottom: 0;
        background: var(--white, #fff);
        padding: 15px;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        margin: 0 -20px;
        width: calc(100% + 40px);
    }
    
    .cart-list-header {
        display: none;
    }
    
    .cart-item {
        flex-wrap: wrap;
        padding: 15px;
        gap: 10px;
    }
    
    .cart-item .product-info {
        flex: 1 1 calc(100% - 100px);
    }
    
    .cart-item .quantity-controls {
        order: 3;
        flex: 1;
    }
    
    .cart-item .item-total {
        order: 4;
        font-weight: 700;
        font-size: 1.1rem;
    }
    
    .cart-item .remove-btn {
        position: absolute;
        top: 10px;
        right: 10px;
    }
}

/* ----------------------------------------
   8. HOVER & FOCUS STATES
   ---------------------------------------- */
/* Buttons */
.btn:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 82, 255, 0.35);
}

.btn-secondary:hover {
    background-color: var(--bg-light, #f8f9fa);
    transform: translateY(-1px);
}

/* Cards */
.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.product-card:focus-within {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Links */
a:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Form inputs */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 82, 255, 0.1);
}

/* ----------------------------------------
   9. LOADING STATES & TRANSITIONS
   ---------------------------------------- */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spinner 0.6s linear infinite;
}

@keyframes btn-spinner {
    to { transform: rotate(360deg); }
}

/* Page transitions */
.content-panel {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------
   10. ADDITIONAL POLISH
   ---------------------------------------- */

/* Better empty state styling */
.info-message {
    text-align: center;
    padding: 60px 30px;
    background: var(--bg-light, #f8f9fa);
    border-radius: 16px;
    margin: 30px 0;
}

.info-message i {
    font-size: 4rem;
    color: var(--primary-blue);
    margin-bottom: 20px;
    opacity: 0.8;
}

.info-message h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.info-message p {
    color: var(--text-muted);
    margin-bottom: 25px;
}

/* Toast notifications improvement */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 16px 20px;
    border-radius: 10px;
    background: var(--white, #fff);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
    max-width: 380px;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

/* Mobile menu improvements */
@media (max-width: 768px) {
    .mobile-menu {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
    
    .mobile-nav-links-wrapper a,
    .mobile-auth-wrapper a,
    .mobile-auth-wrapper button {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
}

/* Search input improvements */
.header-search input {
    transition: all 0.3s ease;
}

.header-search input:focus {
    background: var(--white, #fff);
    box-shadow: 0 4px 20px rgba(0, 82, 255, 0.15);
}

/* Price display improvements */
.product-price {
    font-weight: 700;
    color: var(--primary-blue);
    font-size: 1.1rem;
}

.price-original {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: 8px;
}

/* Category pills in shop */
.category-link {
    transition: all 0.2s ease;
}

.category-link:hover {
    color: var(--primary-blue);
    padding-left: 5px;
}

.category-link.active-category {
    color: var(--primary-blue);
    font-weight: 600;
    position: relative;
}

.category-link.active-category::before {
    content: '';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: var(--primary-blue);
    border-radius: 2px;
}

/* Footer improvements */
.footer {
    margin-top: auto;
}

.footer-col a:hover {
    color: var(--primary-blue);
    padding-left: 5px;
}

/* WhatsApp floating button */
.whatsapp-float {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background: #25D366;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.4);
    z-index: 999;
    transition: all 0.3s ease;
    text-decoration: none;
}

.whatsapp-float:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(37, 211, 102, 0.5);
}

@media (max-width: 768px) {
    .whatsapp-float {
        width: 55px;
        height: 55px;
        bottom: 20px;
        right: 20px;
    }
    
    /* Adjust for pages with mobile product actions */
    body:has(.mobile-product-actions) .whatsapp-float {
        bottom: 90px;
    }
}
