/**
 * CLICKaligners Patients CRM Styles
 * Package: CLICKALIGNERS Astra Child Theme (includes/Patients/css/patients.css)
 */

.click-patients-crm-root {
    position: relative;
    width: 100%;
    margin-bottom: 40px;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 1. Top Bar */
.click-patients-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.click-patients-title-col {
    display: flex;
    align-items: center;
    gap: 14px;
}

.click-patients-page-title {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 !important;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.click-patients-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

.click-patients-count-badge strong {
    color: var(--ast-global-color-0);
    font-weight: 800;
}

/* 2. Toolbar: Search & Sort */
.click-patients-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.click-search-box-wrap {
    position: relative;
    flex: 1;
    min-width: 280px;
}

.click-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
    color: #64748b;
}

.click-patients-search-input {
    width: 100% !important;
    height: 46px !important;
    padding: 0 42px 0 46px !important;
    background: #ffffff !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    color: #0f172a !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03) !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-sizing: border-box !important;
}

.click-patients-search-input:focus {
    outline: none !important;
    border-color: var(--ast-global-color-0) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

.click-search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #f1f5f9;
    border: none;
    color: #64748b;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.click-search-clear-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.click-sort-box-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.click-sort-label {
    font-size: 13.5px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

.click-select-custom {
    position: relative;
    display: inline-block;
}

.click-patients-sort-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: 46px !important;
    padding: 0 38px 0 16px !important;
    background: #ffffff !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    color: #1e293b !important;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03) !important;
    transition: all 0.2s ease !important;
    line-height: normal !important;
}

.click-patients-sort-select:focus {
    outline: none !important;
    border-color: var(--ast-global-color-0) !important;
}

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

/* 3. Status Filter Chips */
.click-status-filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
}

.click-status-filters-row::-webkit-scrollbar {
    display: none;
}

.click-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
}

.click-status-chip:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.click-status-chip.active {
    background: var(--ast-global-color-0);
    border-color: var(--ast-global-color-0);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.click-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.click-status-chip.active .click-chip-count {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

/* 4. Patients List & Accordion Cards */
.click-patients-list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 120px;
}

.click-patient-accordion-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.click-patient-accordion-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.click-patient-accordion-card.is-open {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
}

/* Card Header (Trigger) */
.click-patient-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    cursor: pointer;
    user-select: none;
    gap: 16px;
    background: #ffffff;
    transition: background 0.15s ease;
}

.click-patient-card-header:hover {
    background: #fbfcfe;
}

.click-patient-accordion-card.is-open .click-patient-card-header {
    background: #f8fafc;
    border-bottom: 1px solid #edf2f7;
}

/* Left: Avatar + Title */
.click-patient-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1.5;
    min-width: 240px;
}

.click-patient-avatar-wrap {
    position: relative;
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.click-patient-avatar-thumb {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #f1f5f9;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* When progress circle is present, scale thumb to fit neatly inside circle ring */
.click-patient-avatar-wrap.has-progress-circle .click-patient-avatar-thumb {
    width: 40px;
    height: 40px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

/* Wear Calendar Progress Circle in Patient Card */
.click-patient-avatar-wrap .awc-progress-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 58px;
    height: 58px;
    z-index: 2;
    pointer-events: stroke;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.click-patient-avatar-wrap .awc-progress-circle {
    width: 58px;
    height: 58px;
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
}

.click-patient-avatar-wrap .awc-progress-circle #progress_circle {
    stroke: var(--ast-global-color-0, #0085FF);
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.click-patient-card-header:hover .click-patient-avatar-wrap .click-patient-avatar-thumb {
    box-shadow: 0 3px 10px rgba(0, 133, 255, 0.16);
    transform: scale(1.02);
}

.click-patient-thumb-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
}

.click-patient-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #475569;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.click-patient-name-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.click-patient-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 !important;
    line-height: 1.25;
}

.click-patient-subinfo {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.click-patient-case-pill {
    font-size: 12.5px;
    color: #64748b;
}

.click-patient-case-pill strong {
    color: var(--ast-global-color-0);
}

.click-patient-sc-pill {
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* Center: Active case status */
.click-patient-header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 140px;
}

.click-case-date-text {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

/* Right: Cases count + Chevron */
.click-patient-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: flex-end;
    flex: 1;
    min-width: 140px;
}

.click-cases-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 5px 12px;
    border-radius: 8px;
}

.click-accordion-toggle-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
}

.click-patient-card-header:hover .click-accordion-toggle-btn {
    background: #e2e8f0;
    color: #0f172a;
}

.click-chevron-arrow {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.click-patient-accordion-card.is-open .click-chevron-arrow {
    transform: rotate(180deg);
}

.click-patient-accordion-card.is-open .click-accordion-toggle-btn {
    background: var(--ast-global-color-0);
    border-color: var(--ast-global-color-0);
    color: #ffffff;
}

/* 5. Cases Table inside Accordion Body */
.click-patient-card-body {
    padding: 16px 22px 20px;
    background: #ffffff;
}

.click-patient-cases-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.click-cases-table {
    width: 100%;
    border-collapse: collapse !important;
    margin: 0 !important;
    font-size: 13.5px;
    border: none !important;
}

.click-cases-table,
.click-cases-table th,
.click-cases-table td,
.click-case-row,
.click-case-row td {
    border-left: none !important;
    border-right: none !important;
}

.click-cases-table thead th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 16px;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    text-align: left;
}

.click-cases-table thead th.text-right {
    text-align: right;
}

.click-cases-table tbody tr,
.click-case-row {
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid #edf2f7 !important;
    transition: background 0.15s ease;
}

.click-cases-table tbody tr:last-child,
.click-case-row:last-child {
    border-bottom: none !important;
}

.click-cases-table tbody tr:hover,
.click-case-row:hover {
    background: #fbfcfe;
}

.click-cases-table tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    color: #334155;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
}

