/* ============================================================
   Formulario de Atendimento ao Associado - Redesign Referencia
   ============================================================ */

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

:root {
    /* Mobile / base typography */
    --fs-header-title: 1.65rem;
    --fs-header-subtitle: 0.92rem;
    --fs-section-title: 1.12rem;
    --fs-section-subtitle: 0.92rem;
    --fs-label: 0.88rem;
    --fs-input: 0.96rem;
    --fs-owner-check: 0.90rem;
    --fs-topic-title: 1.02rem;
    --fs-topic-subtitle: 0.84rem;
    --fs-topic-detail-label: 0.90rem;
    --fs-topic-link: 0.92rem;
    --fs-topic-textarea: 0.94rem;
    --fs-return-label: 0.95rem;
    --fs-return-pill: 0.98rem;
    --fs-privacy: 0.84rem;
    --fs-submit: 1rem;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #fcfaf7;
    color: #232323;
    line-height: 1.45;
    min-height: 100vh;
    font-weight: 300;
}

.page-header {
    width: 100%;
    background: #024220;
    padding: 28px 32px 42px;
}

.page-header-inner {
    max-width: 1260px;
    margin: 0 auto;
}

.header-logo {
    height: 42px;
    width: auto;
    object-fit: contain;
    margin-bottom: 20px;
}

.header-text h1 {
    color: #ffffff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: var(--fs-header-title);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.12;
}

.header-subtitle {
    max-width: 1020px;
    margin-top: 14px;
    color: rgba(255, 255, 255, 0.92);
    font-size: var(--fs-header-subtitle);
    line-height: 1.34;
    font-weight: 300;
}

.header-subtitle strong {
    color: #ffffff;
    font-weight: 700;
}

.form-wrapper {
    width: 100%;
    max-width: 1260px;
    margin: 46px auto 0;
    padding: 0 22px 74px;
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 14px;
    border: 1px solid transparent;
    font-size: 0.94rem;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.form-section {
    margin-top: 28px;
}

.form-section-last {
    margin-top: 42px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.section-badge {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #024220;
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    font-weight: 500;
    line-height: 1;
    flex-shrink: 0;
}

.section-title {
    font-family: Georgia, "Times New Roman", serif;
    color: #024220;
    text-transform: uppercase;
    font-size: var(--fs-section-title);
    letter-spacing: 0.02em;
    font-weight: 500;
    line-height: 1.1;
}

.section-subtitle {
    margin: 0 0 18px 58px;
    color: #024220;
    font-size: var(--fs-section-subtitle);
    font-weight: 600;
    line-height: 1.25;
}

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

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #353535;
    font-size: var(--fs-label);
    font-weight: 300;
    text-transform: none;
    letter-spacing: 0;
}

input[type="text"],
input[type="email"],
input[type="url"] {
    width: 100%;
    border: none;
    border-bottom: 1.8px solid #4a4a4a;
    border-radius: 0;
    background: transparent;
    padding: 7px 0 8px;
    font-family: inherit;
    font-size: var(--fs-input);
    color: #242424;
    outline: none;
    transition: border-color 0.15s ease;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
textarea::placeholder {
    color: #b6b2aa;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus {
    border-bottom-color: #024220;
}

.readonly-field {
    border-bottom-color: #d2d2d2 !important;
    color: #8f8f8f;
}

.fields-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 18px 22px;
    margin-bottom: 10px;
}

.owner-group {
    margin-bottom: 0;
}

.is-owner-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 8px;
    font-size: var(--fs-owner-check);
    color: #1f1f1f;
    cursor: pointer;
    font-weight: 300;
}

.is-owner-check input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: #024220;
    cursor: pointer;
}

#is_owner {
    width: auto;
    border: none;
    background: none;
    padding: 0;
}

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

.topic-item {
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #f0ede7;
    padding: 0 14px;
}

.topic-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 0;
    cursor: pointer;
    user-select: none;
}

.topic-row:hover .topic-icon-box {
    background: #e7f0ea;
}

.topic-icon-box {
    width: 42px;
    height: 42px;
    border-radius: 9px;
    background: #f3efe7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #024220;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.topic-icon-box svg {
    width: 22px;
    height: 22px;
}

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

.topic-title {
    display: block;
    color: #212121;
    font-size: var(--fs-topic-title);
    font-weight: 700;
    line-height: 1.22;
}

.topic-subtitle {
    display: block;
    color: #505050;
    font-size: var(--fs-topic-subtitle);
    margin-top: 1px;
    line-height: 1.2;
    font-weight: 300;
}

.topic-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    border-radius: 2px;
    border: 2px solid #024220;
    background: #fff;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.topic-checkbox:checked {
    background: #024220;
}

