/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

html {
    font-size: 17px;
}

body {
    margin: 0;
    padding: 0;
    display: block;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Flash toast - auto-dismiss popup */
.flash-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 4px 24px rgba(0, 39, 76, 0.15);
    transition: opacity 0.3s ease;
    max-width: 90%;
}

.flash-toast.flash-notice,
.flash-toast.flash-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.flash-toast.flash-alert,
.flash-toast.flash-error {
    background: #ffebee;
    color: #c62828;
}

.flash-toast.flash-dismissing {
    opacity: 0;
}

/* Navigation bar */

.navbar {
    position: sticky;           /* stays at top when scrolling */
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e2e2e2;
    background-color: #ffffff;
    gap: 20px;
}

.navbar-brand {
    flex-shrink: 0;
}

.navbar-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    text-decoration: none;
}

.navbar-logo {
    width: 70px;
    height: 70px;
    object-fit: contain;
    display: block;
}

.navbar-title-base {
    font-family: "Graduate", serif;
    font-weight: 700;
    font-size: 1.70rem;
    line-height: 1;
}

.navbar-maize {
    text-transform: uppercase;
}

.navbar-blue {
    text-transform: lowercase;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}


.navbar-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.navbar-links a {
    text-decoration: none;
    color: #333;
    font-weight: 600;
    font-size: 1.08rem;
}

.navbar-links a.btn-create {
    color: white;
}

.navbar-links a.btn-create:hover {
    color: white;
}

.navbar-links a:hover {
    color: #00274C;
}

/* Profile dropdown */
.navbar-dropdown {
    position: relative;
}

.navbar-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
    font-weight: 600;
    font-size: 1.08rem;
    font-family: inherit;
}

.navbar-dropdown-trigger:hover {
    color: #00274C;
}

.navbar-dropdown-chevron {
    font-size: 0.6em;
    opacity: 0.8;
}

.navbar-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    width: 100px;
    min-width: 100px;
    padding: 6px 0;
    background: #fff;
    border: 1px solid #e2e4e8;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 39, 76, 0.12);
    display: none;
    flex-direction: column;
    z-index: 200;
}

.navbar-dropdown.is-open .navbar-dropdown-menu {
    display: flex;
}

.navbar-dropdown-item {
    display: block;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    background: none;
    border: none;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}

.navbar-dropdown-menu .navbar-dropdown-item,
.navbar-dropdown-menu .navbar-dropdown-item-button button {
    padding: 10px 16px;
}

.navbar-dropdown-item:hover {
    background: #f0f4f8;
    color: #00274C;
}

.navbar-dropdown-item-button {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    min-width: 0;
}

.navbar-dropdown-item-button button {
    display: block;
    width: 100%;
    margin: 0;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    color: #333;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.navbar-dropdown-item-button button:hover {
    background: #f0f4f8;
    color: #00274C;
}

.navbar-dropdown-item-button button:focus {
    outline: none;
}

/* Destructive action (Log out) */
.navbar-dropdown-menu .navbar-logout-item {
    color: #c00;
    font-weight: 600;
}

.navbar-dropdown-menu .navbar-logout-item:hover {
    background: #fee;
    color: #c00;
}

/* Mobile navbar toggle */
.navbar-toggle-checkbox {
    display: none;
}

.navbar-toggle-label {
    display: none;
}

@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .navbar-toggle-label {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-left: auto;
        cursor: pointer;
        border-radius: 8px;
    }

    .navbar-toggle-label:hover {
        background: #f0f0f0;
    }

    .navbar-toggle-icon,
    .navbar-toggle-icon::before,
    .navbar-toggle-icon::after {
        display: block;
        width: 22px;
        height: 2px;
        background: #333;
        border-radius: 1px;
    }

    .navbar-toggle-icon {
        position: relative;
    }

    .navbar-toggle-icon::before,
    .navbar-toggle-icon::after {
        content: "";
        position: absolute;
        left: 0;
    }

    .navbar-toggle-icon::before { top: -7px; }
    .navbar-toggle-icon::after { top: 7px; }

    .navbar-toggle-checkbox:checked ~ .navbar-links {
        display: flex;
    }

    .navbar-links {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-top: 12px;
        border-top: 1px solid #eee;
    }

    .navbar-links a {
        padding: 12px 0;
        border-bottom: 1px solid #f0f0f0;
    }

    .navbar-links a.btn-create {
        text-align: center;
        margin-bottom: 8px;
    }

    .navbar-dropdown {
        border-bottom: 1px solid #f0f0f0;
    }

    .navbar-dropdown-trigger {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 0;
    }

    .navbar-dropdown-menu {
        position: static;
        margin-top: 0;
        width: auto;
        min-width: 100%;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0 0 8px 0;
        background: #f8f9fa;
    }

    .navbar-dropdown-item,
    .navbar-dropdown-item-button button {
        padding: 10px 16px 10px 24px;
    }
}

