/**
 * Customer Portal Unified Design System
 * Consistent look and feel across all customer pages
 */

/* Global typography */
body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.5;
    color: #111827;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ========================================
   Page Layout & Structure
   ======================================== */

/* Soft section backgrounds for portal pages */
.section-soft {
    background: linear-gradient(180deg, #f9fafb 0%, #ffffff 100%);
}

.section-soft-alt {
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
}

/* Navbar logo wrapper - make uploaded logo look like a clean circular badge */
.portal-logo-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 9999px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
    overflow: hidden;
}

.portal-logo-img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 9999px;
    object-fit: contain;
}

/* Desktop navbar left links - simple, flat style similar to reference */
.portal-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.9rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: #e5e7eb;
    border-radius: 9999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.portal-nav-link:hover,
.portal-nav-link:focus {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.13);
    text-decoration: none;
}

/* Prevent Bootstrap from turning navbar links blue on hover */
.navbar.navbar-dark .navbar-nav .nav-link:hover,
.navbar.navbar-dark .navbar-nav .nav-link:focus {
    color: #f9fafb !important;
}

@media (max-width: 991.98px) {
    /* In the collapsed mobile menu, keep links full-width and readable */
    .portal-nav-link {
        width: 100%;
        border-radius: 0.75rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Right-side navbar icon buttons (account, cart) */
.portal-icon-button {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 46px;
    border-radius: 9999px;
    color: #e5e7eb;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.portal-icon-button i {
    font-size: 1.3rem;
}

.portal-icon-label {
    font-size: 0.7rem;
    line-height: 1;
    margin-top: 2px;
}

.portal-icon-button:hover,
.portal-icon-button:focus {
    color: #e5e7eb;
    background-color: transparent;
    text-decoration: none;
    transform: translateY(-1px);
}

.portal-cart-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9999px;
    background: #f97316; /* orange like reference badge */
    color: #ffffff;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(88, 28, 135, 0.9); /* edge that blends with navbar gradient */
}

@media (max-width: 991.98px) {
    .portal-icon-button {
        width: 46px;
        height: 46px;
        flex-direction: row;
        gap: 0.25rem;
    }
    .portal-icon-label {
        font-size: 0.75rem;
        margin-top: 0;
    }
}

.portal-container {
    padding: 2.5rem 1.25rem; /* more breathing room around main content */
    min-height: calc(100vh - 300px);
    max-width: 1200px; /* keep content centered on wide screens */
    margin: 0 auto;
}

.portal-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ecf0f1;
}

.portal-header h1 {
    color: #2c3e50;
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.portal-header h1 i {
    color: #667eea;
}

.portal-header .subtitle {
    color: #7f8c8d;
    font-size: 1rem;
}

/* ========================================
   Cards & Containers
   ======================================== */

.portal-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.portal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.portal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ecf0f1;
}

.portal-card-header h2,
.portal-card-header h3 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-card-header h2 i,
.portal-card-header h3 i {
    color: #667eea;
}

/* ========================================
   Buttons & Actions
   ======================================== */

.btn-portal-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-portal-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-portal-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-portal-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-portal-success {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-portal-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(67, 233, 123, 0.4);
    color: white;
}

/* ========================================
   Stat Boxes (matching dashboard)
   ======================================== */

.stat-box {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
}

