/* Codes portes — style proche de l'annuaire */

.alertSuccess {
    background-color: #d4edda;
    color: #155724;
    padding: 15px;
    margin: 0 auto 16px;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
    text-align: center;
    max-width: 800px;
    transition: opacity 0.5s ease-in-out;
}

.alertError {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    margin: 0 auto 16px;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    text-align: center;
    max-width: 800px;
    transition: opacity 0.5s ease-in-out;
}

.codeporte-page {
    position: relative;
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 10px 10px 140px;
    box-sizing: border-box;
}

.codeporte-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
}

.codeporte-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    min-width: 0;
}

.codeporte-title-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.codeporte-logo {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.codeporte-logo-image {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.codeporte-eyebrow {
    margin: 0 0 2px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.codeporte-title-block h1 {
    margin: 0;
    font-size: 1.35rem;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.codeporte-search {
    margin: 0 0 16px;
}

.codeporte-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 2px 6px rgb(0 13 16 / 18%);
    font-size: 1rem;
    outline: none;
}

.codeporte-search input::placeholder {
    color: #64748b;
    font-style: italic;
}

.codeporte-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.codeporte-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px 12px;
    background: #0e1c274d;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgb(0 13 16 / 35%);
    font-weight: 600;
}

.service-card[hidden],
.contact-row[hidden],
.codeporte-empty[hidden] {
    display: none !important;
}

.service-card {
    background-color: #0e1c274d;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgb(0 13 16 / 64%);
    padding: 14px 16px;
    box-sizing: border-box;
}

.service-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.18);
}

.service-title-wrap {
    min-width: 0;
    flex: 1 1 auto;
}

.service-card-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: #0f172a;
    line-height: 1.3;
}

.service-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
}

.service-contacts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 8px;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.contact-name {
    font-size: 1rem;
    color: #111;
}

.codeporte-code {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(12, 136, 182, 0.16);
    color: #0c88b6;
    font-weight: 800;
    letter-spacing: 0.06em;
    font-size: 0.98rem;
    word-break: break-word;
}

.contact-actions {
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.contact-edit,
.contact-delete {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.contact-edit img,
.contact-delete img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
}

body.codeporte-modal-open {
    overflow: hidden;
}

.codeporte-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.codeporte-modal.is-open {
    display: flex;
}

.codeporte-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
}

.codeporte-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 28px 22px 22px;
    background-color: rgba(226, 236, 242, 0.96);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    text-align: center;
    color: #000;
    box-sizing: border-box;
}

.codeporte-modal-dialog h2 {
    margin: 8px 0 18px;
    font-size: 1.25rem;
    color: #111;
}

.codeporte-modal-dialog .close-button {
    position: absolute;
    top: 6px;
    right: 12px;
    border: none;
    background: transparent;
    font-size: 2.5em;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.codeporte-form-message {
    margin: 0 0 12px;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
}

.codeporte-form-message.is-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.codeporte-form-message.is-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.detail-row-new {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
    border-bottom: 1px solid #b0c4de;
    padding-bottom: 5px;
    text-align: left;
}

.detail-icon-new {
    width: 25px;
    height: 25px;
    margin-right: 15px;
}

.codeporte-modal-dialog input[type="text"] {
    flex-grow: 1;
    border: none;
    background-color: transparent;
    color: black;
    font-size: 1rem;
    outline: none;
    padding: 5px 0;
    min-width: 0;
}

.codeporte-site-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.codeporte-site-toggle {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #111;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.codeporte-site-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 5;
    display: none;
    flex-direction: column;
    flex-wrap: nowrap;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #eef4f8;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
    column-count: 1;
    columns: 1;
}

.codeporte-site-menu.is-open {
    display: flex;
}

.codeporte-site-menu[hidden] {
    display: none !important;
}

.codeporte-site-menu li {
    display: block;
    width: 100%;
    float: none;
}

.codeporte-site-menu button {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.98rem;
    color: #111;
    cursor: pointer;
}

.codeporte-site-menu button:hover,
.codeporte-site-menu button:focus {
    background: rgba(71, 138, 201, 0.18);
}

.codeporte-site-empty {
    padding: 10px 12px;
    color: #334155;
    font-style: italic;
}

.codeporte-modal-dialog input::placeholder {
    color: #212224;
    font-style: italic;
}

.action-button-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background-color: transparent;
    color: white;
    font-size: 1.1em;
    font-weight: bold;
}

