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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #e8e8ed;
    --bg-card: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-muted: #6e6e73;
    --accent-primary: #007aff;
    --accent-secondary: #5856d6;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --border-color: #d2d2d7;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-card: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --text-muted: #636366;
    --border-color: #38383a;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    padding-top: 64px; /* Space for top nav */
}

.app-container {
    max-width: 100%;
    margin: 0 auto;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.top-nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 24px;
    overflow: hidden; /* Prevent overflow */
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-container {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.logo-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.logo-fallback {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.logo-fallback svg {
    width: 100%;
    height: 100%;
}

.logo-icon {
    flex-shrink: 0;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-nav-tabs {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.top-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: auto;
}

.top-nav-item svg {
    stroke: currentColor;
    fill: none;
    width: 20px;
    height: 20px;
}

.top-nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.top-nav-item.active {
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent-primary);
}

.top-nav-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}


/* Header */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 64px); /* Account for top nav */
}

.page-content {
    display: none;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

.page-content.active {
    display: block;
}

/* Items Grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.item-report-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.item-card:hover .item-action-buttons {
    opacity: 1;
}

.item-action-buttons {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
}

.item-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.item-action-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.item-save-btn:hover {
    background: rgba(255, 193, 7, 0.8);
}

.item-share-btn:hover {
    background: rgba(0, 122, 255, 0.8);
}

.item-report-btn:hover {
    background: rgba(255, 59, 48, 0.8);
}

.item-action-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
}

.item-save-btn svg {
    fill: currentColor;
}

.item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.item-image {
    width: 100%;
    height: 160px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-image svg {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
}

/* Image Navigation Arrows for Item Cards */
.item-image-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    opacity: 0;
}

.item-card:hover .item-image-nav {
    opacity: 1;
}

.item-image-nav:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.item-image-nav-prev {
    left: 8px;
}

.item-image-nav-next {
    right: 8px;
}

.item-image-nav svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

.item-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.item-condition {
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(0, 122, 255, 0.1);
    color: var(--accent-primary);
    border-radius: 4px;
    font-weight: 500;
}

.item-location {
    font-size: 11px;
    color: var(--text-secondary);
}

.item-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.item-status.public {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
}

.item-status.private {
    background: rgba(142, 142, 147, 0.1);
    color: var(--text-secondary);
}

.item-status.your-item {
    background: rgba(0, 122, 255, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

/* Ad Row Styles - Match item row appearance for search results */
.ad-row {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
    display: flex;
    gap: 16px;
    cursor: default; /* Ads are not clickable items */
}

.ad-row:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
    border-color: var(--accent-primary);
}

/* Ad Card Styles - Match item card appearance exactly */
.ad-card {
    /* Inherits all styles from .item-card */
    cursor: default; /* Ads are not clickable like items */
    max-height: none; /* Allow natural height like item cards */
}

.ad-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

/* Strictly constrain AdSense ads to match item card image size */
.ad-card .item-image {
    height: 160px !important;
    max-height: 160px !important;
    min-height: 160px !important;
    overflow: hidden !important;
    position: relative !important;
}

.ad-card .item-image ins {
    display: block !important;
    width: 100% !important;
    height: 160px !important;
    max-height: 160px !important;
    min-height: 160px !important;
    overflow: hidden !important;
}

.ad-card .item-image iframe,
.ad-card .item-image div {
    max-height: 160px !important;
    overflow: hidden !important;
}

/* Ensure the ad content doesn't expand beyond the container */
.ad-card .item-image > * {
    max-height: 160px !important;
    overflow: hidden !important;
}

/* Ad placeholder - shows while AdSense loads */
.ad-placeholder {
    transition: opacity 0.3s ease;
    z-index: 0;
}

/* Hide placeholder when AdSense has loaded content */
.adsbygoogle[data-adsbygoogle-status="done"] ~ .ad-placeholder,
.item-image:has(.adsbygoogle[data-adsbygoogle-status="done"]) .ad-placeholder,
.item-image:has(.adsbygoogle iframe) .ad-placeholder,
.item-image:has(.adsbygoogle div[id*="google"]) .ad-placeholder {
    display: none !important;
}

/* Ads are now regular grid items, no special container needed */

/* Items List (for search) */
.items-list {
    margin-top: 16px;
}

.item-row {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 16px;
}

.item-row:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
    border-color: var(--accent-primary);
}

