/* Custom CSS for Morendat Farm */

:root {
    --primary-color: #dc3545;
    --secondary-color: #6c757d;
    --dark-color: #000000;
    --light-color: #ffffff;
    --muted-color: #6c757d;
    --border-color: #495057;
}

/* Force consistent primary color across all browsers */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #ffffff !important;
}

.btn-primary:hover {
    background-color: #c82333 !important;
    border-color: #bd2130 !important;
}

.text-primary,
.text-primary:hover,
.text-primary:focus {
    color: #dc3545 !important;
}

.bg-primary {
    background-color: #dc3545 !important;
}

.border-primary {
    border-color: #dc3545 !important;
}

/* Global Styles */
html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: var(--dark-color) !important;
    color: var(--light-color) !important;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Sticky Footer Layout */
main {
    flex: 1 0 auto;
    padding-top: 0; /* Ensure no extra padding that might cause overlapping */
}

footer {
    flex-shrink: 0;
}

/* Ensure proper spacing with sticky navbar */
.sticky-top ~ main,
.sticky-top + main {
    padding-top: 0;
}

/* Carousel Styles */
.carousel-item {
    height: 70vh;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

.carousel-item img {
    object-fit: cover;
    height: 100%;
    width: 100%;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    background: #333; /* Fallback background if image fails to load */
}

/* Hide broken images and show background instead */
.carousel-item img[src=""],
.carousel-item img:not([src]),
.carousel-item img[src*="placeholder"] {
    display: none;
}

/* When images fail to load, show a gradient background */
.carousel-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #dc3545, #6c757d);
    z-index: -1;
}

/* Ensure carousel transitions work properly */
.carousel-item {
    transition: transform 0.6s ease-in-out;
}

.carousel-item-next,
.carousel-item-prev,
.carousel-item.active {
    display: block;
}

