/* ========================================
   Component Styles
   E-Commerce Moderno
*/

/* ========================================
   CSS Variables (Fallback for components)
   ======================================== */
:root {
    /* Fallback colors for components */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.85rem;
}

.btn-lg {
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: 1.1rem;
}

/* ========================================
   Product Card
   ======================================== */
.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    position: relative;
}

.product-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

.product-badge {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    background: var(--accent-gradient);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1;
    text-transform: uppercase;
}

.product-image {
    width: 100%;
    height: 250px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    color: var(--accent-primary);
    position: relative;
    overflow: hidden;
}

.product-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

.product-icon {
    position: relative;
    z-index: 1;
    transition: transform var(--transition-normal);
}

.product-card:hover .product-icon {
    transform: scale(1.1);
}

.product-actions {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    opacity: 0;
    transform: translateX(10px);
    transition: all var(--transition-normal);
}

.product-card:hover .product-actions {
    opacity: 1;
    transform: translateX(0);
}

.product-action-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.product-action-btn:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.product-info {
    padding: var(--spacing-lg);
}

.product-category {
    font-size: 0.8rem;
    color: var(--accent-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-xs);
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    line-height: 1.3;
}

.product-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-md);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.product-price span {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: line-through;
    margin-left: var(--spacing-xs);
}

.product-rating {
    display: flex;
    gap: 2px;
    color: var(--warning);
    font-size: 0.85rem;
}

.add-to-cart-btn {
    width: 100%;
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-fast);
}

.add-to-cart-btn:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.add-to-cart-btn.added {
    background: var(--success);
    border-color: transparent;
    color: white;
}

/* ========================================
   Form Elements
   ======================================== */
.form-group {
    position: relative;
}

.form-group.error input {
    border-color: var(--error);
}

.form-error {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: var(--spacing-xs);
    display: none;
}

.form-group.error .form-error {
    display: block;
}

/* ========================================
   Loading States
   ======================================== */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: 100px;
    right: var(--spacing-lg);
    z-index: var(--z-tooltip);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--accent-primary);
    animation: toastIn 0.3s ease;
    min-width: 300px;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-icon {
    font-size: 1.25rem;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-message {
    flex: 1;
    font-size: 0.9rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ========================================
   Spinner
   ======================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--spacing-3xl);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   Badge
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* ========================================
   Tooltip
   ======================================== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
    z-index: var(--z-tooltip);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 8px);
}

/* ========================================
   Progress Bar
   ======================================== */
.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ========================================
   Divider
   ======================================== */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--spacing-lg) 0;
}

.divider-text {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ========================================
   Avatar
   ======================================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}

.avatar-lg {
    width: 60px;
    height: 60px;
    font-size: 1.25rem;
}

/* ========================================
   Image Placeholder
   ======================================== */
.img-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2rem;
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   Selection
   ======================================== */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* ========================================
   Focus States
   ======================================== */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .header,
    .footer,
    .cart-sidebar,
    .mobile-menu {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .product-card,
    .checkout-form,
    .checkout-summary {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
