@import url('https://fonts.googleapis.com/css2?family=Blinker:wght@400;700&display=swap');

/* ===== Root Variables ===== */
:root {
    --primary-color: #f5f1eb;
    --secondary-color: #e8dfd7;
    --accent-color: #d4a574;
    --text-dark: #2c2416;
    --text-light: #6b5d52;
    --border-color: #ede5dd;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--primary-color);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--primary-color);
    position: relative;
    /* Mobile safe area support */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, #faf7f2 0%, #f5f1eb 100%);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

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

.logo {
    font-size: 24px;
    font-family: 'Blinker', system-ui, sans-serif;
    font-weight: 400;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #8b6f47 0%, #a68968 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo strong {
    font-weight: 700;
}

.header-icons {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-dark);
    transition: var(--transition);
    padding: 0;
}

.icon-btn svg {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 70px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page.active {
    display: block;
}

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

/* ===== Feed Page ===== */
.feed-container {
    padding: 16px;
}

.search-bar {
    margin-bottom: 20px;
    display: flex;
    gap: 8px;
    align-items: center;
}

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

/* Prevent iOS Safari zoom on focus (minimum 16px) */
input,
select,
textarea,
button {
    font-size: 16px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.dropdown-container {
    position: relative;
}

.search-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    padding: 0;
}

.search-btn svg {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.search-btn:hover {
    background-color: var(--secondary-color);
}

.search-btn:active {
    transform: scale(0.95);
}

.settings-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    padding: 0;
}

.settings-btn svg {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.settings-btn:hover {
    background-color: var(--secondary-color);
}

.settings-btn:active {
    transform: scale(0.95);
}

/* Filter Dropdown */
.filter-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-width: 220px;
    max-height: 500px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.filter-dropdown.active {
    display: block;
}

.filter-section {
    padding: 12px 0;
}

.filter-section:first-child {
    padding-top: 8px;
}

.filter-section:last-child {
    padding-bottom: 8px;
}

.filter-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    padding: 8px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0;
}

.countries-list {
    display: flex;
    flex-direction: column;
}

.country-option {
    padding: 12px 16px;
    border: none;
    background: white;
    cursor: pointer;
    text-align: left;
    font-weight: 500;
    color: var(--text-dark);
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.country-option:last-child {
    border-bottom: none;
}

.country-option:hover {
    background-color: var(--secondary-color);
    color: var(--accent-color);
}

.country-option.active {
    background: linear-gradient(90deg, rgba(212, 165, 116, 0.15) 0%, transparent 100%);
    color: var(--accent-color);
    font-weight: 600;
}

.cities-list {
    display: flex;
    flex-direction: column;
}

.city-option {
    padding: 12px 16px;
    border: none;
    background: white;
    cursor: pointer;
    text-align: left;
    font-weight: 500;
    color: var(--text-dark);
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.city-option:last-child {
    border-bottom: none;
}

.city-option:hover {
    background-color: var(--secondary-color);
    color: var(--accent-color);
}

.city-option.active {
    background: linear-gradient(90deg, rgba(212, 165, 116, 0.15) 0%, transparent 100%);
    color: var(--accent-color);
    font-weight: 600;
}

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

.conversation-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
}

.conversation-card:active {
    background-color: var(--secondary-color);
    transform: scale(0.98);
}

.delete-post-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border-radius: 6px;
    flex-shrink: 0;
}

.delete-post-btn:hover {
    color: #ff4444;
    background-color: rgba(255, 68, 68, 0.1);
}

.delete-post-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.conversation-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--accent-color) !important;  /* UPDATED: Use background-color instead of gradient for vehicle type support */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 20px;
    flex-shrink: 0;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

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

.conversation-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

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

.conversation-preview {
    font-size: 14px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 8px;
}

.conversation-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-light);
    align-items: center;
    justify-content: space-between;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    background-color: var(--secondary-color);
    border-radius: 6px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dark);
    flex-shrink: 0;
}

/* ===== Chat Page ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    box-shadow: var(--shadow);
}

.back-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-dark);
    transition: var(--transition);
    padding: 0;
}

.back-btn svg {
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.back-btn:hover {
    background-color: var(--secondary-color);
}

.back-btn:active {
    transform: scale(0.95);
}

.chat-info {
    flex: 1;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-dark);
}

.chat-subtitle {
    font-size: 12px;
    color: var(--text-light);
    margin: 0;
}

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

.message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    animation: slideIn 0.3s ease-out;
}

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

.message.own {
    justify-content: flex-end;
    align-items: flex-end;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius);
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.4;
}

.message-bubble.other {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
}

.message-bubble.own {
    background: linear-gradient(135deg, var(--accent-color) 0%, #c99659 100%);
    color: white;
}

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

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    transition: var(--transition);
}

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

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color) 0%, #c99659 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:active {
    transform: scale(0.95);
}

/* ===== Add Conversation Page ===== */
.add-container {
    padding: 16px;
}

