:root {
    --primary-color: #8B4513;
    --secondary-color: #DEB887;
    --accent-color: #D2691E;
    --background-color: #FFF8DC;
    --text-color: #4A4A4A;
    --font-size-base: 16px;
    --link-focus-outline: 3px solid #D2691E;
    
    /* Bootstrap gutter variables */
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 0;
    
    /* Responsive breakpoints */
    --bp-sm: 576px;  /* Small devices (landscape phones) */
    --bp-md: 768px;  /* Medium devices (tablets) */
    --bp-lg: 992px;  /* Large devices (desktops) */
    --bp-xl: 1200px; /* Extra large devices */
    
    /* Responsive spacing variables */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2.5rem;
    
    /* Image gallery variables */
    --thumbnail-size: 80px;
    --thumbnail-gap: 10px;
    
    /* Typography scale for mobile-first */
    --font-size-h1-mobile: 1.8rem;
    --font-size-h1-desktop: 2.5rem;
    --font-size-h2-mobile: 1.5rem;
    --font-size-h2-desktop: 2rem;
}

[data-theme="dark"] {
    --primary-color: #B25B1A;
    --secondary-color: #6B4423;
    --accent-color: #FF8C42;
    --background-color: #1A1A1A;
    --text-color: #E0E0E0;
}

[data-contrast="high"] {
    --primary-color: #000000;
    --secondary-color: #FFFFFF;
    --accent-color: #FFFF00;
    --background-color: #FFFFFF;
    --text-color: #000000;
}

[data-contrast="high"][data-theme="dark"] {
    --primary-color: #FFFFFF;
    --secondary-color: #000000;
    --accent-color: #FFFF00;
    --background-color: #000000;
    --text-color: #FFFFFF;
}

/* Font size adjustments */
[data-font-size="larger"] {
    --font-size-base: 20px;
}

[data-font-size="largest"] {
    --font-size-base: 24px;
}

[data-theme="dark"] .card,
[data-theme="dark"] .search-bar,
[data-theme="dark"] .dropdown-menu {
    background-color: #2A2A2A !important;
    color: var(--text-color);
}

[data-theme="dark"] .form-control {
    background-color: #333;
    border-color: #444;
    color: var(--text-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-color);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: #333;
}

[data-theme="dark"] .card-title {
    background-color: #242424;
    padding: 10px;
    border-radius: 4px;
}

