/*
 * aaaTranslate translator marketplace (templates/marketplace/).
 *
 * 1. Theme          5. Alerts and badges     9.  Sign-up and log-in pages
 * 2. Layout         6. Select2               10. Profile page
 * 3. Buttons        7. Footer                11. Small screens
 * 4. Cards, forms   8. Home page              12. Background updates (busy buttons, popup text)
 */

/* 1. Theme: the two plums of the aaaTranslate logo. */
:root {
    --brand: #4b2f5a;
    --brand-deep: #220035;
    --brand-tint: #f5f0f7;
    --brand-ring: rgba(75, 47, 90, 0.18);
    --ink: #1c1424;
    --muted: #6b6274;
    --line: #e8e2ec;
    --field-line: #d9d1de;
    --surface: #ffffff;
    --page: #faf8fb;
    --danger: #b42318;
    --danger-tint: #fef3f2;
    --ok: #067647;
    --ok-tint: #ecfdf3;
    --warn: #b54708;
    --warn-tint: #fffaeb;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(28, 20, 36, 0.06), 0 8px 24px rgba(28, 20, 36, 0.06);
}

/* 2. Layout */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.marketplace {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.marketplace a { color: var(--brand); }
.marketplace a:hover { color: var(--brand-deep); }
.marketplace img { max-width: 100%; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main { flex: 1; width: 100%; }
.page { padding: 40px 0 64px; }

.site-header { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; }
.site-header .logo img { display: block; height: 38px; width: auto; }
.site-nav { display: flex; align-items: center; gap: 8px; }
.site-nav form { margin: 0; }
.marketplace .nav-link { padding: 8px 12px; border-radius: 8px; color: var(--ink); font-weight: 600; text-decoration: none; }
.marketplace .nav-link:hover { background: var(--brand-tint); color: var(--brand-deep); }

h1, h2, h3 { color: var(--ink); line-height: 1.2; }
h1 { font-size: 2.25rem; margin: 0 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; margin: 0 0 4px; }
h3 { font-size: 1rem; margin: 0 0 4px; }
.lead { max-width: 640px; margin: 0 0 28px; font-size: 1.125rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sub { margin: 4px 0 0; }
.note { margin: 16px 0 0; }
.eyebrow { display: inline-block; margin-bottom: 10px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); }

/* 3. Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 22px;
    border: 1.5px solid var(--brand); border-radius: 10px;
    background: var(--brand); color: #fff;
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.marketplace .btn { color: #fff; }
.btn:hover, .marketplace .btn:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--brand-ring); }
.marketplace .btn.secondary { background: var(--surface); color: var(--brand); }
.marketplace .btn.secondary:hover { background: var(--brand-tint); color: var(--brand-deep); }
.marketplace .btn.light { background: #fff; border-color: #fff; color: var(--brand-deep); }
.marketplace .btn.light:hover { background: var(--brand-tint); border-color: var(--brand-tint); }
.marketplace .btn.ghost-light { background: transparent; border-color: rgba(255, 255, 255, 0.55); color: #fff; }
.marketplace .btn.ghost-light:hover { background: rgba(255, 255, 255, 0.12); border-color: #fff; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 0.9375rem; }
.btn:disabled, .marketplace .btn:disabled,
.btn:disabled:hover, .marketplace .btn:disabled:hover {
    background: #cfc6d4; border-color: #cfc6d4; color: #fff; cursor: not-allowed; box-shadow: none;
}
.btn.block { width: 100%; }
.btn-remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); color: var(--muted); font: inherit; cursor: pointer;
}
.btn-remove:hover { color: var(--danger); border-color: #fecdca; background: var(--danger-tint); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* 4. Cards and forms */
.card { padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.card-head p { margin: 4px 0 0; }

.form-section + .form-section { margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-section-title { margin: 0 0 14px; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.field { min-width: 0; margin-bottom: 18px; }
.field label { display: block; margin-bottom: 6px; font-size: 0.9375rem; font-weight: 600; }
.field .optional { color: var(--muted); font-weight: 400; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=tel],
.field input[type=url], .field input[type=date], .field select, .field textarea {
    width: 100%; min-height: 48px; padding: 10px 14px;
    border: 1.5px solid var(--field-line); border-radius: 10px;
    background: #fff; color: var(--ink); font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input[type=file] {
    width: 100%; padding: 14px; border: 1.5px dashed #cbbfd3; border-radius: 10px;
    background: var(--brand-tint); font: inherit; cursor: pointer;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.field.has-error input, .field.has-error select, .field.has-error textarea, .field.has-error .select2-selection { border-color: var(--danger) !important; }
.field .help { margin-top: 6px; font-size: 0.8125rem; color: var(--muted); }
.field .error { margin-top: 6px; font-size: 0.875rem; font-weight: 500; color: var(--danger); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 52px !important; }
.password-toggle {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center; width: 40px; height: 36px;
    padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.password-toggle:hover { background: var(--brand-tint); color: var(--brand); }
.password-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.password-toggle .icon-eye-off,
.password-toggle[aria-pressed="true"] .icon-eye { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye-off { display: block; }

/* Hints under a field: neutral, a warning, or a good sign. */
.hint { margin-top: 6px; font-size: 0.8125rem; color: var(--muted); }
.hint.warn { color: var(--warn); font-weight: 600; }
.hint.ok { color: var(--ok); font-weight: 600; }
.field .hint { margin-top: 6px; }
.link-button { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Password strength: five steps, one per rule met. */
.password-meter { margin: -8px 0 18px; }
.meter-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.meter-bar span { height: 5px; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.password-meter[data-strength="1"] .meter-bar span:nth-child(-n+1),
.password-meter[data-strength="2"] .meter-bar span:nth-child(-n+2) { background: var(--danger); }
.password-meter[data-strength="3"] .meter-bar span:nth-child(-n+3) { background: var(--warn); }
.password-meter[data-strength="4"] .meter-bar span:nth-child(-n+4) { background: #2e90fa; }
.password-meter[data-strength="5"] .meter-bar span { background: var(--ok); }
.meter-label { margin: 8px 0 6px; font-size: 0.8125rem; color: var(--muted); }
.meter-label strong { color: var(--ink); }
.rules { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--muted); }
.rules li { display: flex; align-items: center; gap: 8px; }
.rules li svg { flex: none; padding: 2px; border-radius: 50%; background: var(--line); color: #fff; width: 16px; height: 16px; }
.rules li.met { color: var(--ok); }
.rules li.met svg { background: var(--ok); }
.check { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.check input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); }
.field .check label { margin: 0; font-weight: 400; }
.has-error .check { border-color: var(--danger); }

/* 5. Alerts and badges */
.alert { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 20px; padding: 12px 16px; border-radius: 10px; font-weight: 500; }
.alert.success { background: var(--ok-tint); border: 1px solid #abefc6; color: var(--ok); }
.alert.error { background: var(--danger-tint); border: 1px solid #fecdca; color: var(--danger); }
.alert svg { flex: none; margin-top: 2px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.8125rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.pending, .badge.waiting { background: var(--warn-tint); color: var(--warn); }
.badge.verified { background: var(--ok-tint); color: var(--ok); }
.badge.rejected, .badge.expired { background: var(--danger-tint); color: var(--danger); }
.badge.neutral { background: var(--brand-tint); color: var(--brand); }

/* 6. Select2, matched to the inputs */
/* Only the box itself (.select2): the open list's wrapper is also a
   .select2-container, and stretching it pushed the page sideways. */
.marketplace .select2.select2-container { width: 100% !important; }
.field { position: relative; }
.marketplace .select2-container .select2-selection--single {
    display: flex; align-items: center; height: 48px;
    border: 1.5px solid var(--field-line); border-radius: 10px;
}
.marketplace .select2-container--default .select2-selection--single .select2-selection__rendered { padding-left: 14px; padding-right: 36px; line-height: 1.4; color: var(--ink); }
.marketplace .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--muted); }
.marketplace .select2-container--default .select2-selection--single .select2-selection__arrow { height: 46px; right: 8px; }
.marketplace .select2-container--default.select2-container--focus .select2-selection--single,
.marketplace .select2-container--default.select2-container--open .select2-selection--single { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.marketplace .select2-dropdown { overflow: hidden; border: 1.5px solid var(--brand); border-radius: 10px; box-shadow: var(--shadow); }
.marketplace .select2-search--dropdown { padding: 8px; }
.marketplace .select2-container--default .select2-search--dropdown .select2-search__field { padding: 10px 12px; border: 1.5px solid var(--field-line); border-radius: 8px; font: inherit; }
.marketplace .select2-results__option { padding: 10px 14px; }
.marketplace .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--brand); }
.marketplace .select2-container--default .select2-results__option--selected { background: var(--brand-tint); }

/* 7. Footer */
.site-footer { padding: 24px 0; border-top: 1px solid var(--line); background: var(--surface); font-size: 0.875rem; color: var(--muted); }
.site-footer .container { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.marketplace .site-footer a { color: var(--muted); }
.marketplace .site-footer a:hover { color: var(--brand); }

/* 8. Home page */
.hero { background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand) 100%); color: #fff; }
.hero .container { display: grid; grid-template-columns: 1fr; gap: 32px; padding-top: 56px; padding-bottom: 56px; }
.hero h1 { font-size: 2.75rem; color: #fff; }
.hero .lead { color: rgba(255, 255, 255, 0.85); }
.hero .eyebrow { color: rgba(255, 255, 255, 0.75); }
.hero .actions { margin-top: 8px; }
.steps { padding: 24px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: var(--radius); }
.steps h2 { margin-bottom: 16px; font-size: 1.0625rem; color: #fff; }
.steps ol { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.steps li { display: flex; align-items: flex-start; gap: 14px; }
.steps .num { flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--brand-deep); font-weight: 800; }
.steps strong { display: block; color: #fff; }
.steps span { font-size: 0.9375rem; color: rgba(255, 255, 255, 0.78); }
.features { display: grid; grid-template-columns: 1fr; gap: 20px; }
.feature { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.feature .icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 10px; background: var(--brand-tint); color: var(--brand); }
.feature p { margin: 6px 0 0; color: var(--muted); }
.welcome { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }

@media (min-width: 900px) {
    .hero .container { grid-template-columns: 1.3fr 1fr; align-items: center; padding-top: 80px; padding-bottom: 80px; }
    .features { grid-template-columns: repeat(3, 1fr); }
}

/* 9. Sign-up and log-in pages */
.auth { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
.auth.narrow { max-width: 480px; margin: 0 auto; }
.auth-aside { padding: 28px; border-radius: var(--radius); background: linear-gradient(160deg, var(--brand-deep) 0%, var(--brand) 100%); color: #fff; }
.auth-aside h2 { margin-bottom: 8px; font-size: 1.25rem; color: #fff; }
.auth-aside p { margin: 0; color: rgba(255, 255, 255, 0.82); }
.auth-aside ul { display: grid; gap: 12px; margin: 20px 0 0; padding: 0; list-style: none; }
.auth-aside li { display: flex; align-items: flex-start; gap: 10px; color: rgba(255, 255, 255, 0.92); }
.auth-aside li svg { flex: none; margin-top: 3px; }
.auth-card h1 { font-size: 1.75rem; }
.auth-card .lead { margin-bottom: 24px; font-size: 1rem; }
.auth-switch { margin: 20px 0 0; text-align: center; color: var(--muted); }

@media (min-width: 960px) {
    .auth:not(.narrow) { grid-template-columns: 380px 1fr; gap: 32px; }
    .auth-aside { position: sticky; top: 92px; padding: 36px; }
}
@media (max-width: 959px) {
    .auth-aside { padding: 20px; }
    .auth-aside ul { display: none; }
}

/* 10. Profile page */
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.avatar {
    flex: none; display: flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-deep), var(--brand));
    color: #fff; font-size: 1.5rem; font-weight: 800; text-transform: uppercase;
}
.profile-head h1 { margin: 0 0 4px; font-size: 1.75rem; }
.profile-head .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); }
.profile-head .badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.progress { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.progress-bar { height: 8px; margin: 10px 0 16px; overflow: hidden; border-radius: 999px; background: var(--brand-tint); }
.progress-bar span { display: block; width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-deep)); }
.progress-bar[data-done="1"] span { width: 33.34%; }
.progress-bar[data-done="2"] span { width: 66.67%; }
.progress-bar[data-done="3"] span { width: 100%; }
.checklist { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; padding: 0; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.checklist .tick { flex: none; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 2px solid var(--field-line); border-radius: 50%; color: #fff; }
.checklist li.done .tick { background: var(--ok); border-color: var(--ok); }
.checklist li:not(.done) { color: var(--muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.switch { position: relative; flex: none; width: 56px; height: 32px; }
.switch input { position: absolute; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--field-line); transition: background 0.2s; }
.switch .track::after {
    content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(24px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--brand-ring); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border: 1px solid #e4d9ea; border-radius: 999px; background: var(--brand-tint); }
.chip strong { color: var(--brand-deep); }
.chip .level { font-size: 0.875rem; color: var(--muted); }
.chip form { margin: 0; }
.chip .btn-remove { width: 28px; height: 28px; border: 0; border-radius: 50%; background: #fff; }

.docs { display: grid; gap: 12px; }
.doc { display: grid; grid-template-columns: 44px 1fr auto; align-items: start; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.doc .icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; background: var(--brand-tint); color: var(--brand); }
.doc h3 { margin: 0 0 4px; }
.doc .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.875rem; color: var(--muted); }
.doc .side { display: flex; align-items: center; gap: 10px; }
.doc .side form { margin: 0; }
.doc .reason { margin-top: 6px; font-size: 0.875rem; color: var(--danger); }

.empty { padding: 24px 16px; border: 1.5px dashed var(--field-line); border-radius: 10px; text-align: center; color: var(--muted); }

.add-panel { margin-top: 20px; border: 1.5px solid var(--line); border-radius: 10px; background: #fcfbfd; }
.add-panel > summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; list-style: none; font-weight: 700; color: var(--brand); cursor: pointer; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel > summary .plus { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 1.125rem; line-height: 1; }
.add-panel[open] > summary { border-bottom: 1px solid var(--line); }
.add-panel .panel-body { padding: 18px; }
.lang-row { display: grid; grid-template-columns: 1fr; align-items: end; gap: 0 16px; }

@media (min-width: 720px) {
    .row.two { grid-template-columns: 1fr 1fr; }
    .checklist { grid-template-columns: repeat(3, 1fr); }
    .lang-row { grid-template-columns: 2fr 1.2fr auto; }
    .lang-row .btn { margin-bottom: 18px; }
}

/* 11. Small screens */
@media (max-width: 640px) {
    h1 { font-size: 1.75rem; }
    .lead { font-size: 1rem; }
    .page { padding: 24px 0 48px; }
    .card { padding: 20px; }
    .site-header .logo img { height: 32px; }
    .marketplace .nav-link { padding: 8px; }
    .site-nav .btn.small { padding: 0 12px; }
    .actions .btn { width: 100%; }
    .hero h1 { font-size: 2rem; }
    .hero .container { padding-top: 40px; padding-bottom: 40px; }
}
@media (max-width: 560px) {
    .doc { grid-template-columns: 1fr auto; }
    .doc .icon { display: none; }
    .doc .side { flex-direction: column; align-items: flex-end; }
    .switch-row { align-items: flex-start; }
}

/* 12. Background updates. Toasts and the confirmation popup are the app's own
   (partials/toast.html, SweetAlert2 with css/inpage-css/modal-css/sweetalert2.css). */
.swal2-marketplace-text { margin: 0; font-size: 14px; color: #444; }

.btn.is-busy { cursor: progress; }
.btn.is-busy::before {
    content: ""; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
.btn.secondary.is-busy::before { border-color: var(--brand-ring); border-top-color: var(--brand); }
.btn-remove:disabled { opacity: 0.5; cursor: progress; }
form[data-busy] .switch { opacity: 0.7; }
@keyframes spin { to { transform: rotate(360deg); } }

.just-updated { animation: flash 0.9s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--brand-ring); } to { box-shadow: 0 0 0 0 transparent; } }

@media (prefers-reduced-motion: reduce) {
    .just-updated, .btn.is-busy::before { animation: none; transition: none; }
}