.stat-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.stat-box-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-box-icon.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stat-box-icon.success {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.stat-box-icon.warning {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.stat-box-icon.info {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.stat-box-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.stat-box-label {
    color: #7f8c8d;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   Status Badges
   ======================================== */

.status-badge {
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-confirmed {
    background: #d1ecf1;
    color: #0c5460;
}

.status-shipped {
    background: #cce5ff;
    color: #004085;
}

.status-delivered {
    background: #d4edda;
    color: #155724;
}

.status-cancelled {
    background: #f8d7da;
    color: #721c24;
}

.status-in-stock {
    background: #d4edda;
    color: #155724;
}

.status-low-stock {
    background: #fff3cd;
    color: #856404;
}

.status-out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

/* ========================================
   List Items (Orders, Products, etc.)
   ======================================== */

.portal-list-item {
    padding: 1.25rem;
    border-bottom: 1px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}

/* Variant for rows that need stacked content instead of side-by-side */
.portal-list-item-stacked {
    display: block;
}

.portal-list-item:last-child {
    border-bottom: none;
}

.portal-list-item:hover {
    background: #f8f9fa;
}

.portal-list-item .item-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 1rem;
}

.portal-list-item .item-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.portal-list-item .item-subtitle {
    font-size: 0.85rem;
    color: #95a5a6;
}

.portal-list-item .item-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
}

/* ========================================
   Empty States
   ======================================== */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state i {
    font-size: 4rem;
    color: #bdc3c7;
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    color: #7f8c8d;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #95a5a6;
    margin-bottom: 2rem;
}

/* ========================================
   Forms
   ======================================== */

.portal-form .form-label {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.portal-form .form-control,
.portal-form .form-select {
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.portal-form .form-control:focus,
.portal-form .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.portal-form .form-text {
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* ========================================
   Tables
   ======================================== */

.portal-table {
    width: 100%;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.portal-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.portal-table thead th {
    padding: 1rem;
    font-weight: 600;
    border: none;
}

.portal-table tbody td {
    padding: 1rem;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.portal-table tbody tr:last-child td {
    border-bottom: none;
}

.portal-table tbody tr:hover {
    background: #f8f9fa;
}

/* ========================================
   Alerts & Messages
   ======================================== */

.portal-alert {
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.portal-alert.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.portal-alert.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
}

.portal-alert.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.portal-alert.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

/* ========================================
   Breadcrumbs
   ======================================== */

.portal-breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
}

.portal-breadcrumb .breadcrumb-item {
    color: #7f8c8d;
}

.portal-breadcrumb .breadcrumb-item.active {
    color: #667eea;
    font-weight: 600;
}

.portal-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: #bdc3c7;
}

/* ========================================
   Product Cards
   ======================================== */

.product-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.product-meta .product-quick-view {
    border: none;
    background: transparent;
    padding: 0.25rem 0;
    color: #4f46e5;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.product-meta .product-quick-view i {
    font-size: 1rem;
}

.product-meta .product-quick-view:hover,
.product-meta .product-quick-view:focus {
    text-decoration: underline;
    color: #4338ca;
}

.product-meta .product-category-link {
    text-decoration: none;
    display: block;
}

.product-meta .product-sku {
    font-size: 0.8rem;
    color: #64748b;
    display: block;
}

.product-card-portal {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card-portal:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.product-card-portal .product-image-link {
    display: block;
    width: 100%;
    height: 250px;
    overflow: hidden;
    background: #f8fafc;
    position: relative;
}

.product-card-portal .product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    padding: 1rem;
}

.product-card-portal:hover .product-image {
    transform: scale(1.05);
}

.product-card-portal .product-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #cbd5e0;
}

.product-card-portal .product-info {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 0.25rem;
}

.product-card-portal .product-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: 2.8rem;
}

.product-card-portal .product-description {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    min-height: 2.5rem;
}

.product-card-portal .product-price {
    color: #27ae60;
    font-weight: 700;
    font-size: 1.25rem;
}

.product-card-portal .card-img-top {
    height: 200px;
    object-fit: cover;
}

.product-card-portal .card-body {
    padding: 1.25rem;
}

/* Ensure form selects show full text without truncation */
.form-select {
    text-overflow: ellipsis;
    overflow: visible;
    white-space: normal;
}

/* Product attributes card on product detail page */
.product-attributes-card dl {
    margin-bottom: 0;
}

.product-attributes-card dt {
    font-weight: 600;
    color: #64748b;
}

.product-attributes-card dd {
    margin-bottom: 0.35rem;
}

/* Related Products Section */
.related-products-container {
    overflow: hidden;
}

.related-products-scroll {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.related-product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
}

.related-product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.related-product-image {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.related-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.5rem;
    transition: transform 0.2s ease;
}

.related-product-card:hover .related-product-image img {
    transform: scale(1.05);
}

.related-product-info {
    padding: 0.75rem;
}

.related-product-title {
    font-size: 0.8rem;
    color: #475569;
    margin-bottom: 0.35rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2rem;
}

.related-product-price {
    font-size: 0.9rem;
    font-weight: 600;
    color: #10b981;
    margin-bottom: 0;
}

/* Mobile: horizontal scroll */
@media (max-width: 768px) {
    .related-products-scroll {
        display: flex;
        overflow-x: auto;
        scroll-behavior: smooth;
        gap: 0.75rem;
        padding-bottom: 0.75rem;
        -webkit-overflow-scrolling: touch;
    }
    
    .related-product-card {
        flex: 0 0 140px;
        min-width: 140px;
    }
    
    /* Show scrollbar on mobile for better UX */
    .related-products-scroll::-webkit-scrollbar {
        height: 4px;
    }
    
    .related-products-scroll::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 2px;
    }
    
    .related-products-scroll::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 2px;
    }
    
    .related-products-scroll::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
}

/* ========================================
   Quantity Controls
   ======================================== */

.quantity-control {
    display: inline-flex;
    align-items: center;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    overflow: hidden;
}

.quantity-control button {
    background: white;
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.quantity-control button:hover {
    background: #f8f9fa;
}

.quantity-control input {
    border: none;
    width: 60px;
    text-align: center;
    font-weight: 600;
}

/* ========================================
   Mobile Responsiveness
   ======================================== */

@media (max-width: 768px) {
    .portal-container {
        padding: 1.5rem 1rem; /* a bit more vertical room on mobile */
    }
    
    .portal-header h1 {
        font-size: 1.5rem;
    }
    
    .portal-card {
        padding: 1rem;
    }
    
    .stat-box-value {
        font-size: 1.5rem;
    }
    
    .btn-portal-primary,
    .btn-portal-secondary,
    .btn-portal-success {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .portal-table {
        font-size: 0.85rem;
    }
    
    .portal-table thead th,
    .portal-table tbody td {
        padding: 0.75rem 0.5rem;
    }
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease-out;
}

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

.pulse {
    animation: pulse 2s ease-in-out infinite;
}
