/* ===================================
   AGRISYNCH - Buyer Dashboard Styles
   Isolated styles for buyer dashboard
   Matching farmer dashboard structure
   =================================== */

/* Buyer Dashboard Container */
#buyerDashboard {
    display: none;
    background: var(--primary-dark);
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

#buyerDashboard.page.active {
    display: block !important;
}

/* Search and Filter Section */
.search-filter-section {
    margin-bottom: 28px;
    width: 100%;
    max-width: 100%;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0;
    height: 52px;
    width: 100%;
    gap: 12px;
    transition: all 0.2s ease;
}

.search-bar i {
    color: var(--text-secondary);
    font-size: 17px;
    flex-shrink: 0;
    padding-left: 18px;
}

.search-bar input {
    flex: 1;
    background: var(--tertiary-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0 18px;
    height: 52px;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    min-width: 0;
    transition: all 0.2s ease;
}

.search-bar input:focusholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.search-bar:focus-within {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15);
    transform: translateY(-1px);
}

/* Category Chips */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.category-chips.show {
    max-height: 200px;
    opacity: 1;
}

.category-chip {
    background: var(--tertiary-dark);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-chip:hover {
    background: var(--secondary-dark);
    border-color: var(--primary-green);
    transform: translateY(-2px);
}

.category-chip.active {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: white;
}

/* Remove old category filter styles */
.category-filter {
    display: none;
}

/* Hide old elements */
#productSort,
.filter-group:has(#productSort),
.search-filter-wrapper,
.search-input-wrapper,
.search-input-container,
.filter-group,
.filter-label,
.filter-select {
    display: none !important;
}

/* Checkout Button */
#checkoutBtn {
    width: 100%;
    margin-top: 16px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#checkoutBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

#checkoutBtn:active {
    transform: translateY(0);
}

/* Hamburger Menu - Hidden on desktop */
.navbar-hamburger {
    display: none !important;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    z-index: 1100;
    position: relative;
    margin-left: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Hide mobile-only navigation items on desktop */
#buyerNotificationsBtnMobile,
#buyerSettingsBtnMobile,
#buyerLogoutBtnMobile {
    display: none !important;
}

.navbar-hamburger span {
    width: 24px;
    height: 3px;
    background: var(--primary-green);
    border-radius: 2px;
    transition: all 0.3s ease;
    display: block;
    pointer-events: none;
}

.navbar-hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.navbar-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.navbar-hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.nav-divider {
    width: 100%;
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
    display: none;
}

.nav-badge {
    margin-left: auto;
    background: #ff4444;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
}

/* Desktop styles */
@media (min-width: 769px) {
    #buyerDashboard .navbar-menu,
    #buyerNavMenu {
        display: none !important;
    }
    
    .navbar-right {
        display: flex !important;
        gap: 8px;
        margin-left: auto;
    }
    
    .navbar-hamburger {
        display: none !important;
    }
    
    /* Desktop notifications dropdown */
    #notificationsDropdown {
        left: auto !important;
        right: 24px !important;
        width: 350px !important;
        max-width: 350px !important;
        margin: 0 !important;
    }
}

