/* Custom CSS for Spriggan & Banshee */

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE DESIGN
   ========================================================================== */

/* Base styles for all devices */
body {
    /* Removed padding-top since navbar is not fixed */
}

/* ==========================================================================
   UNIFIED CART BUTTON SYSTEM
   ========================================================================== */

.cart-container {
    position: relative;
    margin-left: auto;
    margin-right: 0;
    display: flex;
    align-items: center;
    order: 2; /* Ensure it's positioned after the brand but before the hamburger */
}

.navbar-toggler {
    order: 3; /* Ensure hamburger is rightmost */
}

.cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    background: transparent;
    border: 1px solid transparent;
    position: relative;
    min-width: 50px;
    height: 40px;
    /* Remove transform from here to prevent icon movement */
}

.cart-btn:hover {
    color: #495057;
    background-color: rgba(13, 110, 253, 0.1);
    border-color: rgba(13, 110, 253, 0.2);
    text-decoration: none;
    /* Fixed: No transforms to prevent any movement */
}

.cart-icon {
    font-size: 1.4rem;
    transition: color 0.3s ease;
    /* Removed any transform transitions to keep icon stable */
}

.cart-icon.cart-empty {
    color: #6c757d;
}

.cart-icon.cart-filled {
    color: #0d6efd;
}

.cart-count-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #dc3545 !important;
    color: white !important;
    border-radius: 12px; /* Horizontal oval instead of perfect circle */
    padding: 0 6px; /* Horizontal padding for oval shape */
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: cartBadgeAppear 0.3s ease-out;

    /* Auto-expand for larger numbers */
    white-space: nowrap;
    width: auto; /* Let it expand naturally */

    /* Fix vertical alignment */
    line-height: 1;
    text-align: center;
    vertical-align: middle;
}

/* Simple width adjustments based on content length */
.cart-count-badge[data-digits="2"] {
    min-width: 24px;
}

.cart-count-badge[data-digits="3"] {
    min-width: 30px;
}

.cart-count-badge[data-digits="4"] {
    min-width: 36px;
}

@keyframes cartBadgeAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile positioning */
@media (max-width: 991.98px) {
    .cart-container {
        margin-left: auto;
        margin-right: 8px; /* Add some space from the hamburger menu */
        order: 2; /* Keep it between brand and hamburger */
    }

    .navbar-toggler {
        order: 3; /* Keep hamburger rightmost */
    }

    .cart-btn {
        padding: 6px 10px;
        min-width: 45px;
        height: 36px;
    }

    .cart-icon {
        font-size: 1.2rem;
    }

    .cart-count-badge {
        font-size: 0.65rem;
        min-width: 16px;
        height: 16px;
        width: 16px;
        top: -1px;
        right: -1px;

        /* Fix vertical alignment for mobile */
        line-height: 1;
        text-align: center;
        vertical-align: middle;
    }
}

/* ==========================================================================
   ADD TO CART BUTTON SUCCESS STATE
   ========================================================================== */

/* Success state for Add to Cart buttons */
.add-to-cart-list-btn.success,
.add-to-cart-detail-btn.success {
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: white !important;
}

.add-to-cart-list-btn.success:hover,
.add-to-cart-detail-btn.success:hover {
    background-color: #157347 !important;
    border-color: #157347 !important;
    color: white !important;
}

/* ==========================================================================
   CART SIDEBAR STYLES
   ========================================================================== */

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: -400px; /* Start off-screen - increased from 350px */
    width: 400px; /* Increased from 350px to accommodate square buttons */
    height: 100%;
    background-color: #fff;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transition: right 0.3s ease-in-out;
    z-index: 1050;
    display: flex;
    flex-direction: column;
}

.cart-sidebar.open {
    right: 0; /* Slide in */
}

.cart-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.cart-sidebar-content {
    padding: 1rem;
    overflow-y: auto;
    flex-grow: 1;
}

.cart-sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    background-color: #fff;
    border-top: 1px solid #dee2e6;
}

/* Stock limit warning styles */
.stock-limit-row {
    background-color: #fff5f5;
    border-left: 3px solid #dc3545;
    padding: 8px 16px;
    margin: 0;
    width: 100%;
    display: block;
    clear: both;
    position: relative;
}

.stock-limit-warning {
    font-size: 0.75rem;
    color: #dc3545;
    font-weight: 500;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    display: block;
    width: 100%;
}

.stock-limit-warning i {
    margin-right: 4px;
}

/* Disabled plus button when stock limit reached */
.quantity-btn.stock-limited {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
}

.quantity-btn.stock-limited:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
    transform: none;
}

.quantity-btn.stock-limited:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Quantity input when at stock limit */
.quantity-input.at-stock-limit {
    border-color: #dc3545;
    background-color: #fff5f5;
}

/* Cart Sidebar Overlay */
#cart-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

#cart-sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Cart Item Layout */
.sidebar-cart-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    min-height: 60px;
}

.sidebar-cart-item .d-flex {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    width: 100%;
}

.cart-item-image-col {
    flex-shrink: 0;
    width: 50px;
    margin-right: 0.5rem;
}