.topic-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    width: 4px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.outros-fieldset {
    border: none;
    padding: 0 0 10px;
}

.outros-fieldset label {
    margin-bottom: 4px;
}

.topic-extra {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, opacity 0.28s ease;
}

.topic-extra.active {
    opacity: 1;
    padding-bottom: 14px;
}

.topic-detail-group {
    margin-top: 8px;
    padding-left: 0;
}

.topic-detail-group > label {
    margin-bottom: 6px;
    font-size: var(--fs-topic-detail-label);
    font-weight: 300;
}

.topic-detail-wrapper {
    position: relative;
}

.topic-detail-wrapper textarea {
    width: 100%;
    min-height: 176px;
    border: 1px solid #cfcac1;
    border-radius: 9px;
    background: #fff;
    color: #252525;
    font-family: inherit;
    font-size: var(--fs-topic-textarea);
    padding: 10px 94px 10px 10px;
    resize: vertical;
    outline: none;
}

.topic-detail-wrapper textarea:focus {
    border-color: #024220;
}

.topic-detail-wrapper.has-file textarea {
    border-color: #2e7d32;
    box-shadow: 0 0 0 1px rgba(46, 125, 50, 0.2);
}

.topic-detail-toolbar {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 6px;
    padding: 2px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
}

.topic-detail-button {
    width: 40px;
    height: 40px;
    border: 1px solid #d8d8d8;
    background: #fff;
    color: #5c5c5c;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.topic-detail-button:hover {
    border-color: #024220;
    color: #024220;
}

.topic-detail-button:disabled {
    opacity: 0.45;
    cursor: default;
}

.topic-detail-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topic-detail-attachments {
    margin-top: 3px;
}

.topic-files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.topic-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 260px;
    padding: 4px 8px 4px 12px;
    border-radius: 20px;
    border: 1px solid #a5d6a7;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 12px;
    font-weight: 500;
}