/* Buyer Responsive */
@media (max-width: 768px) {
    #buyerDashboard .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    #buyerDashboard .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    /* Mobile Search & Filter Section */
    .search-filter-section {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .search-bar {
        height: 52px;
        padding: 0 16px;
    }
    
    .search-bar i {
        font-size: 17px;
        margin-right: 12px;
    }
    
    .search-bar input {
        font-size: 16px;
    }
    
    .category-filter {
        width: 100%;
        gap: 12px;
    }
    
    .category-filter label {
        min-width: 80px;
        font-size: 14px;
    }
    
    .category-filter select {
        flex: 1;
        min-width: 0;
        height: 52px;
        font-size: 15px;
    }
    
    /* Mobile navbar with hamburger */
    .navbar-hamburger {
        display: flex !important;
    }
    
    /* Show mobile menu items */
    #buyerNotificationsBtnMobile,
    #buyerSettingsBtnMobile,
    #buyerLogoutBtnMobile {
        display: flex !important;
    }
    
    .navbar-container {
        display: flex;
        flex-wrap: nowrap;
        padding: 10px !important;
        gap: 0;
        position: relative;
        align-items: center;
        justify-content: space-between;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .navbar-logo {
        order: 1;
        font-size: 14px;
    }
    
    .navbar-logo i {
        font-size: 16px;
    }
    
    .navbar-right {
        display: none !important;
        order: 3;
    }
    
    .navbar-hamburger {
        order: 4;
        margin-left: 0;
    }
    
    .nav-divider {
        display: block;
    }
    
    .navbar-menu {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 280px;
        height: calc(100vh - 60px);
        background: var(--secondary-dark);
        border-right: 1px solid var(--border-color);
        flex-direction: column;
        padding: 16px;
        gap: 8px;
        transition: left 0.3s ease;
        z-index: 999;
        overflow-y: auto;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
        pointer-events: auto;
    }
    
    .navbar-menu.active {
        left: 0;
    }
    
    .nav-link {
        font-size: 14px;
        padding: 12px 16px;
        white-space: nowrap;
        width: 100%;
        justify-content: flex-start;
        border-radius: 8px;
        display: flex;
        align-items: center;
        gap: 12px;
        border-bottom: none !important;
        pointer-events: auto;
        cursor: pointer;
    }
    
    .nav-link span {
        display: inline !important;
        opacity: 1 !important;
        visibility: visible !important;
        color: var(--text-primary) !important;
        font-size: 14px !important;
    }
    
    .nav-link i {
        font-size: 18px;
        width: 20px;
        flex-shrink: 0;
    }
    
    .navbar-right {
        gap: 8px;
    }
    
    .btn-icon {
        padding: 8px;
        font-size: 16px;
    }
    
    /* Dashboard content spacing */
    .dashboard-container {
        padding: 12px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .welcome-header {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .welcome-header h1 {
        font-size: 20px;
    }
    
    .welcome-header p {
        font-size: 13px;
    }
}

/* Extra Small Mobile (< 480px) */
@media (max-width: 480px) {
    .search-filter-section {
        margin-bottom: 12px;
    }
    
    .search-filter-wrapper {
        gap: 10px;
    }
    
    .search-input {
        font-size: 14px;
        padding: 11px 11px 11px 38px;
        min-height: 44px;
    }
    
    .search-icon {
        left: 12px;
        font-size: 15px;
    }
    
    .filter-select {
        font-size: 13px;
        padding: 11px 8px;
        min-height: 44px;
        padding-right: 34px;
        background-size: 16px;
        background-position: right 8px center;
    }
    
    .filter-label {
        font-size: 12px;
        min-width: 60px;
    }
    
    .filter-group {
        gap: 6px;
    }
    
    #buyerDashboard .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    #buyerDashboard .product-card {
        min-height: auto;
    }
    
    #buyerDashboard .product-card-image {
        aspect-ratio: 1;
        font-size: 28px;
    }
    
    #buyerDashboard .product-card-body {
        padding: 10px;
    }
    
    #buyerDashboard .product-card h3 {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    #buyerDashboard .product-card p {
        font-size: 11px;
        margin-bottom: 6px;
        line-height: 1.3;
    }
    
    #buyerDashboard .product-price {
        font-size: 15px;
    }
    
    .welcome-header h1 {
        font-size: 18px !important;
    }
    
    .welcome-header p {
        font-size: 12px !important;
    }
}

/* Specific optimization for 360px width screens */
@media (max-width: 380px) {
    .dashboard-container {
        padding: 10px;
    }
    
    .welcome-header h1 {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .welcome-header p {
        font-size: 11px;
    }
    
    .search-filter-section {
        margin-bottom: 10px;
    }
    
    .search-filter-wrapper {
        gap: 10px;
    }
    
    .search-input {
        font-size: 13px;
        padding: 10px 10px 10px 36px;
        min-height: 42px;
        border-radius: 8px;
    }
    
    .search-icon {
        left: 11px;
        font-size: 14px;
    }
    
    .filter-select {
        font-size: 12px;
        padding: 10px 6px;
        min-height: 42px;
        padding-right: 32px;
        background-size: 14px;
        background-position: right 6px center;
        border-radius: 8px;
    }
    
    .filter-label {
        font-size: 11px;
        min-width: 55px;
    }
    
    .filter-group {
        gap: 5px;
    }
    
    #buyerDashboard .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
}

/* Buyer Search Bar */
#buyerDashboard .search-bar {
    position: relative;
    max-width: 600px;
    margin: 0 auto 24px;
}

#buyerDashboard .search-bar input {
    width: 100%;
    padding: 12px 44px;
    background: var(--tertiary-dark);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

#buyerDashboard .search-bar input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.1);
}

#buyerDashboard .search-bar input::placeholder {
    color: var(--gray-medium);
}

#buyerDashboard .search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-medium);
    font-size: 14px;
}

/* Buyer Stats Grid */
#buyerDashboard .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

#buyerDashboard .stat-card {
    background: var(--secondary-dark);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: var(--transition);
}

