/* assets/cids.css */

/* Toolbar igual ao de Receitas */
.cids-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    background: var(--tab-inactive);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    /* Removemos width: 100% forçado pois o flex-direction: column do pai já cuida disso */
}

.search-cids {
    flex: 1;
    /* Ajuste para não quebrar em telas menores */
    min-width: 200px; 
    padding: 10px 15px;
    border-radius: 25px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    outline: none;
}
.search-cids:focus { border-color: var(--accent-color); }

/* Container da Tabela */
.cids-container {
    background: var(--bg-container);
    border: none;
    border-radius: 8px;
    min-height: 200px; /* Reduzi um pouco o min-height, opcional */
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    height: auto; /* Garante altura automática */
}

.cids-header-row {
    display: flex;
    padding: 10px 20px;
    background: var(--hover-row);
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.lista-cids-body {
    flex: 1;
    /* REMOVIDO: overflow-y: auto; */
    /* REMOVIDO: max-height: 60vh; */
    overflow: visible; /* Permite que a lista cresça livremente */
    height: auto;
}

.cid-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.cid-row:hover { background: var(--hover-row); }
.cid-row:last-child { border-bottom: none; }

.cid-col-nome { flex: 1; color: var(--text-main); font-size: 0.95rem; }
.cid-col-code { width: 100px; text-align: right; }

.code-badge {
    background: var(--accent-color);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
}

.cid-empty { padding: 30px; text-align: center; color: #888; font-style: italic; }

.btn-icon-delete {
    background: none; border: none; color: var(--danger-color);
    cursor: pointer; margin-left: 15px; padding: 5px; opacity: 0.6; transition: 0.2s;
}
.btn-icon-delete:hover { opacity: 1; transform: scale(1.1); }

[data-theme="dark"] .search-cids {
    background: #2e2e2e;
}

/* Botão "x" de limpar busca — posicionado SOBRE o input #busca-cid */
.cids-toolbar .search-input-wrapper {
    position: relative;
    max-width: 350px;
}

@media (max-width: 900px) {
    .cids-toolbar .search-input-wrapper {
        max-width: none;
    }
}
.cids-toolbar .search-input-wrapper .search-receitas {
    width: 100%;
    max-width: none;
    padding-right: 36px;
}
.cids-toolbar .search-clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #888);
    font-size: 0.85rem;
    padding: 6px 8px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 2;
}
.cids-toolbar .search-clear-btn:hover {
    color: var(--text-main);
    background: var(--hover-row, rgba(0,0,0,0.05));
}

@media (max-width: 900px) {
    #slot-perfil-cids {
        padding: 0 20px;
        margin-top: 20px;
    }

    .cids-toolbar {
        background: transparent;
        border-radius: 0;
        border: none;
        padding: 0 20px;
    }

    /* "Adicionar CID": FAB pílula no canto inferior direito (recolhe em bolinha) */
    .cids-toolbar .btn-add-receita {
        position: fixed;
        right: 16px;
        bottom: 76px; /* acima da bottom-nav (60px) + margem */
        height: 52px;
        max-width: 52px;
        padding: 0;
        border-radius: 26px;
        overflow: hidden;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        justify-content: flex-end;
        z-index: 4500;
        box-shadow: 0 6px 18px rgba(0,0,0,0.20);
        transition: max-width 0.35s ease, transform 0.12s linear;
    }
    .cids-toolbar .btn-add-receita .cid-add-label { display: none; }
    .cids-toolbar .btn-add-receita i {
        flex: 0 0 52px;
        text-align: center;
        font-size: 18px;
        margin: 0;
        order: 2;
    }
    .cids-toolbar .btn-add-receita .cid-add-legend {
        display: inline-block;
        order: 1;
        opacity: 0;
        margin: 0;
        padding-left: 16px;
        padding-right: 18px;
        font-size: 13px;
        font-weight: 600;
        transition: opacity 0.2s ease;
    }
    .cids-toolbar .btn-add-receita.is-legend { max-width: min(86vw, 340px); }
    .cids-toolbar .btn-add-receita.is-legend .cid-add-legend { opacity: 1; }
}