.carousel-caption {
    position: absolute !important;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    border-radius: 0;
    padding: 1.5rem 2rem 1rem 2rem;
    text-align: center;
    max-width: none;
    width: 100%;
    z-index: 15;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.carousel-caption h1 {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 0.25rem;
    font-size: 1.25rem !important;
}

.carousel-caption p {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.carousel-caption .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

.carousel-indicators [data-bs-target] {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 5px;
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
}

.carousel-indicators .active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.carousel-control-prev,
.carousel-control-next {
    width: 5%;
    opacity: 0.8;
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    opacity: 1;
}

/* Responsive carousel adjustments */
@media (max-width: 768px) {
    .carousel-item {
        height: 60vh;
        min-height: 400px;
    }
    
    .carousel-caption {
        position: absolute !important;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
        padding: 3rem 1rem 1rem 1rem;
        max-width: none;
        width: 100%;
        text-align: center;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .carousel-caption h1 {
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }
    
    .carousel-caption p {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .carousel-caption .btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
}

/* Custom Bootstrap Overrides */
.bg-dark-subtle {
    background-color: #1a1a1a !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Navigation Styles */
.navbar-brand img {
    filter: brightness(0) invert(1);
}

.navbar-dark .navbar-nav .nav-link {
    color: var(--light-color);
    transition: color 0.3s ease;
}

.navbar-dark .navbar-nav .nav-link:hover,
.navbar-dark .navbar-nav .nav-link.active {
    color: var(--primary-color);
}

.dropdown-menu {
    border: 1px solid var(--border-color);
}

.dropdown-item:hover {
    background-color: var(--primary-color);
    color: var(--light-color) !important;
}

/* Hero Carousel */
.carousel-item img {
    height: 70vh;
    object-fit: cover;
    filter: brightness(0.7);
}

/* Additional carousel caption styles - merged with main definition above */

.carousel-indicators button {
    background-color: var(--primary-color);
}

/* Cards */
.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(220, 53, 69, 0.2);
}

.product-card .card-img-top {
    transition: transform 0.3s ease;
}

.product-card:hover .card-img-top {
    transform: scale(1.05);
}

.category-card {
    cursor: pointer;
}

.category-card:hover {
    border-color: var(--primary-color);
}

/* Feature Icons */
.feature-icon i {
    transition: transform 0.3s ease;
}

.feature-icon:hover i {
    transform: scale(1.1);
}

/* Forms */
.form-control {
    background-color: #2a2a2a;
    border-color: var(--border-color);
    color: var(--light-color);
}

.form-control:focus {
    background-color: #2a2a2a;
    border-color: var(--primary-color);
    color: var(--light-color);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control::placeholder {
    color: var(--muted-color);
}

/* Tables */
.table-dark {
    --bs-table-bg: #1a1a1a;
    --bs-table-border-color: var(--border-color);
}

/* Badges */
.badge {
    font-size: 0.75em;
}

/* Toast */
.toast {
    border: 1px solid var(--border-color);
}

/* Back to Top Button */
#backToTop {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Fix z-index layering for better stacking */
.navbar.sticky-top {
    z-index: 1030;
}

.carousel {
    z-index: 1;
}

.modal {
    z-index: 1050;
}

/* Ensure dropdowns appear above other content */
.dropdown-menu {
    z-index: 1000;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Product image fallback */
.card-img-top {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    min-height: 200px;
    object-fit: cover;
}

/* Hide broken product images */
.card-img-top[src=""],
.card-img-top:not([src]) {
    display: none;
}

/* Show placeholder when image is missing */
.card:has(.card-img-top[src=""]),
.card:has(.card-img-top:not([src])) {
    .card-img-top {
        display: block;
        background: linear-gradient(135deg, #dc3545, #6c757d);
        content: '';
    }
}

/* Price Display */
.price-display {
    font-size: 1.25rem;
    font-weight: bold;
}

.price-original {
    text-decoration: line-through;
    color: var(--muted-color);
    font-size: 1rem;
}

/* Quantity Controls - Cross-browser compatibility */
.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-controls button,
.quantity-btn {
    width: 35px !important;
    height: 35px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #6c757d !important;
    background-color: #495057 !important;
    color: #ffffff !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    font-size: 16px !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    transition: all 0.2s ease !important;
}

.quantity-controls button:hover,
.quantity-btn:hover {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #ffffff !important;
}

.quantity-controls button:active,
.quantity-btn:active {
    background-color: #c82333 !important;
    border-color: #bd2130 !important;
    transform: scale(0.95) !important;
}

.quantity-controls input,
.quantity-input {
    width: 60px !important;
    text-align: center !important;
    border: 1px solid #6c757d !important;
    background-color: #495057 !important;
    color: #ffffff !important;
    border-radius: 4px !important;
    height: 35px !important;
    font-size: 14px !important;
    padding: 0 5px !important;
    margin: 0 !important;
}

.quantity-controls input:focus,
.quantity-input:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
    outline: none !important;
}

/* Remove default number input spinners */
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.quantity-input[type=number] {
    -moz-appearance: textfield !important;
}

/* Cart Summary */
.cart-summary {
    background-color: #1a1a1a;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
}

/* Order Status */
.order-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.order-status.pending {
    background-color: #ffc107;
    color: #000;
}

.order-status.processing {
    background-color: #17a2b8;
    color: #fff;
}

.order-status.shipped {
    background-color: #007bff;
    color: #fff;
}

.order-status.delivered {
    background-color: #28a745;
    color: #fff;
}

.order-status.cancelled {
    background-color: #dc3545;
    color: #fff;
}

/* Recipe Cards */
.recipe-card {
    position: relative;
    overflow: hidden;
}

.recipe-card .card-img-overlay {
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Admin Panel */
.admin-sidebar {
    background-color: #1a1a1a;
    border-right: 1px solid var(--border-color);
    min-height: calc(100vh - 76px);
}

.admin-sidebar .nav-link {
    color: var(--light-color);
    padding: 0.75rem 1rem;
    border-radius: 5px;
    margin-bottom: 0.25rem;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: var(--light-color);
}

/* Statistics Cards */
.stat-card {
    background: linear-gradient(135deg, var(--primary-color), #c82333);
    color: var(--light-color);
    border: none;
}

.stat-card .card-body {
    padding: 1.5rem;
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .carousel-item img {
        height: 50vh;
    }
    
    .carousel-caption {
        padding: 1rem;
    }
    
    .carousel-caption h1 {
        font-size: 1.5rem;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 576px) {
    .carousel-item {
        height: 50vh;
        min-height: 350px;
    }
    
    .carousel-item img {
        height: 100%;
    }
    
    .carousel-caption {
        position: absolute !important;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
        padding: 3.5rem 0.5rem 0.75rem 0.5rem;
        max-width: none;
        width: 100%;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .carousel-caption h1 {
        font-size: 0.9rem;
        margin-bottom: 0.2rem;
    }
    
    .carousel-caption p {
        font-size: 0.7rem;
        margin-bottom: 0.4rem;
    }
    
    .carousel-caption .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
    }
    
    .product-grid {
        grid-template-columns: 1fr;
    }
    
    .cart-summary {
        margin-top: 2rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Utility Classes */
.text-shadow {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color), #c82333);
}

/* Print Styles */
@media print {
    .navbar, .footer, #backToTop {
        display: none !important;
    }
    
    body {
        background-color: white !important;
        color: black !important;
    }
    
    .card {
        border: 1px solid #ccc !important;
        background-color: white !important;
    }
}