#buyerDashboard .stat-card:hover {
    border-color: var(--primary-green);
    transform: translateY(-2px);
}

/* Buyer Products Grid */
#buyerDashboard .products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    #buyerDashboard .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
    }
}

/* Buyer Orders Section */
#buyerDashboard .orders-grid {
    display: grid;
    gap: 16px;
}

/* Buyer Cart Section */
#buyerDashboard .cart-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Settings Modal Tabs */
.settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.settings-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.settings-tab:hover {
    color: var(--text-primary);
    background: var(--tertiary-dark);
}

.settings-tab.active {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

.settings-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--tertiary-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
}

.settings-label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
}

.settings-description {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    transition: var(--transition);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary-green);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Order Items - Desktop Layout */
.order-item {
    padding: 14px 20px;
    background: #2d3748;
    border: 1px solid #3d4a5c;
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.order-item:hover {
    border-color: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.order-item:active {
    transform: translateY(0);
}

/* Desktop: Horizontal layout */
.order-card-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
}

.order-id-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 180px;
}

.order-id {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
}

.order-price {
    font-size: 22px;
    font-weight: 700;
    color: #2ecc71;
    flex: 0.6;
    text-align: left;
}

.order-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #94a3b8;
    flex: 1;
}

.order-date i {
    font-size: 12px;
}

.order-status {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
}

.order-status.pending {
    background: #f59e0b;
    color: #ffffff;
}

.order-status.cancelled {
    background: #ef4444;
    color: #ffffff;
}

.order-status.confirmed {
    background: #3b82f6;
    color: #ffffff;
}

.order-status.delivered {
    background: #10b981;
    color: #ffffff;
}

.cancel-order-btn {
    background: transparent;
    border: 1px solid #4a5568;
    color: #e2e8f0;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cancel-order-btn i {
    font-size: 12px;
}

.cancel-order-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.cancel-order-btn:active {
    transform: scale(0.98);
}

.view-order-btn {
    background: transparent;
    border: 1px solid #4a5568;
    color: #e2e8f0;
    padding: 8px 20px;
    border-ra6px 16px;
    border-radius: 6px;
    font-size: 12500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.view-order-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
}

.view-order-btn:active {
    transform: scale(0.98);
}

.order-complete-badge {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Mobile: Compact vertical layout */
@media (max-width: 768px) {
    .order-item {
        padding: 14px;
        margin-bottom: 10px;
        border-radius: 8px;
    }
    
    .order-card-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .order-id-section {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-width: auto;
    }
    
    .order-id {
        font-size: 14px;
        font-weight: 600;
        color: #e2e8f0;
    }
    
    .order-price {
        font-size: 22px;
        font-weight: 700;
        text-align: left;
        flex: none;
    }
    
    .order-date {
        font-size: 12px;
        gap: 6px;
        color: #94a3b8;
        flex: none;
    }
    
    .order-date i {
        font-size: 11px;
    }
    
    .order-status {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .view-order-btn {
        width: 100%;
        justify-content: center;
        padding: 9px 16px;
        font-size: 12px;
    }
        flex: 1;
        justify-content: center;
        min-width: 100px;
        padding: 8px 16px;
    }
    
    .order-right {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .order-status {
        text-align: center;
        font-size: 12px;
        padding: 6px 12px;
        font-weight: 600;
    }
    
    .cancel-order-btn {
        width: 100%;
        padding: 8px 12px;
        font-size: 12px;
        text-align: center;
    }
    
    .cancel-order-btn i {
        font-size: 10px;
    }
    
    .order-complete-badge {
        text-align: center;
        font-size: 11px;
        padding: 4px 0;
    }
}

/* Orders section container */
#allOrdersContainer {
    padding: 0;
}

@media (max-width: 768px) {
    #allOrdersContainer {
        padding: 0;
    }
    
    .orders-section {
        padding: 0;
    }
    
    /* Settings Modal Mobile Fixes */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        padding: 16px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-content h2 {
        font-size: 18px;
        margin-bottom: 16px;
    }
    
    .settings-tabs {
        margin-bottom: 16px;
        margin-left: -16px;
        margin-right: -16px;
        padding: 0 16px;
    }
    
    .settings-tab {
        padding: 10px 12px;
        font-size: 13px;
        gap: 6px;
    }
    
    .settings-tab i {
        font-size: 13px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 14px;
        padding: 10px;
    }
    
    .settings-option {
        padding: 16px;
        margin-bottom: 10px;
    }
    
    .settings-label {
        font-size: 13px;
    }
    
    .settings-description {
        font-size: 12px;
    }
}