.add-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.add-header h2 {
    font-size: 20px;
    margin: 0;
    color: var(--text-dark);
    flex: 1;
}

.add-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group textarea,
.form-group select,
.form-input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    background-color: white;
    color: var(--text-dark);
    transition: var(--transition);
    /* Prevent zoom on iOS focus */
    font-size: 16px !important;
}

/* iOS specific optimizations */
@supports (-webkit-touch-callout: none) {
    .form-group input,
    .form-group textarea,
    .form-group select,
    .form-input {
        -webkit-user-select: text;
        user-select: text;
    }
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.form-group textarea {
    resize: vertical;
}

.submit-btn {
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #c99659 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 12px;
}

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

/* ===== Bottom Navigation ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: env(safe-area-inset-left);
    right: env(safe-area-inset-right);
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    cursor: pointer;
    color: var(--text-light);
    font-size: 11px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item svg {
    stroke-width: 2;
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

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

/* ===== Mobile Responsiveness ===== */
@media (max-width: 480px) {
    .conversation-card {
        padding: 12px;
    }

    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 14px;
    }

    .add-form {
        gap: 16px;
    }
}

/* ===== Utilities ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 16px;
    margin: 0;
}

/* ===== Messages List Page ===== */
.messages-list-container {
    padding: 16px;
}

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

.message-item {
    background: white;
    border-radius: var(--radius);
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
    align-items: center;
}

.message-item:active {
    background-color: var(--secondary-color);
    transform: scale(0.98);
}

.message-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color) 0%, #c99659 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.message-user-info {
    flex: 1;
    min-width: 0;
}

.message-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px 0;
}

.message-user-preview {
    font-size: 13px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

.message-user-time {
    font-size: 12px;
    color: var(--text-light);
    flex-shrink: 0;
}

.message-unread {
    width: 10px;
    height: 10px;
    background-color: var(--accent-color);
    border-radius: 50%;
    flex-shrink: 0;
}

/* ===== Direct Chat Styling ===== */
#directChatPage .chat-header {
    background: linear-gradient(135deg, #faf7f2 0%, #f5f1eb 100%);
}

#directChatPage .messages-container {
    background-color: var(--primary-color);
}

#directChatPage .message-bubble {
    font-size: 14px;
}

/* ===== Profile Dropdown Menu ===== */
.profile-dropdown {
    position: fixed;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 180px;
    max-width: 200px;
    overflow: hidden;
    display: none;
}

.profile-dropdown.active {
    display: flex;
    flex-direction: column;
}

/* Prevent dropdown from going off-screen on mobile */
@media (max-width: 480px) {
    .profile-dropdown {
        min-width: 160px;
        right: 12px !important;
        left: auto !important;
    }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-dark);
    text-decoration: none;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

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

.dropdown-item:hover {
    background-color: var(--secondary-color);
}

.dropdown-item:active {
    background-color: var(--border-color);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    flex-shrink: 0;
}

.dropdown-item span {
    font-size: 14px;
    font-weight: 500;
}

/* ===== Direct Profile Access Styling ===== */
body.direct-profile-access .profile-overlay {
    display: none !important;
}

body.direct-profile-access .profile-modal {
    display: flex !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    background: var(--primary-color);
    max-width: 100%;
}

body.direct-profile-access .profile-modal-content {
    margin-top: 0 !important;
    max-width: 100% !important;
    width: 100%;
}

/* ===== Mobile Friendly Optimizations ===== */

/* Prevent tap delay on mobile */
button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Safe area support for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Input field mobile optimization */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Button mobile optimization */
button,
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    min-height: 44px; /* Apple's recommended touch target size */
    min-width: 44px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

/* Prevent double-tap zoom on buttons */
@media (hover: none) and (pointer: coarse) {
    button,
    a,
    input[type="button"],
    input[type="submit"] {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Mobile portrait mode */
@media (orientation: portrait) and (max-width: 480px) {
    .app-container,
    .landing-container {
        max-width: 100%;
    }
}

/* Mobile landscape mode */
@media (orientation: landscape) and (max-height: 500px) {
    .main-content {
        padding-bottom: 60px;
    }

    .landing-content {
        padding: 16px 16px;
    }

    .hero-title {
        font-size: 24px;
    }

    .hero-subtitle {
        font-size: 13px;
    }

    .features-grid {
        gap: 8px;
        margin: 16px 0;
    }
}

/* Disable text selection on buttons for better UX */
.btn,
button,
.nav-item,
.icon-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* Prevent body scroll on modals */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

