/* Global Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.loading-spinner {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
}

.loading-logo {
    width: 80px;
    height: 80px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    object-fit: cover;
    z-index: 2;
}

.loading-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.loading-ring:nth-child(2) {
    border-top-color: transparent;
    border-right-color: var(--primary-color);
    animation-duration: 1.5s;
    animation-direction: reverse;
    box-shadow: 0 0 15px rgba(107, 142, 35, 0.3);
}

.loading-ring:nth-child(3) {
    border-top-color: transparent;
    border-bottom-color: white;
    animation-duration: 2s;
    opacity: 0.7;
}

.loading-text {
    font-size: 1.2rem;
    color: white;
    font-weight: 600;
    margin-top: 15px;
    animation: pulse 1.5s ease-in-out infinite;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   Mini Loading Spinner (for buttons & small areas)
   ============================================ */
.loading-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading-mini-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(107, 142, 35, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-mini-spinner.white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

/* ============================================
   Item Loading Overlay (for cart rows, cards)
   ============================================ */
.item-loading-container {
    position: relative;
}

.item-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: inherit;
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.item-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.item-loading-spinner {
    position: relative;
    width: 50px;
    height: 50px;
}

.item-loading-spinner .spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.item-loading-spinner .spinner-ring:nth-child(2) {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-top-color: var(--secondary-color);
    animation-duration: 1.2s;
    animation-direction: reverse;
}

.item-loading-spinner .spinner-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

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

.toast.success .toast-icon {
    background: linear-gradient(135deg, #28a745, #34ce57);
}

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

.toast.error .toast-icon {
    background: linear-gradient(135deg, #dc3545, #e74c3c);
}

.toast.info {
    border-left-color: var(--primary-color);
}

.toast.info .toast-icon {
    background: linear-gradient(135deg, var(--primary-color), #8ab846);
}

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

.toast.warning .toast-icon {
    background: linear-gradient(135deg, #ffc107, #ffca2c);
}

.toast-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-icon i {
    color: white;
    font-size: 1rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--dark-color);
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.toast-message {
    color: #666;
    font-size: 0.85rem;
}

.toast-close {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #333;
}

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

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

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

/* ============================================
   Button Loading State
   ============================================ */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn.loading span {
    visibility: hidden;
}

/* ============================================
   Cart Quantity Button Loading
   ============================================ */
.cart-quantity button.loading {
    position: relative;
    pointer-events: none;
    color: transparent;
}

.cart-quantity button.loading::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    top: 50%;
    left: 50%;
    margin-left: -6px;
    margin-top: -6px;
    border: 2px solid rgba(107, 142, 35, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ============================================
   Page Transition Loading
   ============================================ */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 99999;
    overflow: hidden;
}

.page-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    animation: pageLoadingBar 1.5s ease infinite;
}

@keyframes pageLoadingBar {
    0% {
        left: -30%;
    }
    100% {
        left: 100%;
    }
}

/* Mobile Toast Adjustments */
@media (max-width: 480px) {
    .toast-container {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 20px;
    }

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