.click-cases-table tbody td.text-right {
    text-align: right;
}

.click-case-number-link {
    font-weight: 700;
    color: var(--ast-global-color-0) !important;
    text-decoration: none !important;
    font-size: 14px;
}

.click-case-number-link:hover {
    text-decoration: underline !important;
}

.click-case-sc-code {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    background: #f1f5f9;
    color: #475569;
    padding: 1px 5px;
    border-radius: 4px;
}

.click-case-rev-tag {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
    padding: 2px 7px;
    border-radius: 4px;
    vertical-align: middle;
}

.click-case-type-tag {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: #1e293b;
}

/* 6. Empty State */
.click-patients-empty-state {
    text-align: center;
    padding: 50px 20px;
    background: #ffffff;
    border: 1.5px dashed #cbd5e1;
    border-radius: 16px;
    margin: 10px 0;
}

.click-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #94a3b8;
    margin-bottom: 16px;
}

.click-empty-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 6px !important;
}

.click-empty-desc {
    font-size: 14px;
    color: #64748b;
    margin: 0 auto;
    max-width: 420px;
}

/* 7. Loading Overlay */
.click-patients-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 14px;
}

.click-spinner {
    width: 36px;
    height: 36px;
    border: 3.5px solid #e2e8f0;
    border-top-color: var(--ast-global-color-0);
    border-radius: 50%;
    animation: click-spin 0.7s linear infinite;
}

@keyframes click-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 8. Mobile Responsiveness */
@media (max-width: 900px) {
    .click-patient-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .click-patient-header-left,
    .click-patient-header-center,
    .click-patient-header-right {
        width: 100%;
        justify-content: space-between;
        align-items: center;
        flex: auto;
    }

    .click-patient-header-center {
        flex-direction: row;
        padding-top: 4px;
        border-top: 1px dashed #edf2f7;
    }

    .click-patients-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .click-sort-box-wrap {
        justify-content: space-between;
    }

    .click-patients-sort-select {
        width: 100% !important;
    }
}

/* Pagination: load more */
.click-patients-more-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.click-patients-more-counter {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.click-patients-more-btn {
    padding: 10px 22px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.click-patients-more-btn:hover:not(:disabled) {
    background: var(--ast-global-color-0);
    border-color: var(--ast-global-color-0);
    color: #ffffff;
}

.click-patients-more-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* 9. Mobile: cases as stacked cards instead of a wide table */
@media (max-width: 640px) {
    .click-patient-card-body {
        padding: 12px 14px 16px;
    }

    .click-patient-cases-table-wrap {
        overflow: visible;
        border: none;
        border-radius: 0;
    }

    .click-cases-table thead {
        display: none;
    }

    .click-cases-table,
    .click-cases-table tbody {
        display: block;
        width: 100%;
    }

    .click-cases-table tbody tr,
    .click-cases-table tbody tr:last-child,
    .click-case-row,
    .click-case-row:last-child {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "number status"
            "type   date"
            "action action";
        gap: 8px 12px;
        align-items: center;
        padding: 14px;
        margin-bottom: 10px;
        background: #ffffff;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px;
    }

    .click-cases-table tbody tr:last-child,
    .click-case-row:last-child {
        margin-bottom: 0;
    }

    .click-cases-table tbody td,
    .click-cases-table tbody td.text-right {
        display: block;
        padding: 0;
        text-align: left;
        min-width: 0;
    }

    .click-cases-table tbody td.click-case-number-cell {
        grid-area: number;
        font-size: 15px;
    }

    .click-cases-table tbody td.click-case-status-cell {
        grid-area: status;
        text-align: right;
    }

    .click-cases-table tbody td.click-case-type-cell {
        grid-area: type;
    }

    .click-cases-table tbody td.click-case-date-cell {
        grid-area: date;
        text-align: right;
        color: #64748b;
        font-size: 13px;
        white-space: nowrap;
    }

    .click-cases-table tbody td.click-case-action-cell {
        grid-area: action;
        margin-top: 4px;
    }

    .click-cases-table tbody td.click-case-action-cell .click-btn-open {
        display: flex;
        width: 100%;
        justify-content: center;
        box-sizing: border-box;
    }
}
