/* -------------------------------------------------------------
   ADDRESS BOOK – MERGED + CLEANED MASTER CSS
   All duplicates removed • Conflicts resolved • No design change
--------------------------------------------------------------*/

/* ---------------------- Layout ------------------------------*/
.ab-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin-bottom: 20px;
}

.ab-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

#abControls #addressBookRows,
#addressBookRows {
    width: 100px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
    font-size: 14px;
    cursor: pointer;
}

/* ---------------------- Table -------------------------------*/
/* merged: kept the most complete table style block */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 10px 10px 0 0;
    table-layout: auto;
    overflow: hidden;
}

thead th {
    text-align: left;
    padding: 10px;
    border-bottom: 2px solid #ddd;
    font-weight: 600;
    background-color: #2271b1; /* unified from secondary CSS */
    color: #fff;
}

tbody td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

tbody tr:hover {
    background-color: #f9f9f9;
}

/* unified avatar sizing */
.ab-sl-column img {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

.ab-sl-column,
.ab-actions-column,
table td:first-child,
table td:last-child {
    text-align: center;
    vertical-align: middle;
}

/* Client name */
.client-name {
    min-width: 150px;
    font-size: 14px!important;
    font-weight: 600;
}

.client-name-text {
    cursor: pointer;
    color: #0073aa;
    text-decoration: underline;
}
.client-name-text:hover { color: #0056b3; }

.email, .phone-number, .notes {
    min-width: 120px;
}

/* Row tooltip */
tbody td:hover::after {
    content: attr(title);
    position: absolute;
    left: 0;
    top: 100%;
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    min-width: 200px;
    max-width: 400px;
    font-size: 13px;
    z-index: 1000;
}

/* Action icons unified */
.ab-action-icons {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.ab-action-icon,
.editClientBtn,
.deleteClientBtn {
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
    margin: 0 6px;
    display: inline-flex;
}
.ab-action-icon:hover,
.editClientBtn:hover,
.deleteClientBtn:hover {
    transform: scale(1.2);
}

/* ---------------------- Pagination ---------------------------*/
.ab-pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 15px;
    padding-right: 10px;
}

.ab-pagination button {
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ab-pagination button:hover {
    background-color: #e6e6e6;
    border-color: #bbb;
}

.ab-pagination button.active {
    background-color: #0052cc;
    color: #fff !important;
    border-color: #0052cc;
}

/* ---------------------- Buttons ------------------------------*/
.ab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid #007bff;
    background-color: #007bff;
    color: #fff !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ab-btn:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.ab-btn:active {
    background-color: #004a99;
    border-color: #004a99;
    transform: scale(0.98);
}

/* Variant buttons */
.ab-btn-import {
    background-color: #007bff;
    color: #fff;
    border: 1px solid #ddd;
}
.ab-btn-export,
.ab-btn-create {
    background-color: #007bff;
    border-color: #007bff;
}

/* Cancel button */
.cancel-btn {
    background-color: #6c757d;
    color: #fff !important;
    border: 1px solid #6c757d;
}
.cancel-btn:hover {
    background-color: #5a6268;
}
.cancel-btn:active {
    background-color: #4e555b;
    transform: scale(0.98);
}

.ab-footer-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ---------------------- Modals -------------------------------*/
.ab-modal,
.modal-overlay,
.modal-overlay-address-book {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ab-modal-inner,
.modal-container {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
    width: 100%;
    max-width: 600px;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.ab-modal-close,
.close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

/* Modal form */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

label { margin-bottom: 5px; font-weight: 600; }

input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.save-btn {
    background: #007bff !important;
    color: #fff !important;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.save-btn:hover { background: #0056b3; }

/* ---------------------- Client Details Modal ------------------*/
.modal-container.large {
    width: 90%;
    max-width: 1000px;
}

.client-details {
    width: 100%;
    border-collapse: collapse;
}
.client-details tr { border-bottom: 1px solid #eee; }
.client-details td { padding: 10px; }

.client-profile-container {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

.client-avatar {
    width: 80px;
    border-radius: 50%;
}

/* Gallery */
.gallery {
    display: flex;
    gap: 8px;
    margin: 10px 0;
}
.gallery img {
    flex: 1;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

/* ---------------------------------------
   FIX: Address Book Header Layout Restore
-----------------------------------------*/
.ab-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap; /* prevents breaking on smaller screens */
}

/* Right side actions */
.ab-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Search box style restored */
.ab-search-box {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    padding: 6px 10px;
    border-radius: 6px;
    min-width: 220px;
}

.pt-search-icon {
    margin-right: 6px;
}

.pt-search-input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 14px;
}

/* Action buttons restored */
.ab-action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

th.sortable {
    cursor: pointer;      /* shows pointer on hover */
}

/* ---------------------- Mobile & Tablet Responsive ------------------ */
@media (max-width: 768px) {
    /* Header layout */
    .ab-table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .ab-header-right {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }

    .ab-search-box {
        width: 100%;
    }
    .ab-action-buttons {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Table becomes card-like */
    table:not(.client-details),
    table:not(.client-details) thead,
    table:not(.client-details) tbody,
    table:not(.client-details) th,
    table:not(.client-details) tr,
    table:not(.client-details) td {
        display: block;
        width: 100%;
    }

    table:not(.client-details) thead { display: none; }

    table:not(.client-details) tr {
        margin-bottom: 15px;
        padding: 12px;
        background-color: #f9f9ff;
        border-radius: 8px;
        border: 1px solid #ddd;
    }

    table:not(.client-details) td {
        justify-content: space-between;
        padding: 6px 0;
        border: none;
        white-space: normal;
    }

    table:not(.client-details) td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #555;
        margin-right: 6px;
        flex: 1 0 40%;
    }

    /* Avatar adjustment */
    .ab-sl-column img {
        width: 35px;
        height: 35px;
    }

    /* Action icons alignment */
    .ab-action-icons {
        justify-content: flex-start;
        gap: 10px;
        flex-wrap: wrap;
    }

    table td:first-child,
    table td:last-child {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .ab-container {
        padding: 10px;
    }

    .ab-btn {
        padding: 6px 10px !important;
        font-size: 13px;
    }

    .pt-search-input {
        font-size: 13px;
    }

    /* Reduce table row padding on phones */
    table:not(.client-details) tr {
        padding: 10px;
    }

    .ab-sl-column img {
        width: 30px;
        height: 30px;
    }
}