.action-button-modal img {
    width: 25px;
    height: 25px;
}

.save-button-modal {
    background-color: #478ac9;
}

.save-button-modal:hover {
    background-color: #2d6ca8;
}

.save-button-modal:disabled {
    opacity: 0.7;
    cursor: wait;
}

#genericConfirmationModal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    justify-content: center;
    align-items: center;
    animation: codeporteFadeIn 0.3s ease-out;
}

@keyframes codeporteFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#genericConfirmationModal .modal-content {
    background-color: #ffffff;
    margin: auto;
    padding: 25px 20px;
    border-radius: 12px;
    width: 85%;
    max-width: 450px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    text-align: center;
    position: relative;
    transform: scale(0.95);
    animation: codeporteZoomIn 0.3s ease-out forwards;
}

@keyframes codeporteZoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#genericConfirmationModal #modalConfirmationMessage {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.5;
}

#genericConfirmationModal #modalConfirmationMessage strong {
    color: #dc3545;
    font-weight: 700;
}

#genericConfirmationModal .modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#genericConfirmationModal .modal-btn-cancel,
#genericConfirmationModal #confirmActionButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#genericConfirmationModal .modal-btn-cancel {
    background-color: #6c757d;
    color: #fff;
    order: 1;
}

#genericConfirmationModal .modal-btn-cancel:hover {
    background-color: #5a6268;
}

#genericConfirmationModal #confirmActionButton {
    background-color: #dc3545;
    color: #fff;
    order: 2;
}

#genericConfirmationModal #confirmActionButton:hover {
    background-color: #c82333;
}

.add-button-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1000;
}

.add-button {
    display: block;
    width: 60px;
    height: 60px;
    padding: 0;
    border: none;
    background-color: #478ac9;
    color: white;
    text-align: center;
    font-size: 4em;
    line-height: 60px;
    border-radius: 30%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-family: inherit;
}

/* Mobile : cartes plus compactes pour en afficher davantage */
@media screen and (max-width: 767.98px) {
    .codeporte-page {
        padding: 8px 8px 120px;
    }

    .codeporte-list {
        gap: 10px;
    }

    .service-card {
        padding: 8px 10px;
    }

    .service-card-header {
        align-items: center;
        margin-bottom: 6px;
        padding-bottom: 4px;
        gap: 6px;
    }

    .service-card-header h2 {
        font-size: 1.02rem;
        line-height: 1.2;
    }

    .service-count {
        font-size: 0.78rem;
    }

    .service-contacts {
        gap: 5px;
    }

    .contact-row {
        padding: 6px 8px;
        gap: 8px;
        border-radius: 6px;
    }

    .contact-info {
        gap: 2px;
    }

    .contact-name {
        font-size: 1rem;
        line-height: 1.2;
    }

    .codeporte-code {
        padding: 2px 8px;
        font-size: 0.88rem;
        letter-spacing: 0.04em;
    }

    .contact-edit,
    .contact-delete {
        width: 36px;
        height: 36px;
    }

    .contact-edit img,
    .contact-delete img {
        width: 24px;
        height: 24px;
    }
}

@media (min-width: 500px) {
    #genericConfirmationModal .modal-content {
        padding: 30px 40px;
    }

    #genericConfirmationModal .modal-btn-cancel,
    #genericConfirmationModal #confirmActionButton {
        width: auto;
        min-width: 150px;
        padding: 12px 25px;
    }

    #genericConfirmationModal .modal-actions {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
    }
}

@media screen and (min-width: 768px) {
    .codeporte-page {
        padding: 20px;
    }

    .codeporte-top {
        display: flex;
        justify-content: center;
        margin-bottom: 22px;
    }

    .codeporte-header {
        justify-content: center;
        width: 100%;
    }

    .codeporte-title-block {
        flex: 0 1 auto;
        justify-content: center;
    }

    .codeporte-title-block h1 {
        font-size: 1.6rem;
    }

    .codeporte-logo {
        width: 80px;
        height: 80px;
    }

    .codeporte-logo-image {
        width: 40px;
        height: 40px;
    }

    .codeporte-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 22px;
        align-items: start;
    }

    .add-button-container {
        position: absolute;
        top: 20px;
        right: -85px;
        bottom: auto;
    }

    .service-card {
        min-height: 140px;
        min-width: 0;
    }

    .codeporte-search {
        max-width: 560px;
        margin-left: auto;
        margin-right: auto;
    }
}
