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

:root {
    --primary-green: #22c55e;
    --dark-green: #16a34a;
    --light-green: #bbf7d0;
    --very-light-green: #f0fdf4;
    --white: #ffffff;
    --off-white: #fafafa;
    --light-gray: #f3f4f6;
    --medium-gray: #9ca3af;
    --dark-gray: #4b5563;
    --text-color: #1f2937;
    --border-radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.12);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--off-white);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

html, body {
    width: 100%;
    height: 100%;
}

/* ==================== MOBILE FIRST DESIGN ==================== */

.mobile-container {
    width: 100%;
    max-width: none;
    margin: 0;
    background: var(--white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: none;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px;
    -webkit-overflow-scrolling: touch;
}

.app-content.chat-fullscreen {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ==================== NAVIGATION ==================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: none;
    height: 70px;
    background: var(--white);
    border-top: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    color: var(--medium-gray);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: var(--border-radius);
    font-size: 24px;
    position: relative;
}

.message-unread-dot {
    display: none;
    position: absolute;
    top: 8px;
    right: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid var(--white);
}

.notification-unread-dot {
    display: none;
    position: absolute;
    top: 8px;
    right: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid var(--white);
}

.nav-item:active,
.nav-item.active {
    color: var(--primary-green);
    background-color: var(--very-light-green);
}

.nav-label {
    font-size: 10px;
    margin-top: 2px;
    font-weight: 500;
}

.nav-item.add-item {
    position: relative;
    bottom: 15px;
    background: var(--primary-green);
    color: var(--white);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: var(--shadow-lg);
}

.nav-item.add-item:hover {
    background: var(--dark-green);
    transform: scale(1.1);
}

/* ==================== BUTTONS ==================== */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

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

.btn-primary:active,
.btn-primary:hover {
    background: var(--dark-green);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--light-gray);
    color: var(--text-color);
    border: 2px solid var(--primary-green);
}

.btn-secondary:active,
.btn-secondary:hover {
    background: var(--very-light-green);
}

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

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== FORM ELEMENTS ==================== */

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: var(--white);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

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

.address-suggestions {
    margin-top: 8px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: var(--white);
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow-y: auto;
}

.address-suggestion-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
}

.address-suggestion-item:hover {
    background: var(--very-light-green);
}

.radius-control {
    background: var(--white);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: var(--shadow);
}

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

.radius-value {
    background: var(--very-light-green);
    color: var(--dark-green);
    font-size: 13px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
}

.radius-slider {
    width: 100%;
    accent-color: var(--primary-green);
    cursor: pointer;
}

.radius-scale {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #6b7280;
}

/* ==================== CARDS ==================== */

.card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.card:active,
.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

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

.card-title {
    font-size: 18px;
    font-weight: 700;
    margin: 12px 0;
}

.card-meta {
    font-size: 13px;
    color: var(--medium-gray);
}

.chat-thread {
    cursor: pointer;
}

.chat-thread-unread {
    border: 1px solid rgba(34, 197, 94, 0.35);
    background: #f7fff9;
}

.chat-thread-name {
    font-weight: 700;
}

.chat-thread-name.unread {
    color: #111827;
}

.chat-thread-preview {
    font-size: 13px;
    color: #9ca3af;
}

.chat-thread-preview.unread {
    color: #374151;
    font-weight: 600;
}

.chat-thread-time {
    font-size: 12px;
    color: #9ca3af;
}

.chat-thread-time.unread {
    color: var(--primary-green);
    font-weight: 700;
}

.chat-thread-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

/* ==================== HEADER ==================== */

.header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    color: var(--white);
    padding: 20px 16px;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow);
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.header-subtitle {
    font-size: 14px;
    opacity: 0.9;
}

/* ==================== SEARCH ==================== */

.search-container {
    display: flex;
    gap: 10px;
    margin: 16px;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 16px;
    background: var(--off-white);
}

.search-btn {
    width: 48px;
    height: 48px;
    padding: 0;
    background: var(--primary-green);
    color: var(--white);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* ==================== FILTERS ==================== */

.filter-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--light-gray);
    border-radius: 20px;
    background: var(--white);
    color: var(--text-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

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

/* ==================== ITEM GRID/LIST ==================== */

.item-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
}

.item-card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.item-card:active,
.item-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.item-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: contain;
    object-position: center;
    background: var(--light-gray);
    display: block;
    padding: 6px;
}

.item-info {
    padding: 10px;
    min-height: 170px;
}

.item-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-color);
    line-height: 1.3;
}