.item-row-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.item-row-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.item-row-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-row-title {
    font-size: 16px;
    font-weight: 600;
}

.item-row-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 64px 16px;
    color: var(--text-secondary);
}

.empty-state svg {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 24px;
}

.empty-state-small {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Search */
.search-container {
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

/* Buttons */
.btn-primary {
    padding: 12px 24px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: #0051d5;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    padding: 12px 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.page-header-actions {
    margin-bottom: 16px;
}

/* Profile */
.profile-header {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-large svg {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
}

.avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-info {
    flex: 1;
}

.profile-info h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.profile-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rating-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stars {
    color: var(--warning);
    font-size: 16px;
    letter-spacing: 2px;
}

.rating-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.trade-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.trade-count svg {
    width: 16px;
    height: 16px;
}

.profile-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
}

.section-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Offers and Trades */
.offers-list,
.trades-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.offer-item,
.trade-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.offer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.offer-status {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.offer-status.pending {
    background: rgba(255, 149, 0, 0.1);
    color: var(--warning);
}

.offer-status.accepted {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
}

.offer-status.declined {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.offer-status.counterOffered {
    background: rgba(88, 86, 214, 0.1);
    color: var(--accent-secondary);
}

.offer-details {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.offer-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

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

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

.btn-view {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Item Detail */
.item-detail {
    padding: 20px;
}

.item-detail-images {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    margin-bottom: 20px;
    padding-bottom: 12px;
    position: relative;
}

/* When showing one image at a time (with navigation) */
.item-detail-images-container .item-detail-images {
    display: block;
    overflow: visible;
}

.item-detail-image {
    width: 260px;
    height: 220px;
    border-radius: 12px;
    background: var(--bg-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Single image display in detail modal */
.item-detail-images-container .item-detail-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
}

.item-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-detail-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.item-detail-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.item-detail-section {
    margin-bottom: 24px;
}

.item-detail-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.item-detail-section p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Forms */
.add-item-form,
.trade-offer-content,
.location-filter-content {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-range {
    width: 100%;
    margin: 12px 0;
}

.range-value {
    text-align: center;
    font-weight: 600;
    color: var(--accent-primary);
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .top-nav-content {
        padding: 10px 12px;
        gap: 8px;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .logo-section {
        gap: 8px;
        flex-shrink: 0;
        min-width: 0; /* Allow text truncation */
    }

    .logo-container {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .logo-text {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }

    .top-nav-tabs {
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex: 1;
        min-width: 0; /* Allow shrinking */
        justify-content: center;
    }

    .top-nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .top-nav-item {
        padding: 8px 10px;
        font-size: 13px;
        gap: 0;
        min-height: 44px; /* Better touch target */
        flex-shrink: 0;
    }

    .top-nav-item span {
        display: none;
    }

    .top-nav-item svg {
        width: 20px;
        height: 20px;
    }

    .top-nav-actions {
        gap: 4px;
        flex-shrink: 0;
    }

    .icon-btn {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .icon-btn svg {
        width: 20px;
        height: 20px;
    }

    .page-content {
        padding: 12px;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .item-card {
        border-radius: 10px;
    }

    .item-image {
        height: 140px;
    }

    .item-info {
        padding: 10px;
    }

    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .item-detail-images {
        flex-direction: column;
        gap: 8px;
    }

    .item-detail-image {
        width: 100%;
        height: 250px;
    }

    .item-detail-title {
        font-size: 20px;
    }

    .item-detail-meta {
        gap: 8px;
    }

    /* Modal improvements for mobile */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 95vh;
        border-radius: 20px 20px 0 0;
        margin-top: auto;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
        font-size: 28px;
    }

    /* Form improvements */
    .add-item-form,
    .trade-offer-content,
    .location-filter-content,
    .login-content,
    .settings-content,
    .account-settings-content {
        padding: 16px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-input,
    .form-textarea,
    .form-select {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }

    .form-textarea {
        min-height: 120px;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary,
    .btn-google {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 44px; /* Better touch target */
    }

    .btn-small {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 40px;
    }

    /* Chat improvements */
    .chat-content {
        height: calc(100vh - 200px);
        max-height: 600px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-message {
        max-width: 85%; /* More space on mobile */
    }

    .chat-input-container {
        padding: 12px;
    }

    .chat-input {
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .chat-send-btn {
        width: 44px;
        height: 44px;
    }

    /* Item detail actions */
    .item-detail-actions {
        flex-direction: column;
        gap: 10px;
    }

    .item-detail-actions button {
        width: 100%;
        min-height: 44px;
    }

    /* Location filter */
    .location-map {
        height: 250px;
    }

    .location-filter-actions {
        flex-direction: column;
    }

    .location-filter-actions button {
        width: 100%;
        min-height: 44px;
    }

    /* Profile sections */
    .profile-sections {
        gap: 16px;
    }

    .section-card {
        padding: 16px;
    }

    /* Offers and messages */
    .offers-list,
    .messages-list {
        gap: 12px;
    }

    .offer-item,
    .message-item {
        padding: 12px;
    }

    .offer-actions {
        flex-direction: column;
        gap: 8px;
    }

    .offer-actions button {
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 56px;
        font-size: 14px;
    }

    .top-nav {
        height: 56px;
    }

    .top-nav-content {
        padding: 8px 8px;
        gap: 6px;
        height: 100%;
    }

    .logo-section {
        gap: 6px;
    }

    .logo-container {
        width: 32px;
        height: 32px;
    }

    .logo-text {
        font-size: 14px;
        max-width: 90px;
    }

    .top-nav-tabs {
        gap: 2px;
    }

    .top-nav-item {
        padding: 6px 8px;
        min-width: 40px;
    }

    .top-nav-item svg {
        width: 18px;
        height: 18px;
    }

    .top-nav-actions {
        gap: 2px;
    }

    .icon-btn {
        min-width: 36px;
        min-height: 36px;
        width: 36px;
        height: 36px;
    }

    .icon-btn svg {
        width: 18px;
        height: 18px;
    }

    .page-content {
        padding: 10px;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .item-image {
        height: 120px;
    }

    .item-title {
        font-size: 13px;
    }

    .item-detail-title {
        font-size: 18px;
    }

    .modal-header {
        padding: 14px;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    .add-item-form,
    .trade-offer-content,
    .location-filter-content,
    .login-content,
    .settings-content,
    .account-settings-content {
        padding: 14px;
    }

    .item-detail-image {
        height: 200px;
    }

    .chat-content {
        height: calc(100vh - 180px);
    }

    /* Make touch targets even larger on small screens */
    button,
    .btn-primary,
    .btn-secondary,
    .btn-google,
    .top-nav-item,
    .icon-btn {
        min-height: 44px;
    }

    /* Better spacing for small screens */
    .form-group {
        margin-bottom: 14px;
    }

    .section-card h3 {
        font-size: 15px;
    }
}

/* Very small screens - hide logo text */
@media (max-width: 360px) {
    .logo-text {
        display: none;
    }
    
    .logo-section {
        gap: 0;
    }
    
    .top-nav-content {
        gap: 4px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .item-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }

    .item-report-btn {
        opacity: 1; /* Always show on touch devices */
    }

    .top-nav-item:hover,
    .icon-btn:hover {
        background: var(--bg-secondary);
    }

    .chat-send-btn:hover {
        transform: none;
    }

    /* Better touch feedback */
    button:active,
    .btn-primary:active,
    .btn-secondary:active,
    .top-nav-item:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Login/Signup Styles */
.login-content {
    padding: 20px;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-divider span {
    padding: 0 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.btn-google {
    width: 100%;
    padding: 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

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

.auth-footer {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
    padding: 4px;
}

.link-btn:hover {
    color: var(--accent-secondary);
}

.error-message {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.validation-message {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* Password Input with Toggle Button */
.password-input-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-container .form-input {
    padding-right: 50px; /* Space for the toggle button */
    width: 100%;
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    z-index: 10;
}

.password-toggle-btn:hover {
    color: var(--accent-primary);
    background: var(--bg-secondary);
}

.password-toggle-btn:active {
    transform: translateY(-50%) scale(0.9);
}

.password-toggle-btn:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.password-toggle-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}

#passwordRequirements div {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

#passwordRequirements div:has-text("✓") {
    color: var(--success);
}

/* Settings Styles */
.settings-content,
.account-settings-content {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* MFA/2FA Styles */
.mfa-content {
    padding: 20px;
}

.mfa-step {
    animation: fadeIn 0.2s ease;
}

#recaptcha-container-mfa {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

#recaptcha-container-mfa > div {
    transform-origin: center;
}

@media (max-width: 400px) {
    #recaptcha-container-mfa > div {
        transform: scale(0.85);
    }
}

.profile-edit {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.avatar-upload {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* Messages Styles */
.messages-content {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.message-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-name {
    font-weight: 600;
    font-size: 16px;
}

.message-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.message-preview {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-badge {
    background: var(--accent-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

/* Chat Styles */
.chat-content {
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 70%;
}

.chat-message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.chat-message.sent .chat-message-bubble {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.chat-message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    color: var(--text-primary);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Location Filter Map Styles */
.modal-large {
    max-width: 800px;
}

.location-filter-content {
    padding: 20px;
}

.location-search-container {
    position: relative;
}

.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.location-suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s;
}

.location-suggestion-item:last-child {
    border-bottom: none;
}

.location-suggestion-item:hover {
    background: var(--bg-secondary);
}

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

.location-suggestion-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.location-map {
    width: 100%;
    height: 300px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-top: 8px;
}

.map-instructions {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.radius-presets {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.radius-preset-btn {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

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

.radius-preset-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.location-filter-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.location-filter-actions .btn-secondary,
.location-filter-actions .btn-primary {
    flex: 1;
}

/* Leaflet Map Customization */
.leaflet-container {
    background: var(--bg-secondary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 8px;
}

.leaflet-popup-tip {
    background: var(--bg-card);
}

.leaflet-control-zoom {
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-secondary) !important;
}

.custom-marker {
    background: transparent !important;
    border: none !important;
}

/* Report Modal Styles */
.report-content {
    padding: 20px;
}

.report-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.report-actions .btn-secondary,
.report-actions .btn-primary {
    flex: 1;
}

/* Image Upload Styles */
.image-upload-container {
    margin-top: 8px;
}

.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.image-preview-item {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 59, 48, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.image-remove-btn:hover {
    transform: scale(1.1);
}

/* Location Input Container */
.location-input-container {
    position: relative;
}

#itemLocationSuggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

/* Item Image Display */
.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-detail-images-container {
    position: relative;
    margin-bottom: 20px;
}

.item-detail-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.item-detail-image {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Image Navigation Arrows for Detail Modal */
.item-detail-image-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
}

.item-detail-image-nav:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.item-detail-image-nav-prev {
    left: 12px;
}

.item-detail-image-nav-next {
    right: 12px;
}

.item-detail-image-nav svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
}

.item-detail-image-counter {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    z-index: 10;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* GDPR Cookie Consent Banner */
.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 20px;
    z-index: 10000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 768px) {
    .cookie-consent-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.cookie-consent-text {
    flex: 1;
}

.cookie-consent-text h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.cookie-consent-text p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.cookie-learn-more {
    font-size: 13px;
    color: var(--accent-primary);
    text-decoration: none;
}

.cookie-learn-more:hover {
    text-decoration: underline;
}

.cookie-consent-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cookie-btn {
    padding: 10px 20px;
    font-size: 14px;
    white-space: nowrap;
}

@media (max-width: 767px) {
    .cookie-consent-buttons {
        width: 100%;
    }
    
    .cookie-btn {
        flex: 1;
        min-width: calc(50% - 5px);
    }
}

/* Cookie Settings Modal */
.cookie-settings-content {
    padding: 20px;
}

.cookie-category {
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.cookie-category:last-of-type {
    border-bottom: none;
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.cookie-category h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cookie-category p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    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-color: var(--bg-tertiary);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

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

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
}

