@import url('https://fonts.googleapis.com/css2?family=Maven+Pro:wght@400;500;600;700;900&display=swap');

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

/* ==================== HEADER ==================== */
header {
    margin: 1% 0;
}

.top {
    text-align: center;
    padding: 20px;
}

.top img {
    max-width: 200px;
    margin-bottom: 15px;
}

.top h1 {
    font-size: 2em;
    margin-bottom: 10px;
    color: var(--primary-color, #007bff);
}

.top p {
    font-size: 1.1em;
    color: var(--gray-500, #666);
}

/* ==================== FORMULÁRIO ==================== */
main {
    padding: 20px 0;
}

.inputLabel {
    text-align: left;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 5% 15%;
}

.child {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.child > p {
    font-size: 0.85em;
    color: var(--gray-500, #666);
    margin: 5px 0 8px 0;
}

/* ==================== INPUTS ==================== */
input[type="text"],
input[type="email"],
input[type="tel"] {
    font-size: 1em;
    padding: 12px 16px;
    border: 1px solid var(--gray-400, #ccc);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    outline: none;
    font-family: 'Maven Pro', sans-serif;
    font-weight: 600;
    width: 100%;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus {
    border-color: var(--primary-color, #007bff);
}

/* ==================== SELECT CUSTOMIZADO (O que você busca) ==================== */
label[for="id_label_multiple"] {
    position: relative;
}

.IPI.custom-select {
    width: 100%;
    height: 50px;
    border: 1px solid var(--gray-400, #ccc);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    padding: 0 16px;
    align-items: center;
    cursor: pointer;
    background: white;
    user-select: none;
    transition: border-color 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.IPI.custom-select:focus {
    border-color: var(--primary-color, #007bff);
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: 2px;
}

#IPIp {
    margin: 0;
    overflow: hidden;         /* ESCONDE o que ultrapassar a largura */
    text-overflow: ellipsis;  /* ADICIONA "..." quando o texto for cortado */
    flex: 1;                  /* Faz o texto ocupar o espaço máximo disponível */
    padding-right: 10px;      /* Espaço entre o texto e a seta */
    font-size: 0.9em;
    color: #333;
}

#IPIp.placeholder {
    margin: 0;
    font-weight: 600;
    font-size: 0.95em;
    color: #333;
    text-overflow: ellipsis;
    overflow: hidden;
}

.expand {
    transition: transform 0.3s;
    color: #666;
}

.custom-select.open .expand {
    transform: rotate(180deg);
}

/* Lista de opções do multiselect */
#meu-select {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    z-index: 999;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    max-height: 250px;
    overflow-y: auto;
}

#meu-select li {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    font-size: 0.9em;
    color: #333;
}

#meu-select li:last-child {
    border-bottom: none;
}

#meu-select li:hover {
    background-color: #f8f9fa;
    color: var(--primary-color, #007bff);
}

#meu-select li.selected {
    background-color: #e9ecef;
    font-weight: bold;
    color: #000;
}

/* ==================== SELECTS NATIVOS (Faturamento e Segmento) ==================== */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-input {
    width: 100%;
    height: 50px;
    padding: 0 40px 0 16px;
    font-size: 1em;
    font-family: 'Maven Pro', sans-serif;
    font-weight: 600;
    border: 1px solid var(--gray-400, #ccc);
    border-radius: 8px;
    appearance: none;
    background-color: white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: border-color 0.3s;
    color: #333;
}

.custom-select-input:focus {
    border-color: var(--primary-color, #007bff);
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: 2px;
}

.select-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #666;
}

/* ==================== CHECKBOX DE TERMOS ==================== */
.terms-container {
    grid-column: span 2;
    margin: 20px 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    gap: 10px;
}

.custom-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-400, #ccc);
    border-radius: 4px;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
    transition: all 0.3s;
}

.custom-checkbox:checked ~ .checkbox-custom {
    background-color: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
}

.custom-checkbox:checked ~ .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text {
    font-size: 0.95em;
    color: #333;
}

.terms-description {
    font-size: 0.8em;
    color: var(--gray-500, #666);
    margin-top: 8px;
    margin-left: 30px;
    line-height: 1.4;
}

/* ==================== MENSAGENS DE ERRO ==================== */
.error-message {
    color: #dc3545;
    font-size: 0.85em;
    margin-top: 5px;
    display: none;
}

.error-message:not(:empty) {
    display: block;
}

/* ==================== BOTÃO DE ENVIO ==================== */
#botao {
    grid-column: span 2;
    width: 100%;
    max-width: 400px;
    margin: 30px auto 20px;
    justify-self: center;
    font-size: 1.1em;
    padding: 14px 24px;
    border: 1px solid var(--gray-500, #999);
    border-radius: 8px;
    background-color: var(--primary-color, #007bff);
    color: white;
    transition: all 0.2s;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#botao:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    background-color: var(--primary-hover, #0056b3);
}

#botao:active {
    transform: translateY(0);
}

#botao:focus {
    outline: 2px solid var(--primary-color, #007bff);
    outline-offset: 2px;
}

.button-icon-left {
    width: 20px;
    height: 20px;
}

.button-text {
    font-weight: 600;
}

/* ==================== FOOTER ==================== */
footer {
    text-align: center;
    padding: 30px 20px;
    background-color: #f8f9fa;
    margin-top: 50px;
    border-top: 1px solid #e0e0e0;
}

footer p {
    margin: 5px 0;
    font-size: 0.9em;
    color: var(--gray-500, #666);
}

.footer-address,
.footer-cnpj {
    font-size: 0.85em;
    color: #888;
}

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

.modal[hidden] {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 25px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.modal-header.error {
    background-color: #f8d7da;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin: 10px 0;
    color: #555;
    line-height: 1.6;
}

.error-detail {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
    text-align: right;
}

.modal-button {
    padding: 12px 24px;
    background-color: var(--primary-color, #007bff);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-button:hover {
    background-color: var(--primary-hover, #0056b3);
    transform: translateY(-1px);
}

.modal-button.error {
    background-color: #dc3545;
}

.modal-button.error:hover {
    background-color: #c82333;
}

/* ==================== RESPONSIVIDADE ==================== */

/* Tablets e dispositivos médios (1024px e abaixo) */
@media (max-width: 1024px) {
    header {
        margin: 3% 0;
    }

    .top {
        padding: 20px 15px;
    }

    .top img {
        max-width: 180px;
    }

    .top h1 {
        font-size: 1.8em;
    }

    .top p {
        font-size: 1em;
        padding: 0 10px;
    }

    /* IMPORTANTE: Grid vira 1 coluna */
    .inputLabel {
        grid-template-columns: 1fr;
        margin: 5% 8%;
        gap: 0;
    }

    /* Cada campo ocupa 1 coluna inteira */
    .child {
        width: 100%;
        margin-bottom: 20px;
        grid-column: span 1;
    }

    /* Inputs com largura total */
    input[type="text"],
    input[type="email"],
    input[type="tel"] {
        width: 100%;
    }

    /* Selects com largura total */
    .IPI.custom-select,
    .custom-select-wrapper {
        width: 100%;
    }

    /* Lista do multiselect também 100% */
    #meu-select {
        width: 100%;
    }

    /* Container de termos ocupa 1 coluna */
    .terms-container {
        grid-column: span 1;
        margin: 10px 0 20px 0;
    }

    /* Botão ocupa 1 coluna */
    #botao {
        grid-column: span 1;
        max-width: 100%;
        width: 100%;
        margin: 20px 0;
    }

    /* Footer */
    footer {
        padding: 25px 15px;
    }
}

/* Tablets pequenos (768px e abaixo) */
@media (max-width: 768px) {
    .top h1 {
        font-size: 1.6em;
    }

    .top p {
        font-size: 0.95em;
    }

    .inputLabel {
        margin: 5% 6%;
    }

    .child {
        margin-bottom: 18px;
    }

    .child > p {
        font-size: 0.82em;
    }

    /* Ajuste de altura dos campos */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    .custom-select-input,
    .IPI.custom-select {
        height: 48px;
        font-size: 0.95em;
        padding: 12px 14px;
    }

    .select-arrow,
    .expand {
        width: 18px;
        height: 18px;
    }

    #botao {
        font-size: 1.05em;
        padding: 13px 20px;
    }

    .button-icon-left {
        width: 18px;
        height: 18px;
    }
}

/* Smartphones (480px e abaixo) */
@media (max-width: 480px) {
    header {
        margin: 8% 0 0 0;
    }

    .top {
        padding: 15px 10px;
    }

    .top img {
        max-width: 150px;
        margin-bottom: 12px;
    }

    .top h1 {
        font-size: 1.4em;
        margin-bottom: 8px;
    }

    /* Esconde o parágrafo no mobile */
    .top p {
        display: none;
    }

    /* Formulário com menos margem */
    .inputLabel {
        grid-template-columns: 1fr;
        margin: 8% 5%;
        gap: 0;
    }

    .child {
        width: 100%;
        margin-bottom: 15px;
    }

    .child > p {
        font-size: 0.78em;
        margin: 4px 0 6px 0;
    }

    /* Campos menores em mobile */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    .custom-select-input,
    .IPI.custom-select {
        width: 100%;
        height: 45px;
        font-size: 0.9em;
        padding: 10px 12px;
    }

    /* Ajuste do padding do select para não cortar o texto */
    .custom-select-input {
        padding-right: 35px;
    }

    /* Setas menores */
    .select-arrow,
    .expand {
        width: 16px;
        height: 16px;
        right: 12px;
    }

    /* Lista do multiselect */
    #meu-select {
        max-height: 200px;
        font-size: 0.9em;
    }

    #meu-select li {
        padding: 10px 12px;
        font-size: 0.88em;
    }

    /* Checkbox */
    .checkbox-custom {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }

    .checkbox-text {
        font-size: 0.88em;
        line-height: 1.4;
    }

    .terms-description {
        margin-left: 0;
        margin-top: 6px;
        font-size: 0.72em;
        line-height: 1.3;
    }

    /* Botão mobile */
    #botao {
        width: 100%;
        margin: 25px 0 15px 0;
        padding: 13px 18px;
        font-size: 0.98em;
        grid-column: span 1;
    }

    .button-icon-left {
        width: 16px;
        height: 16px;
    }

    .button-text {
        font-size: 1em;
    }

    /* Footer mobile */
    footer {
        margin-top: 40px;
        padding: 20px 12px;
    }

    footer p {
        font-size: 0.8em;
        line-height: 1.5;
    }

    .footer-address,
    .footer-cnpj {
        font-size: 0.75em;
    }

    /* Modais mobile */
    .modal-content {
        width: 95%;
        margin: 0 10px;
    }

    .modal-header {
        padding: 20px 18px;
    }

    .modal-header h2 {
        font-size: 1.25em;
    }

    .modal-body {
        padding: 20px 18px;
    }

    .modal-body p {
        font-size: 0.9em;
    }

    .modal-footer {
        padding: 18px;
    }

    .modal-button {
        padding: 11px 20px;
        font-size: 0.95em;
        width: 100%;
    }
}

/* Smartphones muito pequenos (360px e abaixo) */
@media (max-width: 360px) {
    .top img {
        max-width: 130px;
    }

    .top h1 {
        font-size: 1.2em;
    }

    .inputLabel {
        margin: 8% 4%;
    }

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    .custom-select-input,
    .IPI.custom-select {
        height: 42px;
        font-size: 0.85em;
        padding: 9px 11px;
    }

    .child > p {
        font-size: 0.75em;
    }

    #botao {
        padding: 12px 16px;
        font-size: 0.92em;
    }

    .modal-header h2 {
        font-size: 1.15em;
    }
}