/* Vessel Valuation v2 - Hull & Machinery Premium Calculator */

:root {
    --vv-primary: #1A2755;
    --vv-secondary: #CCB28C;
    --vv-bg: #f5f5f5;
    --vv-text: #222;
    --vv-text-light: #fff;
    --vv-border: #d0d0d0;
    --vv-input-bg: #F1F2F5;
    --vv-transition: all 0.3s ease;
    --vv-radius: 8px;
}

#vv-container {
    max-width: 700px;
    margin: 40px auto;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.vv-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 30px;
    border: 1px solid #eee;
}

.vv-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--vv-primary);
    margin: 0 0 25px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vv-section {
    animation: vvFadeIn 0.4s ease-out;
}

.vv-hidden {
    display: none !important;
}

.vv-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--vv-primary);
    margin-bottom: 6px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Search ────────────────────────────────────────────── */

.vv-search-wrapper {
    position: relative;
}

.vv-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--vv-secondary);
    pointer-events: none;
    z-index: 2;
    transition: color 0.3s ease;
}

.vv-search-wrapper:focus-within .vv-search-icon {
    color: var(--vv-primary);
}

.vv-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 15px 20px 15px 48px !important;
    font-size: 16px !important;
    background: var(--vv-input-bg) !important;
    border: 2px solid var(--vv-border) !important;
    border-radius: var(--vv-radius) !important;
    color: var(--vv-text);
    transition: var(--vv-transition);
    outline: none;
}

.vv-search-input::placeholder {
    color: #999;
    font-style: italic;
}

.vv-search-input:focus {
    border-color: var(--vv-primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 4px rgba(26, 39, 85, 0.12) !important;
}

.vv-search-input:hover:not(:focus) {
    border-color: var(--vv-secondary);
}

.vv-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--vv-border);
    border-top: none;
    border-radius: 0 0 var(--vv-radius) var(--vv-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    scrollbar-width: thin;
    scrollbar-color: var(--vv-primary) #f1f1f1;
}

.vv-search-results::-webkit-scrollbar {
    width: 6px;
}

.vv-search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.vv-search-results::-webkit-scrollbar-thumb {
    background: var(--vv-primary);
    border-radius: 3px;
}

.vv-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.vv-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: var(--vv-transition);
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.vv-result-item:hover {
    background: #f0f8ff;
}

.vv-result-item:hover .vv-result-name {
    color: var(--vv-secondary);
}

.vv-result-type {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    color: var(--vv-primary);
}

.vv-result-name {
    font-size: 14px;
    color: var(--vv-primary);
    font-weight: 500;
    transition: color 0.2s ease;
}

.vv-search-hint {
    padding: 14px 16px;
    font-size: 13px;
    color: #888;
    text-align: center;
    font-style: italic;
}

/* ── Boat Specs Card ───────────────────────────────────── */

.vv-boat-specs {
    background: #f8f9fb;
    border: 1px solid #e8ebf0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    animation: vvFadeIn 0.3s ease-out;
}

.vv-specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
}

.vv-spec-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px solid #eef0f4;
}

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

.vv-spec-label {
    color: var(--vv-secondary);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.3px;
}

.vv-spec-value {
    color: #333;
    font-weight: 600;
    text-align: right;
}

.vv-spec-comment {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8ebf0;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    font-style: italic;
}

/* ── Inputs & Grid ─────────────────────────────────────── */

.vv-input {
    padding: 12px 14px;
    border: 2px solid var(--vv-border);
    border-radius: var(--vv-radius);
    font-size: 14px;
    transition: var(--vv-transition);
    background: var(--vv-input-bg);
    width: 100%;
    box-sizing: border-box;
    color: var(--vv-text);
}

.vv-input:focus {
    border-color: var(--vv-primary);
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 39, 85, 0.12);
}

.vv-input:hover:not(:focus) {
    border-color: var(--vv-secondary);
}

.vv-input-error {
    border-color: #e53e3e !important;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.15) !important;
}

.vv-field-error {
    display: block;
    font-size: 12px;
    color: #e53e3e;
    margin-top: 4px;
}

