/**
 * KB Shop Sidebar Styles
 * Desktop and Mobile Responsive Design
 */

/* ===================================
   TRIGGER BUTTON
   =================================== */

.kb-shop-sidebar-trigger {
    position: fixed !important;
    left: 0 !important;
    top: 120px !important;
    bottom: auto !important;
    /* Position, colors, and border-radius overridden via inline CSS from settings */
    border: none;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    z-index: 999999 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    white-space: nowrap;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #ffffff;
    border-radius: 0 8px 8px 0;
}

.kb-shop-sidebar-trigger .kb-trigger-text {
    display: inline;
    visibility: visible;
}

.kb-shop-sidebar-trigger:hover {
    /* Background set via inline CSS from settings */
    padding-right: 28px;
    box-shadow: 3px 3px 16px rgba(0, 0, 0, 0.3);
}

.kb-shop-sidebar-trigger .kb-trigger-icon {
    transition: transform 0.3s ease;
}

.kb-shop-sidebar-trigger:hover .kb-trigger-icon {
    transform: translateX(4px);
}

/* Hide trigger button when sidebar is active */
.kb-shop-sidebar-trigger.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
}

/* ===================================
   OVERLAY
   =================================== */

.kb-shop-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.kb-shop-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   SIDEBAR PANEL
   =================================== */

.kb-shop-sidebar-panel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 460px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kb-shop-sidebar-panel.active {
    left: 0;
}

/* ===================================
   SIDEBAR HEADER
   =================================== */

.kb-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.kb-sidebar-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kb-sidebar-logo {
    max-height: 40px;
    width: auto;
}

.kb-sidebar-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.kb-sidebar-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: color 0.2s ease;
}

.kb-sidebar-close:hover {
    color: #1f2937;
}

/* ===================================
   SEARCH BOX
   =================================== */

.kb-sidebar-search {
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.kb-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    color: #1f2937;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.kb-search-input:focus {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.kb-search-input::placeholder {
    color: #9ca3af;
}

/* ===================================
   SIDEBAR CONTENT
   =================================== */

.kb-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.kb-sidebar-content::-webkit-scrollbar {
    width: 8px;
}

.kb-sidebar-content::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.kb-sidebar-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.kb-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===================================
   CATEGORY SECTIONS
   =================================== */

.kb-category-section {
    margin-bottom: 24px;
}

.kb-category-section.hidden {
    display: none;
}

.kb-category-title {
    font-size: 14px;
    font-weight: 700;
    color: #e74c3c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 24px 8px;
    margin: 0 0 8px 0;
}

.kb-category-products {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ===================================
   PRODUCT ITEMS
   =================================== */

.kb-product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    transition: background-color 0.2s ease;
}

.kb-product-item:hover {
    background-color: #ffffff;
}

.kb-product-item.hidden {
    display: none;
}

.kb-product-info {
    flex: 1;
    min-width: 0;
}

.kb-product-name {
    font-size: 15px;
    font-weight: 400;
    color: #1f2937;
    margin: 0;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease;
}

.kb-product-name:hover {
    color: #e74c3c;
}

.kb-product-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Product Cart Icon Button */
.kb-product-cart-icon {
    background-color: #ffffff;
    background-image: none;
    background: #ffffff;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

.kb-product-cart-icon:hover:not(:disabled) {
    background: #ffffff;
}

.kb-product-cart-icon:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.kb-product-cart-icon img {
    display: block;
}

/* Inline Quantity Controls */
.kb-product-item .kb-quantity-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.kb-product-item .kb-qty-btn {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.kb-product-item .kb-qty-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #1f2937;
}

.kb-product-item .kb-qty-input {
    width: 36px;
    height: 24px;
    text-align: center;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    outline: none;
    background: #ffffff;
    padding: 0 4px;
}

.kb-product-item .kb-qty-input:focus {
    border-color: #d1d5db;
    box-shadow: none;
    background: #ffffff;
}

/* Remove spinner from number input */
.kb-qty-input::-webkit-outer-spin-button,
.kb-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.kb-qty-input[type=number] {
    -moz-appearance: textfield;
}

/* ===================================
   CART SECTION
   =================================== */

.kb-cart-section {
    border-top: 2px solid #e5e7eb;
    margin-top: 16px;
    padding-top: 16px;
}

.kb-cart-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 24px;
}

.kb-cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.kb-cart-item-info {
    flex: 1;
    min-width: 0;
}

.kb-cart-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    margin: 0 0 4px 0;
}

.kb-cart-item-price {
    font-size: 13px;
    color: #6b7280;
}