.item-category {
    display: inline-block;
    background: var(--very-light-green);
    color: var(--dark-green);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 8px;
}

.item-owner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.item-owner-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--light-green);
}

.item-owner-name {
    font-size: 12px;
    color: var(--text-color);
    font-weight: 600;
}

.item-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--medium-gray);
}

.item-price {
    font-weight: 700;
    color: var(--primary-green);
    font-size: 15px;
    margin-top: 6px;
}

/* ==================== DETAIL PAGE ==================== */

.detail-header {
    position: relative;
    height: clamp(240px, 45vh, 420px);
    width: calc(100% - 24px);
    max-width: 980px;
    margin: 12px auto 0;
    overflow: hidden;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: var(--shadow);
}

.detail-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    opacity: 1;
    transition: opacity 220ms ease;
}

.gallery-arrow-btn {
    transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.gallery-arrow-btn:hover {
    background: #ffffff;
    transform: translateY(-50%) scale(1.05);
}

.gallery-arrow-btn:active {
    transform: translateY(-50%) scale(0.96);
}

.back-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 10;
}

.detail-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 20px 16px 28px;
}

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

.detail-owner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--very-light-green);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.owner-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--light-green);
    object-fit: cover;
}

.owner-info {
    flex: 1;
}

.owner-name {
    font-weight: 700;
    margin-bottom: 2px;
}

.owner-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--medium-gray);
}

.verified-badge {
    background: var(--primary-green);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

.detail-section {
    margin-bottom: 20px;
}

.section-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-color);
}

.co2-badge {
    background: var(--very-light-green);
    color: var(--dark-green);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 600;
    display: inline-block;
}

/* ==================== CHAT ==================== */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
}

.message {
    margin-bottom: 12px;
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
}

.message.sent .message-bubble {
    background: var(--primary-green);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: var(--light-gray);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--medium-gray);
    margin-top: 4px;
    text-align: center;
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--light-gray);
    background: var(--white);
}

.chat-text {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--light-gray);
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    max-height: 80px;
}

.chat-send {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--primary-green);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* ==================== PROFILE ==================== */

.profile-header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    padding: 30px 16px;
    color: var(--white);
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--light-green);
    margin: 0 auto 16px;
    object-fit: cover;
    border: 4px solid var(--white);
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-bio {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 12px;
    border-radius: var(--border-radius);
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    opacity: 0.9;
}

.profile-menu {
    padding: 12px;
}

.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-item:active,
.menu-item:hover {
    background: var(--very-light-green);
}

.menu-label {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-icon {
    font-size: 18px;
}

/* ==================== MODALS ==================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

/* ==================== STEPS/PROGRESS ==================== */

.step-indicator {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 20px 16px;
}

.step {
    flex: 1;
    height: 4px;
    background: var(--light-gray);
    border-radius: 2px;
    overflow: hidden;
}

.step.active {
    background: var(--primary-green);
}

/* ==================== LOADING & EMPTY ==================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-gray);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--medium-gray);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-color);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 360px) {
    .item-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .mobile-container {
        max-width: none;
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
        overflow: visible;
        box-shadow: none;
    }

    .bottom-nav {
        top: 0;
        bottom: auto;
        left: 0;
        transform: none;
        max-width: none;
        height: 72px;
        border-top: none;
        border-bottom: 1px solid var(--light-gray);
        box-shadow: none;
        padding: 0 20px;
    }

    .app-content {
        padding-top: 84px;
        padding-bottom: 20px;
    }

    .nav-item {
        width: auto;
        height: 48px;
        padding: 0 14px;
        border-radius: 10px;
        flex-direction: row;
        gap: 8px;
        font-size: 20px;
    }

    .nav-label {
        font-size: 14px;
        margin-top: 0;
        font-weight: 600;
    }

    .nav-item.add-item {
        bottom: 0;
        width: auto;
        height: 44px;
        border-radius: 10px;
        padding: 0 16px;
        font-size: 24px;
    }

    .header {
        padding: 30px 28px 22px;
    }

    .search-container,
    .filter-container {
        padding-left: 28px;
        padding-right: 28px;
    }

    .item-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 14px;
        padding: 16px 24px;
    }

    .item-image {
        height: 148px;
    }

    .detail-header {
        height: clamp(320px, 48vh, 520px);
        width: calc(100% - 64px);
        margin-top: 20px;
    }

    .detail-content {
        padding: 28px 32px 36px;
    }
}

@media (min-width: 1200px) {
    .item-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
        padding-left: 32px;
        padding-right: 32px;
    }
}