[data-theme="dark"] .form-control::placeholder {
    color: #E0E0E0;
    opacity: 0.7;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Mobile-first approach */
/* Small devices - Phones (< 576px) */
@media (max-width: 575.98px) {
    .container {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
        max-width: 100%;
    }
    
    .accordion-body {
        padding: var(--spacing-sm);
    }
    
    .row {
        margin-left: -5px;
        margin-right: -5px;
    }
    
    .col-sm-12 {
        margin-bottom: var(--spacing-md);
    }
    
    h1.vintage-header {
        font-size: var(--font-size-h1-mobile);
    }
    
    h2.vintage-header {
        font-size: var(--font-size-h2-mobile);
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .search-bar {
        padding: var(--spacing-sm);
    }
    
    .yard-sale-card {
        margin-bottom: var(--spacing-md);
    }
    
    .yard-sale-image {
        height: 150px;
    }
    
    .item-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .accessibility-controls button span {
        display: none;
    }
    
    .btn {
        padding: 0.4rem 0.75rem;
    }
    
    .navbar .dropdown-menu {
        position: static;
    }
    
    .community-section img {
        margin-top: var(--spacing-md);
    }
    
    .search-form-row {
        flex-direction: column;
    }
    
    .search-form-row > div {
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }
}

/* Medium devices - Tablets (576px - 767.98px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
    }
    
    .accordion-body {
        padding: var(--spacing-md) var(--spacing-sm);
    }
    
    .row {
        margin-left: -8px;
        margin-right: -8px;
    }
    
    h1.vintage-header {
        font-size: var(--font-size-h1-desktop);
    }
    
    h2.vintage-header {
        font-size: var(--font-size-h2-desktop);
    }
    
    .item-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .yard-sale-image {
        height: 170px;
    }
    
    .featured-items .col-md-4 {
        width: 50%;
    }
}

/* Large devices - Desktops (768px and up) */
@media (min-width: 768px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .accordion-body {
        padding: 1rem;
    }
    
    .row {
        margin-left: -15px;
        margin-right: -15px;
    }
    
    .item-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    .yard-sale-image {
        height: 200px;
    }
}

label{
    font-weight: bold;
    display: inline;
}

input[name="item_names[]"] {
    min-width: 25ch;
}

input[name="item_prices[]"] {
    width: 8ch;
}

.navbar {
    background-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    color: var(--background-color) !important;
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
}

.yard-sale-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    margin-bottom: 1.5rem;
    height: 100%;  /* Make all cards the same height */
}

.yard-sale-card:hover {
    transform: translateY(-4px);
}

.yard-sale-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--accent-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

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

.btn-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.vintage-header {
    font-family: 'Playfair Display', serif;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.search-bar {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.featured-item {
    border: 2px solid var(--accent-color);
}

.date-badge {
    background-color: var(--secondary-color);
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 4px;
    font-weight: bold;
}

.accordion-button:not(.collapsed) {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

.accordion-button:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(139, 69, 19, 0.25);
}

/* Custom badge styling to match theme */
.bg-accent {
    background-color: var(--accent-color) !important;
    color: var(--background-color);
}

[data-theme="dark"] .bg-accent {
    color: #212529;
}

/* Fixed width for yard sale count badge */
.yard-sale-count {
    display: inline-block;
    min-width: 2rem;
    text-align: center;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Badge styling for sale types */
.badge.bg-info {
    background-color: var(--secondary-color) !important;
    color: #333;
}

/* Filter label styling */
.filter-label {
    font-size: 0.9rem;
    color: var(--text-color);
    background-color: rgba(222, 184, 135, 0.15);
    padding: 4px 10px;
    border-radius: 15px;
    display: inline-block;
}

[data-theme="dark"] .filter-label {
    background-color: rgba(51, 51, 51, 0.7);
}

/* Item search form styling */
.search-bar-mini {
    background-color: var(--accent-color-light);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin: 0 auto;
    max-width: 1000px;
}

.search-bar-mini .form-label {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.search-bar-mini .form-control {
    border: 1px solid var(--accent-color);
}

.search-bar-mini .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(222, 184, 135, 0.25);
}

[data-theme="dark"] .search-bar-mini {
    background-color: rgba(51, 51, 51, 0.7);
}

/* Lazy loading styles */
.lazy-load {
    opacity: 0.7;
    transition: opacity 0.3s;
}

.lazy-loaded {
    opacity: 1;
}

.lazy-error {
    opacity: 0.5;
    filter: grayscale(100%);
}

/* Enhanced layout organization styles */
.hero-section {
    background: linear-gradient(135deg, var(--background-color), var(--secondary-color));
    border-radius: 0 0 2rem 2rem;
    margin: -1rem -15px 0 -15px;
    padding: 2rem 15px !important;
}

.search-card {
    border-radius: 1rem;
    background: linear-gradient(145deg, var(--background-color), rgba(222, 184, 135, 0.1));
}

.search-card .card-body {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 0.75rem;
}

/* Section spacing and organization */
.search-section {
    margin-bottom: 3rem !important;
}

.recent-sales-section .card,
.featured-items-section .card {
    border-radius: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.recent-sales-section .card:hover,
.featured-items-section .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
}

.card-header {
    padding: 1.5rem 1.5rem 0 1.5rem !important;
}

.card-body {
    padding: 1.5rem !important;
}

/* Improved content grid spacing */
.container-fluid {
    max-width: 1400px;
    margin: 0 auto;
}

/* Responsive grid optimizations - NoScript compatible */
.container-fluid {
    max-width: 1400px;
    margin: 0 auto;
}

/* Ensure proper responsive behavior without JavaScript dependencies */
.featured-items-grid,
.recent-sales-list {
    display: block;
    width: 100%;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.row > * {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: calc(var(--bs-gutter-x) * 0.5);
    padding-left: calc(var(--bs-gutter-x) * 0.5);
    margin-top: var(--bs-gutter-y);
}

/* Enhanced component styles */
.hover-card {
    transition: all 0.2s ease;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

.hover-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color) !important;
}

.sale-item-compact .hover-card:hover h6 {
    color: var(--primary-color) !important;
}

.featured-item-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.featured-items-grid .featured-item-card:hover h6 {
    color: var(--primary-color) !important;
}

.recent-sales-list {
    max-height: 400px;
    overflow-y: auto;
}

.recent-sales-list::-webkit-scrollbar {
    width: 4px;
}

.recent-sales-list::-webkit-scrollbar-track {
    background: transparent;
}

.recent-sales-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.recent-sales-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Mobile layout improvements - cross-browser */
@media (max-width: 767.98px) {
    .hero-section {
        margin: -1rem -15px 0 -15px;
        padding: 1.5rem 15px !important;
        border-radius: 0 0 1rem 1rem;
    }
    
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .hero-section .lead {
        font-size: 1rem;
    }
    
    .search-card .card-body {
        padding: 1.5rem !important;
    }
    
    .card-header {
        padding: 1rem 1rem 0 1rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .featured-item-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .sale-item-compact,
    .featured-item-card {
        margin-bottom: 0.75rem !important;
    }
    
    /* Force mobile layout in all browsers */
    .row {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .col-12, .col-lg-6 {
        width: 100% !important;
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
    }
}

/* Tablet layout fixes */
@media (min-width: 768px) and (max-width: 991.98px) {
    .row {
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
        -ms-flex-direction: column;
        flex-direction: column;
    }
    
    .col-12, .col-lg-6 {
        width: 100% !important;
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
    }
}

/* Desktop layout - ensure proper side-by-side */
@media (min-width: 992px) {
    .row {
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -ms-flex-direction: row;
        flex-direction: row;
    }
    
    .col-lg-6 {
        width: 50% !important;
        -ms-flex: 0 0 50%;
        flex: 0 0 50%;
    }
}

/* Accessibility improvements */
.accessibility-ready {
    font-size: var(--font-size-base);
}

.accessibility-ready a:focus,
.accessibility-ready button:focus,
.accessibility-ready input:focus,
.accessibility-ready select:focus,
.accessibility-ready textarea:focus {
    outline: var(--link-focus-outline);
    outline-offset: 2px;
}

.accessibility-ready .btn {
    position: relative;
}

.accessibility-ready .btn:focus {
    outline: var(--link-focus-outline);
    outline-offset: 2px;
    box-shadow: none;
}

.accessibility-controls {
    margin-top: 10px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-color);
    color: white;
    padding: 8px 15px;
    z-index: 9999;
    transition: top 0.3s;
}

.skip-to-content:focus {
    top: 0;
    outline: none;
}

/* High contrast theme overrides */
[data-contrast="high"] .navbar,
[data-contrast="high"] .btn-primary,
[data-contrast="high"] .badge {
    background-color: #000000;
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
}

[data-contrast="high"] .yard-sale-card,
[data-contrast="high"] .search-bar,
[data-contrast="high"] .card {
    background-color: #FFFFFF;
    color: #000000;
    border: 2px solid #000000;
}

[data-contrast="high"][data-theme="dark"] .navbar,
[data-contrast="high"][data-theme="dark"] .btn-primary,
[data-contrast="high"][data-theme="dark"] .badge {
    background-color: #FFFFFF;
    color: #000000;
    border: 2px solid #000000;
}

[data-contrast="high"][data-theme="dark"] .yard-sale-card,
[data-contrast="high"][data-theme="dark"] .search-bar,
[data-contrast="high"][data-theme="dark"] .card {
    background-color: #000000;
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
}

/* WCAG 2.1 focus indicator for keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--accent-color) !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

/* Remove animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .vintage-header .badge {
        animation: none !important;
    }
    
    .yard-sale-card:hover {
        transform: none;
    }
}

/* Font size feedback popup */
.font-size-feedback {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    z-index: 1050;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease;
    font-weight: bold;
}

/* Accessibility controls styling */
.accessibility-controls button.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Touch target sizing for accessibility */
@media (hover: none) and (pointer: coarse) {
    .accessibility-controls button,
    .btn:not(.btn-sm):not(.btn-lg),
    .form-check-input {
        min-height: 44px;
        min-width: 44px;
    }
    
    a, button {
        padding: 0.5rem 0.75rem;
    }
}

/* Equal height cards */
.equal-height-container {
    display: flex;
    flex-wrap: wrap;
}

.equal-height-container > div {
    display: flex;
    flex-direction: column;
}

.equal-height-container .yard-sale-card {
    flex: 1;
}

/* Better form layouts for smaller screens */
@media (max-width: 767.98px) {
    .form-row-responsive {
        flex-direction: column;
    }
    
    .form-row-responsive > * {
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }
    
    .navbar-nav .dropdown-menu {
        position: absolute;
    }
}

/* Improve table responsiveness */
@media (max-width: 767.98px) {
    .table-responsive-custom {
        display: block;
        width: 100%;
        overflow-x: auto;
    }
    
    .table-responsive-stack tr {
        display: flex;
        flex-direction: column;
        border-bottom: 3px solid #ddd;
        margin-bottom: var(--spacing-md);
    }
    
    .table-responsive-stack td {
        display: block;
        text-align: right;
        border-bottom: 1px dotted #ccc;
        position: relative;
        padding-left: 50%;
    }
    
    .table-responsive-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
}

/* Image Gallery Styles */
.image-counter {
    cursor: pointer;
}

.inventory-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.inventory-item:hover {
    background-color: #f8f9fa;
}

.image-gallery-row {
    background-color: #f9f9f9;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    margin-top: -15px;
    margin-bottom: 15px;
    border-radius: 0 0 5px 5px;
}

.image-gallery-container {
    width: 100%;
}

.image-thumbnails-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.thumbnail-container {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 10px 0;
    gap: var(--thumbnail-gap);
}

.thumbnail-wrapper {
    flex: 0 0 var(--thumbnail-size);
    height: var(--thumbnail-size);
    margin-right: var(--thumbnail-gap);
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}

.thumbnail-wrapper:hover {
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading spinner for image gallery */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
    width: 100%;
    font-style: italic;
    color: var(--text-color);
    animation: pulse 1.5s infinite;
}

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

/* Error and empty state messages */
.error, .no-images {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
    width: 100%;
    color: var(--text-color);
}

.error {
    color: #dc3545;
}

/* Image counter badge styling */
.image-counter {
    cursor: pointer;
    transition: background-color 0.2s;
}

.image-counter:hover {
    background-color: var(--accent-color) !important;
}

/* Modal styles for full-screen image display */
#imageModal .modal-dialog {
    max-width: 90%;
}

#imageModal .modal-content {
    background-color: rgba(0, 0, 0, 0.9);
    border: none;
}

#modalImage {
    cursor: zoom-in;
    max-height: 80vh;
    object-fit: contain;
}

#modalImage.zoomed {
    cursor: zoom-out;
    max-height: none;
    max-width: none;
    transform-origin: left top;
}

[data-theme="dark"] .image-gallery-row {
    background-color: #2A2A2A;
    border-color: #444;
}

[data-theme="dark"] .inventory-item:hover {
    background-color: #3A3A3A;
}