.cart-item-details-col {
    flex-grow: 1;
    min-width: 0;
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cart-item-quantity-col {
    flex-shrink: 0;
    width: 100px; /* Increased from 85px to accommodate larger buttons */
    margin: 0 1.25rem 0 1rem; /* Increased left margin from 0.5rem to 1rem to move further left */
    display: flex;
    justify-content: center;
}

.cart-item-remove-col {
    flex-shrink: 0;
    width: 40px; /* Increased from 32px for better spacing */
    margin-left: 1.25rem; /* Significantly increased separation */
    display: flex;
    justify-content: center;
}

/* Quantity Controls */
.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px; /* Add consistent gap between elements */
}

.quantity-btn {
    width: 32px !important; /* Force square size */
    height: 32px !important; /* Force square size */
    min-width: 32px !important; /* Prevent shrinking */
    min-height: 32px !important; /* Prevent shrinking */
    max-width: 32px !important; /* Prevent expanding */
    max-height: 32px !important; /* Prevent expanding */
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.75rem;
    line-height: 1;
    border-radius: 4px;
    flex-shrink: 0; /* Prevent flex shrinking */
}

.quantity-display {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    font-size: 0.8rem;
    margin: 0 0.5rem;
}

/* Remove up/down arrows from number inputs */
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

/* Ensure quantity buttons look like proper buttons */
.quantity-btn {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #495057;
    transition: all 0.15s ease-in-out;
}

.quantity-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    color: #212529;
}

.quantity-btn:active {
    background-color: #dee2e6;
    border-color: #adb5bd;
    color: #212529;
}

.quantity-btn:disabled {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
    opacity: 0.65;
}

/* Remove Button */
.sidebar-remove-btn {
    width: 32px; /* Keep consistent with quantity buttons */
    height: 32px; /* Keep consistent with quantity buttons */
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #dc3545;
    border: 1px solid #dc3545;
    background: transparent;
}

.sidebar-remove-btn:hover {
    background-color: #dc3545;
    color: white;
}