.vv-grid {
    display: grid;
    gap: 15px;
    margin-bottom: 18px;
}

.vv-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.vv-grid-value {
    grid-template-columns: 1fr;
}

.vv-field {
    display: flex;
    flex-direction: column;
}

.vv-value-group {
    display: flex;
    gap: 8px;
}

.vv-currency-select {
    width: 90px;
    flex-shrink: 0;
}

.vv-value-input {
    flex: 1;
}

/* ── Selected Boat Summary ─────────────────────────────── */

.vv-selected-boat-summary {
    background: var(--vv-primary);
    padding: 14px 18px;
    border-radius: var(--vv-radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--vv-text-light);
    letter-spacing: 0.3px;
}

.vv-link-btn {
    background: none;
    border: 1px solid var(--vv-secondary);
    color: var(--vv-secondary);
    text-decoration: none;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 4px;
    transition: var(--vv-transition);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vv-link-btn:hover {
    background: var(--vv-secondary);
    color: var(--vv-primary);
}

/* ── Buttons ───────────────────────────────────────────── */

.vv-btn {
    width: 100%;
    padding: 14px;
    background: var(--vv-primary);
    color: var(--vv-text-light);
    border: 2px solid var(--vv-primary);
    border-radius: var(--vv-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--vv-transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vv-btn:hover {
    background: var(--vv-secondary);
    border-color: var(--vv-secondary);
    color: var(--vv-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.vv-btn-secondary {
    background: transparent;
    color: var(--vv-primary);
    border-color: var(--vv-primary);
    margin-top: 15px;
}

.vv-btn-secondary:hover {
    background: var(--vv-primary);
    color: var(--vv-text-light);
}

/* ── Loading ───────────────────────────────────────────── */

.vv-loading {
    text-align: center;
    padding: 40px 0;
}

.vv-spinner {
    width: 38px;
    height: 38px;
    border: 4px solid var(--vv-secondary);
    border-color: var(--vv-secondary) transparent var(--vv-secondary) transparent;
    border-radius: 50%;
    margin: 0 auto 18px;
    animation: vvSpin 1s linear infinite;
}

.vv-loading p {
    color: #666;
    font-size: 14px;
}

/* ── Chat / Result Area ────────────────────────────────── */

.vv-chat-area {
    animation: vvFadeIn 0.4s ease-out;
}

.vv-chat-messages {
    max-height: 500px;
    overflow-y: auto;
    padding: 5px 0;
}

.vv-chat-msg {
    margin-bottom: 16px;
    animation: vvFadeIn 0.4s ease-out;
}

.vv-chat-text {
    background: #f0f4f8;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.vv-chat-styled {
    padding: 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

/* ── Table Styles ──────────────────────────────────────── */

.vv-chat-table-wrap {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.vv-table-caption {
    font-size: 15px;
    font-weight: 600;
    color: var(--vv-primary);
    padding: 12px 0 8px;
}

.vv-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.vv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.vv-table th {
    background: var(--vv-primary);
    color: var(--vv-text-light);
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.vv-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #eee;
    color: #444;
    vertical-align: top;
}

.vv-table tbody tr:hover {
    background: #f8f9fb;
}

.vv-table tbody tr:last-child td {
    border-bottom: none;
}

.vv-table-footer {
    font-size: 12px;
    color: #888;
    padding: 8px 0 4px;
    font-style: italic;
}

/* Table color cells (from n8n) */
.vv-table td[style*="background"],
.vv-table .pa-red-bg,
.vv-table .pa-yellow-bg,
.vv-table .pa-green-bg {
    border-radius: 4px;
    padding: 6px 10px;
    font-weight: 500;
}

/* ── Login Required ────────────────────────────────────── */

.vv-login-required {
    max-width: 500px;
    margin: 40px auto;
    text-align: center;
    padding: 30px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    color: #555;
    font-size: 15px;
}

/* ── Animations ────────────────────────────────────────── */

@keyframes vvSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes vvFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 640px) {
    #vv-container {
        margin: 20px 12px;
    }

    .vv-card {
        padding: 20px;
    }

    .vv-title {
        font-size: 18px;
    }

    .vv-grid-3 {
        grid-template-columns: 1fr;
    }

    .vv-specs-grid {
        grid-template-columns: 1fr;
        /* 1 column instead of 2 for specs to prevent overlap */
    }

    .vv-spec-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .vv-spec-value {
        text-align: left;
        word-break: break-word;
        /* Allows long model names to wrap */
    }

    .vv-value-group {
        flex-direction: column;
    }

    .vv-currency-select {
        width: 100%;
    }

    /* Vertical block layout for all tables on mobile */
    .vv-table thead,
    .vv-chat-styled table thead,
    .vv-chat-messages table thead {
        display: none !important;
        /* Hide standard table headers */
    }

    .vv-table,
    .vv-table tbody,
    .vv-table tr,
    .vv-table td,
    .vv-chat-styled table,
    .vv-chat-styled table tbody,
    .vv-chat-styled table tr,
    .vv-chat-styled table td,
    .vv-chat-messages table,
    .vv-chat-messages table tbody,
    .vv-chat-messages table tr,
    .vv-chat-messages table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    .vv-table tr,
    .vv-chat-styled table tr,
    .vv-chat-messages table tr {
        margin-bottom: 15px;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px;
        padding: 10px;
        background-color: #f9fbfd !important;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
    }

    .vv-table td,
    .vv-chat-styled table td,
    .vv-chat-messages table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        /* Align top for long text */
        text-align: right !important;
        padding: 8px 10px !important;
        border-bottom: 1px solid #f0f0f0 !important;
        white-space: normal !important;
        /* Let text wrap */
        word-break: break-word;
        /* Prevent overflow */
    }

    .vv-table td:last-child,
    .vv-chat-styled table td:last-child,
    .vv-chat-messages table td:last-child {
        border-bottom: none !important;
    }

    /* Use the data-label injected by javascript or n8n before pseudo-element */
    .vv-table td::before,
    .vv-chat-styled table td::before,
    .vv-chat-messages table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--vv-primary);
        margin-right: 15px;
        text-align: left !important;
        flex-shrink: 0;
        max-width: 50%;
    }
}

/* ─── Anti-spam Consent Checkbox ───────────────────────── */

.vv-checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 14px 0 6px;
    cursor: pointer;
    padding: 10px 14px;
    background: #f8f9fb;
    border-radius: var(--vv-radius);
    border: 1px solid #e4e6ea;
    transition: var(--vv-transition);
}

.vv-checkbox-wrapper:hover {
    border-color: var(--vv-secondary);
}

.vv-checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--vv-primary);
    cursor: pointer;
}