.kb-cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-cart-qty-btn {
    background: white;
    border: 1px solid #e5e7eb;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: #6b7280;
    transition: all 0.2s ease;
}

.kb-cart-qty-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.kb-cart-qty-value {
    min-width: 30px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
}

.kb-cart-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #ef4444;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.kb-cart-remove-btn:hover {
    color: #dc2626;
}

/* ===================================
   SIDEBAR FOOTER
   =================================== */

.kb-sidebar-footer {
    padding: 20px 24px;
    border-top: 2px solid #e5e7eb;
    background: #ffffff;
}

.kb-checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white !important;
    border: none;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.kb-checkout-btn span {
    color: white !important;
}

.kb-checkout-btn .kb-total-amount {
    font-weight: 700;
    color: white !important;
}

.kb-checkout-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
    transform: translateY(-2px);
}

/* ===================================
   QUANTITY MODAL
   =================================== */

.kb-quantity-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.kb-quantity-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.kb-quantity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.kb-quantity-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.kb-quantity-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.kb-quantity-close:hover {
    color: #1f2937;
}

.kb-quantity-body {
    padding: 24px;
}

.kb-quantity-product-name {
    font-size: 16px;
    font-weight: 500;
    color: #1f2937;
    margin: 0 0 20px 0;
    text-align: center;
}

.kb-quantity-modal .kb-quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.kb-quantity-modal .kb-qty-decrease,
.kb-quantity-modal .kb-qty-increase {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
    transition: all 0.2s ease;
}

.kb-quantity-modal .kb-qty-decrease:hover,
.kb-quantity-modal .kb-qty-increase:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.kb-quantity-modal .kb-qty-input {
    width: 80px;
    height: 48px;
    text-align: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
    outline: none;
    transition: border-color 0.2s ease;
}

.kb-quantity-modal .kb-qty-input:focus {
    border-color: #e74c3c;
}

/* Remove spinner from number input */
.kb-qty-input::-webkit-outer-spin-button,
.kb-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.kb-qty-input[type=number] {
    -moz-appearance: textfield;
}

.kb-quantity-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
}

.kb-quantity-add-btn {
    width: 100%;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kb-quantity-add-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* ===================================
   LOADING STATE
   =================================== */

.kb-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ===================================
   NO RESULTS MESSAGE
   =================================== */

.kb-no-results {
    padding: 40px 24px;
    text-align: center;
    color: #6b7280;
    font-size: 15px;
}

/* ===================================
   MOBILE RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .kb-shop-sidebar-trigger {
        padding: 20px 8px !important;
        font-size: 14px !important;
        writing-mode: sideways-lr !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        border-radius: 0 8px 8px 0 !important;
    }

    .kb-shop-sidebar-trigger.hidden {
        transform: translate(-100%, -50%) !important;
    }

    .kb-shop-sidebar-trigger .kb-trigger-icon {
        display: none !important;
    }

    .kb-shop-sidebar-panel {
        width: 100%;
        max-width: 100vw;
    }

    .kb-sidebar-title {
        font-size: 20px;
    }

    .kb-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .kb-product-name {
        font-size: 14px;
    }

    .kb-quantity-modal-content {
        margin: 0 16px;
    }

    .kb-sidebar-footer {
        padding: 16px 20px;
    }

    .kb-checkout-btn {
        font-size: 15px;
        padding: 14px 20px;
    }
}

@media (max-width: 480px) {
    .kb-sidebar-header,
    .kb-sidebar-search {
        padding: 16px 20px;
    }

    .kb-product-item {
        padding: 10px 20px;
    }

    .kb-cart-items {
        padding: 0 20px;
    }

    .kb-quantity-controls {
        gap: 12px;
    }

    .kb-qty-decrease,
    .kb-qty-increase {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .kb-qty-input {
        width: 70px;
        height: 42px;
        font-size: 18px;
    }
}

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

.kb-shop-sidebar-trigger:focus,
.kb-sidebar-close:focus,
.kb-add-to-cart-btn:focus,
.kb-checkout-btn:focus,
.kb-quantity-close:focus,
.kb-qty-decrease:focus,
.kb-qty-increase:focus,
.kb-quantity-add-btn:focus {
    outline: 2px solid #e74c3c;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .kb-shop-sidebar-trigger,
    .kb-checkout-btn,
    .kb-quantity-add-btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===================================
   NOTIFICATION
   =================================== */

.kb-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #10b981;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 15px;
    font-weight: 500;
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.kb-notification.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 480px) {
    .kb-notification {
        bottom: 16px;
        right: 16px;
        left: 16px;
        text-align: center;
    }
}