/* Optional: page content spacing below the nav */

.page-content {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 640px) {
    .page-content {
        padding: 24px 20px;
    }
}

/* Chat message screen (in-app messaging layout) */

.chat-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 12px 16px;
    box-sizing: border-box;
}

/* ======================
   MOBILE (Default)
====================== */
.chat-container {
    width: 100%;
    max-width: 800px;
    /* Comfortable height without filling the entire screen */
    height: min(76vh, calc(100vh - 88px));
    min-height: 320px;
    margin: 12px auto 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #e8ecf1;
    box-shadow: 0 4px 24px rgba(0, 39, 76, 0.08);
    transition:
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

@media (hover: hover) {
    .chat-container:hover {
        border-color: #c5d0dc;
        box-shadow: 0 8px 32px rgba(0, 39, 76, 0.14);
    }
}

.chat-top {
    flex-shrink: 0;
}

.chat-header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    background: #00274c;
    color: #ffffff;
    padding: 10px 8px 12px 14px;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.chat-header-titles {
    flex: 1;
    min-width: 0;
    padding-top: 4px;
}

.chat-close-link {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-top: -2px;
    margin-right: -2px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-close-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.chat-close-link:focus-visible {
    outline: 2px solid #ffcb05;
    outline-offset: 2px;
}

.chat-close-x {
    font-size: 1.85rem;
    font-weight: 300;
    line-height: 1;
    position: relative;
    top: -1px;
}

.chat-peer-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.chat-peer-subtitle {
    margin: 4px 0 0;
    font-size: 0.82rem;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.88);
}

.chat-peer-subtitle--muted {
    color: rgba(255, 255, 255, 0.65);
    font-style: italic;
}

.chat-peer-listing-link {
    color: #ffcb05;
    font-weight: 600;
    text-decoration: none;
    word-break: break-word;
}

.chat-peer-listing-link:hover {
    text-decoration: underline;
}

.chat-peer-subtitle-sep {
    margin: 0 0.35em;
    opacity: 0.7;
}

.chat-peer-subtitle-price {
    font-weight: 500;
    opacity: 0.95;
}

.chat-messages {
    flex: 1;
    min-height: 0;             /* IMPORTANT for scrolling inside flex */
    padding: 15px;
    overflow-y: auto;          /* Enables vertical scroll */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-time-sent,
.message-time-received {
    display: block;
    margin-top: 1px;
    font-size: 11px;
    color: #4c4c4c;
    opacity: 0.85;
    user-select: none;
}

.message-time-sent {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.message-time-received {
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message {
    max-width: 75%;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.sent {
    align-self: flex-end;
    background-color: #00274c;
    color: #ffffff;
    border-bottom-right-radius: 5px;
}

.received {
    align-self: flex-start;
    background-color: #e8ecf2;
    color: #1a1a1a;
    border-bottom-left-radius: 5px;
}

.chat-input {
    display: flex;
    align-items: center;
    border-top: 1px solid #e2e6ed;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
    flex-shrink: 0;
    background: #fafbfc;
}

.chat-input-field {
    flex: 1;
    padding: 12px 14px;
    border-radius: 22px;
    border: 1px solid #cfd6df;
    font-size: 15px;
    outline: none;
    background: #ffffff;
}

.chat-input-field:focus {
    border-color: #00274c;
    box-shadow: 0 0 0 3px rgba(0, 39, 76, 0.12);
}

.chat-send-btn {
    padding: 11px 18px;
    border: none;
    border-radius: 22px;
    background: #00274c;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-height: 44px;
}

.chat-send-btn:hover {
    background: #001a33;
}

.chat-send-btn:focus-visible {
    outline: 2px solid #ffcb05;
    outline-offset: 2px;
}

/* ======================
   DESKTOP
====================== */
@media (min-width: 768px) {

    body {
        padding: 0 40px 40px 40px;
    }

    .chat-page {
        padding: 0 0 24px;
    }

    .chat-container {
        width: 100%;
        max-width: 1000px;
        height: min(70vh, 620px);
        min-height: 400px;
        margin-top: 16px;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 39, 76, 0.1);
    }

    @media (hover: hover) {
        .chat-container:hover {
            border-color: #b3c0d0;
            box-shadow: 0 12px 40px rgba(0, 39, 76, 0.16);
        }
    }

    .chat-header-bar {
        padding: 16px 18px 18px;
        align-items: center;
    }

    .chat-peer-title {
        font-size: 1.25rem;
    }

    .chat-peer-subtitle {
        font-size: 0.88rem;
    }

    .chat-messages {
        padding: 25px;
        gap: 15px;
    }

    .message {
        max-width: 60%;
        padding: 14px 16px;
        font-size: 15px;
    }

    .chat-input {
        padding: 14px 18px;
    }

    .chat-input-field {
        padding: 14px 18px;
        font-size: 15px;
    }

    .chat-send-btn {
        padding: 12px 22px;
        font-size: 15px;
    }
}

/* Messages index / empty state */

.messages-page {
    max-width: 960px;
    margin: 0 auto;
}

.messages-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.messages-page-heading {
    flex: 1;
    min-width: 0;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 0;
    max-width: 36rem;
    line-height: 1.45;
}

.messages-browse-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 10px;
    background: #f4f7fb;
    color: #00274c;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.messages-browse-link:hover {
    background: #e8eef6;
    border-color: #cfd8e6;
}

.messages-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 39, 76, 0.08);
    padding: 24px;
}

.messages-empty {
    text-align: center;
    padding: 32px 16px;
    color: #666;
    font-size: 0.95rem;
}

.messages-empty-icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

.messages-actions {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.button-primary {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 10px;
    background: #00274C;
    color: #ffffff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
}

.button-primary:hover {
    background: #001a33;
}

.button-secondary {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 10px;
    background: #f8f9fa;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid #e2e4e8;
}

.button-secondary:hover {
    background: #eef0f4;
}

/* Small tweak so page content matches chat padding patterns */
.page-content.messages-page-wrapper {
    padding-top: 24px;
}

/* Messages list (inbox) — entire row is a link */
a.messages-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px solid #dfe5ec;
    border-radius: 12px;
    margin-bottom: 12px;
    background: #fafbfc;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 39, 76, 0.06);
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

@media (hover: hover) {
    a.messages-list-item:hover {
        background: #f0f5fa;
        border-color: #9eb0c4;
        box-shadow: 0 6px 22px rgba(0, 39, 76, 0.1);
        transform: translateY(-2px);
    }

    a.messages-list-item:active {
        transform: translateY(0);
        box-shadow: 0 2px 10px rgba(0, 39, 76, 0.08);
    }
}

a.messages-list-item:focus-visible {
    outline: 2px solid #00274c;
    outline-offset: 2px;
}

a.messages-list-item:last-child {
    margin-bottom: 0;
}

.messages-list-main {
    flex: 1;
    min-width: 0;
}

.messages-list-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    align-self: center;
    padding: 0 4px;
}

.messages-list-chevron {
    font-size: 1.5rem;
    font-weight: 300;
    color: #9aa5b5;
    line-height: 1;
}

a.messages-list-item:hover .messages-list-chevron {
    color: #00274c;
}

.messages-list-title {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.messages-list-peer {
    margin: 0 0 6px 0;
    font-size: 0.88rem;
    color: #444;
}

.messages-list-peer--muted {
    color: #777;
    font-style: italic;
}

.messages-list-context {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: #333;
    line-height: 1.4;
}

.messages-list-context--compact {
    margin-bottom: 6px;
}

.messages-list-context-price {
    font-size: 0.88rem;
    color: #555;
    font-weight: 500;
}

.messages-list-preview {
    margin: 0 0 10px 0;
    font-size: 0.86rem;
    line-height: 1.4;
    color: #4a5568;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.messages-list-preview-who {
    font-weight: 600;
    color: #00274c;
    margin-right: 0.25em;
}

.messages-list-meta {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
}

.messages-list-meta-label {
    margin-right: 6px;
}

.messages-list-meta-label::after {
    content: "·";
    margin-left: 6px;
    color: #999;
}

.messages-list-time {
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    .messages-page {
        padding: 0;
    }

    .messages-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .messages-browse-link {
        justify-content: center;
    }

    .messages-card {
        padding: 16px;
    }

    a.messages-list-item {
        padding: 14px 12px;
    }
}

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.listings-section {
    padding: 0;
}

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

.no-results {
    text-align: center;
    padding: 24px 16px;
    font-size: 0.95rem;
}