.vv-checkbox-text {
    font-size: 14px;
    line-height: 1.5;
    color: #555;
    padding-top: 1px;
}

#vv-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Typography & Readability Overrides (for n8n content) ─── */

.vv-chat-messages p,
.vv-chat-messages li,
.vv-chat-messages .vv-chat-styled,
.vv-chat-messages .vv-chat-styled div,
.vv-chat-messages .vv-chat-styled span {
    font-size: 16px !important;
    line-height: 1.6 !important;
}

.vv-chat-messages li {
    margin-bottom: 8px !important;
}

.vv-chat-messages table td {
    font-size: 16px !important;
}

.vv-chat-messages h3,
.vv-chat-messages h4,
.vv-chat-messages h3[style],
.vv-chat-messages h4[style],
.vv-chat-styled h4[style*="font-size"] {
    font-size: 19px !important;
    line-height: 1.4 !important;
}

/* Small text & Disclaimers */
.vv-chat-messages div[style*="font-size:12px"],
.vv-chat-messages p[style*="font-size:12px"],
.vv-chat-messages span[style*="font-size:12px"],
.vv-chat-messages div[style*="color:#888"],
.vv-chat-messages p[style*="color:#888"],
.vv-chat-messages p[style*="color:#999"] {
    font-size: 14px !important;
    line-height: 1.5 !important;
}