.topic-file-chip-name {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topic-file-chip-remove {
    flex-shrink: 0;
    border: none;
    background: none;
    color: #2e7d32;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: 0.6;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topic-file-chip-remove:hover {
    opacity: 1;
    background: rgba(46, 125, 50, 0.15);
}

.topic-link-message {
    margin: 10px 0 4px;
    color: #565656;
    font-size: var(--fs-topic-link);
}

.topic-link-message a {
    color: #024220;
    text-decoration: underline;
}

.return-label {
    margin: 8px 0 12px;
    text-align: center;
    color: #313131;
    font-size: var(--fs-return-label);
    font-weight: 300;
}

.return-options {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.return-option {
    position: relative;
}

.return-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.return-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 132px;
    padding: 11px 22px;
    border: 2px solid #024220;
    border-radius: 16px;
    color: #024220;
    background: #fff;
    font-size: var(--fs-return-pill);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.return-option input[type="radio"]:checked ~ .return-pill {
    background: #024220;
    color: #fff;
}

.return-option:hover .return-pill {
    background: #f4faf6;
}

.return-option input[type="radio"]:checked ~ .return-pill:hover {
    background: #03532a;
}

.privacy-text {
    margin-bottom: 14px;
    text-align: center;
    color: #3a3a3a;
    font-size: var(--fs-privacy);
    font-weight: 300;
}

.privacy-text a {
    color: inherit;
    text-decoration: underline;
}

.btn-submit {
    display: block;
    width: min(420px, 100%);
    margin: 0 auto;
    border: none;
    border-radius: 16px;
    padding: 12px 16px;
    background: #024220;
    color: #fff;
    font-family: inherit;
    font-size: var(--fs-submit);
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.btn-submit:hover {
    background: #03552b;
}

.btn-submit:disabled {
    opacity: 0.7;
    cursor: wait;
}

.btn {
    padding: 10px 22px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 8px;
}

.btn-primary {
    background: #1a3225;
    color: #fff;
}

.btn-primary:hover {
    background: #213d2e;
}

.btn-secondary {
    background: #95a5a6;
    color: #fff;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* Garante prioridade sobre a classe genérica .btn */
.btn.btn-submit {
    display: block;
    margin-left: auto;
    margin-right: auto;
    float: none;
    border-radius: 16px;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    width: 90%;
    max-width: 560px;
    padding: 24px;
    border-radius: 10px;
    background: #fff;
    text-align: center;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
    color: #1a3225;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.modal-content p {
    color: #555;
    font-size: 0.93rem;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 16px;
    font-size: 28px;
    font-weight: 700;
    color: #aaa;
    line-height: 1;
    cursor: pointer;
}

.close-modal:hover {
    color: #333;
}

.camera-view {
    margin: 16px 0;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}

.camera-view video {
    width: 100%;
    max-height: 380px;
    display: block;
    margin: 0 auto;
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.camera-controls .btn {
    margin: 0;
}

.sacos-bags-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.saco-card {
    position: relative;
    padding: 12px;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    background: #fff;
    transition: border-color 0.2s;
}

.saco-card.selected {
    border-color: #1a3225;
}

.saco-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 5px;
    background: #f0f0f0;
    color: #333;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.saco-card.selected .saco-badge {
    background: #1a3225;
    color: #fff;
}

.saco-name {
    color: #222;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 3px;
    padding-right: 36px;
}

.saco-specs {
    color: #888;
    font-size: 0.76rem;
    margin-bottom: 8px;
}

.saco-price {
    color: #1a3225;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 10px;
}

.saco-price-label {
    color: #aaa;
    font-size: 0.72rem;
    font-weight: 400;
}

.saco-qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.saco-qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid #ccc;
    background: #fff;
    color: #555;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.saco-qty-btn:hover {
    border-color: #1a3225;
    color: #1a3225;
}

.saco-qty-value {
    min-width: 20px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
}

.saco-subtotal {
    margin-top: 6px;
    color: #555;
    font-size: 0.78rem;
}

.sacos-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
}

.sacos-total-label {
    color: #555;
    font-size: 0.88rem;
    font-weight: 600;
}

.sacos-total-value {
    color: #888;
    font-size: 1rem;
    font-weight: 700;
}

.sacos-total-bar--active .sacos-total-value {
    color: #1a3225;
}

/* ===== Owner Autocomplete ===== */
.owner-autocomplete {
    position: relative;
}

.owner-autocomplete input[type="text"] {
    padding-right: 28px;
}

.owner-autocomplete::after {
    content: '';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-right: 1.5px solid #777;
    border-bottom: 1.5px solid #777;
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
    transition: opacity 0.15s;
}

.owner-autocomplete.is-locked::after {
    opacity: 0;
}

.owner-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #dedad3;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
    max-height: 220px;
    overflow-y: auto;
    z-index: 200;
    scroll-behavior: smooth;
}

.owner-dropdown:empty {
    display: none;
}

.owner-dropdown-item {
    padding: 10px 14px;
    font-size: var(--fs-input);
    color: #242424;
    cursor: pointer;
    border-bottom: 1px solid #f5f3ef;
    transition: background 0.08s;
    line-height: 1.3;
}

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

.owner-dropdown-item:hover,
.owner-dropdown-item.active {
    background: #edf5f0;
    color: #024220;
}

.owner-dropdown-no-results {
    padding: 12px 14px;
    font-size: var(--fs-input);
    color: #999;
    font-style: italic;
}

@media (min-width: 1024px) {
    :root {
        /* Desktop typography */
        --fs-header-title: 2.35rem;
        --fs-header-subtitle: 1.08rem;
        --fs-section-title: 1.75rem;
        --fs-section-subtitle: 1.05rem;
        --fs-label: 0.97rem;
        --fs-input: 1.02rem;
        --fs-owner-check: 0.98rem;
        --fs-topic-title: 1.32rem;
        --fs-topic-subtitle: 0.98rem;
        --fs-topic-detail-label: 0.96rem;
        --fs-topic-link: 0.95rem;
        --fs-topic-textarea: 1rem;
        --fs-return-label: 1rem;
        --fs-return-pill: 1rem;
        --fs-privacy: 0.94rem;
        --fs-submit: 1.1rem;
    }
}

@media (max-width: 1024px) {
    .page-header {
        padding: 24px 20px 34px;
    }

    .header-logo {
        height: 52px;
        margin-bottom: 22px;
    }

    .form-wrapper {
        margin-top: 34px;
        padding: 0 16px 52px;
    }

    .fields-row {
        grid-template-columns: 1fr 1fr;
    }

    .fields-row .form-group:first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .fields-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .section-header {
        gap: 10px;
    }

    .section-badge {
        width: 34px;
        height: 34px;
        border-radius: 8px;
        font-size: 1.15rem;
    }

    .section-subtitle {
        margin-left: 0;
    }

    .topic-item {
        padding: 0 10px;
    }

    .topic-title {
        font-size: 1rem;
    }

    .topic-subtitle {
        font-size: 0.82rem;
    }

    .topic-detail-wrapper textarea {
        min-height: 140px;
    }

    .return-options {
        flex-direction: column;
        align-items: center;
    }

    .return-pill {
        width: 220px;
    }

    .btn-submit {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sacos-bags-grid {
        grid-template-columns: 1fr;
    }
}

fieldset {
    border: none;
}