/* Cart Totals */
.cart-totals-section {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.cart-total-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.cart-final-total {
    font-size: 1rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 2px solid #dee2e6;
    font-weight: bold;
}

/* Free Shipping Messages */
.free-shipping-achieved {
    background: linear-gradient(135deg, #d1edff 0%, #e8f5e8 100%);
    border: 1px solid #b6e5d8;
    color: #0f5132;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.free-shipping-incentive {
    background: linear-gradient(135deg, #f8e6a0 0%, #f0d866 100%);
    border: 1px solid #d4a017;
    color: #2c1810;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ==========================================================================
   TOAST NOTIFICATION SYSTEM
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    margin-bottom: 10px;
    min-width: 300px;
    max-width: 400px;
    border-left: 4px solid #dc3545;
    /* animation: toastSlideIn 0.3s ease-out; */
    pointer-events: auto;
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    opacity: 1 !important;
}

.toast.success {
    border-left-color: #198754;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.2rem;
    margin-top: 2px;
}

.toast.success .toast-icon {
    color: #198754;
}

.toast.warning .toast-icon {
    color: #ffc107;
}

.toast.error .toast-icon {
    color: #dc3545;
}

.toast-content {
    flex-grow: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: #212529;
}

.toast-message {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.toast-close:hover {
    background-color: #f8f9fa;
    color: #495057;
}

@keyframes toastSlideIn {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.removing {
    animation: toastSlideOut 0.3s ease-in forwards;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
        max-width: none;
    }

    /* Mobile cart item adjustments */
    .sidebar-cart-item .d-flex {
        gap: 0.25rem;
        padding: 0.5rem 0;
    }

    .cart-item-image-col {
        width: 40px;
        margin-right: 0.25rem;
    }

    .cart-item-image-col img,
    .cart-item-image-col div {
        width: 40px !important;
        height: 40px !important;
    }

    .cart-item-details-col {
        padding: 0 0.25rem;
    }

    .cart-item-name {
        font-size: 0.8rem;
        line-height: 1.2;
    }

    .cart-item-price {
        font-size: 0.75rem;
    }

    .cart-item-quantity-col {
        width: 100px;
        margin: 0 1.25rem 0 1rem; /* Increased left margin from 0.5rem to 1rem to move further left */
    }

    .quantity-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
        font-size: 0.75rem;
    }

    .quantity-input {
        width: 30px;
        font-size: 0.75rem;
        padding: 2px;
    }

    .cart-item-remove-col {
        width: 32px;
        margin-left: 1.25rem; /* Significantly increased separation for mobile */
    }

    .sidebar-remove-btn {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    /* Mobile cart totals adjustments */
    .cart-totals-section {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .cart-total-line {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }

    .cart-final-total {
        font-size: 0.95rem;
        margin-top: 0.4rem;
        padding-top: 0.4rem;
    }

    .free-shipping-achieved,
    .free-shipping-incentive {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
        margin-bottom: 0.6rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .cart-sidebar {
        width: 100%;
        max-width: none; /* Allow full width on very small screens */
    }

    .cart-sidebar-header {
        padding: 0.5rem;
    }

    .cart-sidebar-content {
        padding: 0.5rem;
    }

    .cart-sidebar-footer {
        padding: 0.5rem;
    }

    /* Mobile cart totals adjustments */
    .cart-totals-section {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .cart-total-line {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }

    .cart-final-total {
        font-size: 0.9rem;
        margin-top: 0.4rem;
        padding-top: 0.4rem;
    }

    .free-shipping-achieved,
    .free-shipping-incentive {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .sidebar-cart-item .d-flex {
        gap: 0.2rem;
        padding: 0.4rem 0;
    }

    .cart-item-image-col {
        width: 35px;
        margin-right: 0.2rem;
    }

    .cart-item-image-col img,
    .cart-item-image-col div {
        width: 35px !important;
        height: 35px !important;
    }

    .cart-item-details-col {
        padding: 0 0.2rem;
    }

    .cart-item-name {
        font-size: 0.75rem;
    }

    .cart-item-price {
        font-size: 0.7rem;
    }

    .cart-item-quantity-col {
        width: 70px;
        margin: 0 0.8rem 0 0.6rem; /* Increased left margin from 0.4rem to 0.6rem for small mobile */
    }

    .quantity-btn {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;
        max-width: 20px !important;
        max-height: 20px !important;
        font-size: 0.65rem;
    }

    .quantity-input {
        width: 25px;
        font-size: 0.7rem;
        padding: 1px;
    }

    .cart-item-remove-col {
        width: 28px;
        margin-left: 0.8rem; /* Significantly increased separation for small mobile */
    }

    .sidebar-remove-btn {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }
}

/* Mobile Responsive Cart Sidebar */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100%; /* Full width on mobile */
        right: -100%; /* Start completely off-screen */
        max-width: 350px; /* Maximum width on larger mobile devices */
    }

    .cart-sidebar.open {
        right: 0;
    }

    .cart-sidebar-header {
        padding: 0.75rem;
    }

    .cart-sidebar-content {
        padding: 0.75rem;
    }

    .cart-sidebar-footer {
        padding: 0.75rem;
    }
}

/* ==========================================================================
   EMPTY CART MESSAGE STYLING
   ========================================================================== */

.empty-cart-message {
    padding: 2rem 1rem;
    text-align: center;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin: 1rem 0;
}

.empty-cart-message i {
    color: #6c757d;
    margin-bottom: 1rem;
}

.empty-cart-message h5 {
    color: #495057;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.empty-cart-message p {
    color: #6c757d;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.empty-cart-message .btn {
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.empty-cart-message .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Mobile responsive adjustments for empty cart */
@media (max-width: 768px) {
    .empty-cart-message {
        padding: 1.5rem 0.75rem;
        margin: 0.75rem 0;
    }

    .empty-cart-message i {
        font-size: 2.5rem !important;
        margin-bottom: 0.75rem;
    }

    .empty-cart-message h5 {
        font-size: 1.1rem;
    }

    .empty-cart-message p {
        font-size: 0.9rem;
        margin-bottom: 1.25rem;
    }

    .empty-cart-message .btn {
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* ==========================================================================
   CHECKOUT FORM VISIBILITY TRANSITIONS
   ========================================================================== */

.checkout-form-card {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.checkout-form-card.checkout-form-hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.checkout-form-card:not(.checkout-form-hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* When checkout form is hidden, center the order summary */
.checkout-wrapper.checkout-empty {
    justify-content: center;
}

.checkout-wrapper.checkout-empty .order-summary-card {
    max-width: 500px;
    width: 100%;
}

/* Chrome Mobile Specific Fixes */
@media screen and (max-width: 768px) {
    .checkout-form-card.checkout-form-hidden {
        /* More aggressive hiding for Chrome mobile */
        opacity: 0 !important;
        transform: translateY(-10px) !important;
        pointer-events: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }

    .checkout-form-card:not(.checkout-form-hidden) {
        /* Ensure visibility for Chrome mobile */
        opacity: 1 !important;
        transform: translateY(0) !important;
        visibility: visible !important;
        position: relative !important;
        left: auto !important;
    }

    /* Force layout recalculation for Chrome mobile */
    .checkout-wrapper.checkout-empty {
        justify-content: center !important;
        align-items: center !important;
    }

    .checkout-wrapper.checkout-empty .order-summary-card {
        max-width: 500px !important;
        width: 100% !important;
        margin: 0 auto !important;
    }
}

/* Chrome Mobile Body Class Fixes */
body.chrome-mobile .checkout-form-card.checkout-form-hidden {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
}

body.chrome-mobile .checkout-form-card:not(.checkout-form-hidden) {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
}

body.chrome-mobile .checkout-wrapper.checkout-empty {
    justify-content: center !important;
    align-items: center !important;
    min-height: 100vh !important;
}

body.chrome-mobile .checkout-wrapper.checkout-empty .order-summary-card {
    max-width: 500px !important;
    width: 100% !important;
    margin: 0 auto !important;
}
