/* ========================================
   WHOLESALER APP - MOBILE-FIRST CSS
   ======================================== */

/* ===== GLOBAL STYLES ===== */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --accent-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
}

/* Ensure content is above mobile bottom nav */
@media (max-width: 991.98px) {
    body {
        padding-bottom: 70px;
    }
}

/* ===== LOGO ===== */
.logo {
    height: 40px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

@media (min-width: 768px) {
    .logo {
        height: 50px;
        max-width: 200px;
    }
}

/* ===== NAVIGATION ===== */
.navbar {
    z-index: 1030;
}

.nav-link {
    font-size: 0.95rem;
    padding: 0.5rem 1rem !important;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.navbar-toggler {
    border: none;
    padding: 0.5rem;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* Dropdown menu z-index fix */
.dropdown-menu {
    z-index: 1050 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.navbar .dropdown-menu {
    position: absolute !important;
}

.nav-item.dropdown {
    position: relative;
}

/* ===== BUTTONS ===== */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-success {
    background-color: var(--accent-color);
}

.btn-success:hover {
    background-color: #218838;
}

/* Mobile: Make buttons full-width on small screens */
@media (max-width: 575.98px) {
    .btn-block-mobile {
        width: 100%;
        display: block;
    }
}

/* Touch-friendly button sizing for mobile */
@media (max-width: 767.98px) {
    .btn {
        padding: 0.75rem 1.5rem;
        min-height: 44px; /* Apple's recommended minimum */
    }
}

/* ===== CARDS ===== */
.card {
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    position: relative;
    z-index: 1;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 2;
}

.card-img-top {
    height: 200px;
    object-fit: cover;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

@media (min-width: 768px) {
    .card-img-top {
        height: 250px;
    }
}

/* Password visibility toggle */
.password-toggle-wrapper {
    position: relative;
}

.password-toggle-input {
    padding-right: 2.5rem !important;
}

.password-toggle-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #9ca3af;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.password-toggle-btn i {
    font-size: 1.1rem;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus {
    color: #4b5563;
}

/* ===== HERO BANNER ===== */
.hero-banner {
    position: relative;
    min-height: 300px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    overflow: hidden;
}

@media (min-width: 768px) {
    .hero-banner {
        min-height: 400px;
    }
}

@media (min-width: 992px) {
    .hero-banner {
        min-height: 500px;
    }
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 2rem 1rem;
}

.hero-content h1 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

@media (max-width: 767.98px) {
    .hero-content h1 {
        font-size: 1.75rem !important; /* Override bootstrap display classes */
    }
}

.hero-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

@media (min-width: 768px) {
    .hero-content h1 {
        font-size: 3rem;
    }
    .hero-content p {
        font-size: 1.3rem;
    }
}

/* ===== PRODUCT GRID ===== */
.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 576px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== PRODUCT CARD ===== */
.product-card {
    position: relative;
}

.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.product-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

.product-stock {
    font-size: 0.9rem;
}

/* ===== FORMS ===== */
.form-control, .form-select {
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    font-size: 1rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Mobile: Larger form inputs for touch */
@media (max-width: 767.98px) {
    .form-control, .form-select {
        padding: 0.875rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ===== MOBILE BOTTOM NAVIGATION ===== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.5rem 0;
    z-index: 1020;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    text-decoration: none;
    padding: 0.5rem;
    font-size: 0.75rem;
    min-width: 60px;
    transition: color 0.3s ease;
}

.mobile-bottom-nav .nav-item i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.mobile-bottom-nav .nav-item:hover,
.mobile-bottom-nav .nav-item.active {
    color: var(--primary-color);
}

/* ===== BADGES ===== */
.badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 0.375rem;
}

/* ===== IMAGES ===== */
img {
    max-width: 100%;
    height: auto;
}

.img-thumbnail {
    padding: 0.25rem;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
}

/* ===== TABLES (Responsive) ===== */
@media (max-width: 767.98px) {
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack table on mobile */
    .table-mobile-stack thead {
        display: none;
    }
    
    .table-mobile-stack tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        padding: 1rem;
    }
    
    .table-mobile-stack td {
        display: block;
        text-align: right;
        border: none;
        padding: 0.5rem 0;
    }
    
    .table-mobile-stack td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: #6c757d;
    }
}

/* ===== SPACING UTILITIES ===== */
.section-padding {
    padding: 3rem 0;
}

@media (min-width: 768px) {
    .section-padding {
        padding: 4rem 0;
    }
}

/* ===== ORDER STATUS BADGES ===== */
.status-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.status-pending { background-color: #ffc107; color: #000; }
.status-confirmed { background-color: #17a2b8; color: white; }
.status-processing { background-color: #007bff; color: white; }
.status-shipped { background-color: #6f42c1; color: white; }
.status-delivered { background-color: #28a745; color: white; }
.status-cancelled { background-color: #dc3545; color: white; }

/* ===== LOADING SPINNER ===== */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

/* ===== STICKY ELEMENTS ===== */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

/* ===== ACCESSIBILITY ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== TOUCH OPTIMIZATION ===== */
@media (hover: none) and (pointer: coarse) {
    /* Touch device specific styles */
    a, button, .btn {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .navbar, .mobile-bottom-nav, footer, .btn {
        display: none !important;
    }
    
    body {
        padding-bottom: 0;
    }
}
