/* TCC CRM Targeting Dashboard Styles
 * Three-column split layout with collapsible filters sidebar
 * Created: January 30, 2026
 */

/* ===========================================
 * TARGETING LAYOUT
 * Three-column: Filters | Donor List | Action Panel
 * =========================================== */

.targeting-layout {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1.5rem;
    min-height: calc(100vh - 200px);
}

/* ===========================================
 * FILTERS SIDEBAR
 * =========================================== */

.targeting-filters {
    width: 280px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
                0 4px 16px rgba(39, 53, 102, 0.06);
    border: 1px solid var(--color-border-light);
    height: fit-content;
    position: sticky;
    top: 1rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.targeting-filters:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1),
                0 8px 24px rgba(39, 53, 102, 0.08);
}

.targeting-filters--collapsed {
    width: 56px;
}

.targeting-filters__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border-light);
    background: linear-gradient(135deg, var(--tcc-primary-light) 0%, rgba(39, 53, 102, 0.08) 100%);
}

.targeting-filters__title {
    font-weight: var(--font-semibold);
    color: var(--tcc-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.targeting-filters--collapsed .targeting-filters__title span {
    display: none;
}

.targeting-filters__toggle {
    background: none;
    border: none;
    color: var(--tcc-primary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.targeting-filters__toggle:hover {
    background: var(--tcc-primary-medium);
}

.targeting-filters__body {
    padding: 1rem;
}

.targeting-filters--collapsed .targeting-filters__body {
    display: none;
}

.targeting-filters__group {
    margin-bottom: 1.25rem;
}

.targeting-filters__label {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

.targeting-filters__actions {
    padding: 1rem;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.targeting-filters--collapsed .targeting-filters__actions {
    display: none;
}

/* Preset dropdown styling */
.targeting-filters .form-select-sm {
    font-size: var(--text-sm);
}

/* ===========================================
 * DONOR LIST (CENTER)
 * =========================================== */

.targeting-donors {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
                0 4px 16px rgba(39, 53, 102, 0.06);
    border: 1px solid var(--color-border-light);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: box-shadow 0.3s ease;
}

.targeting-donors:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1),
                0 8px 24px rgba(39, 53, 102, 0.08);
}

.targeting-donors__header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.8) 0%, white 100%);
}

.targeting-donors__tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
}

.targeting-donors__sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.targeting-donors__sort-label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ===========================================
 * COLUMN HEADERS WITH SORT
 * =========================================== */

.targeting-donors__columns {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: var(--color-bg-secondary);
    border-bottom: 2px solid var(--color-border-light);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.targeting-donors__col {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color var(--transition-fast);
}

.targeting-donors__col:hover {
    color: var(--tcc-primary);
}

.targeting-donors__col--name {
    flex: 1;
    min-width: 0;
}

.targeting-donors__col--lastamt {
    width: 80px;
    justify-content: flex-end;
    text-align: right;
}

.targeting-donors__col--lifetime {
    width: 90px;
    justify-content: flex-end;
    text-align: right;
}

.targeting-donors__col--date {
    width: 100px;
    justify-content: center;
    text-align: center;
}

.targeting-donors__col--contact {
    width: 70px;
    justify-content: center;
    text-align: center;
    cursor: default;
}

.targeting-donors__col--lastcall {
    width: 100px;
    justify-content: center;
    text-align: center;
}

.sort-arrows {
    display: flex;
    flex-direction: column;
    font-size: 0.6rem;
    line-height: 0.5;
    opacity: 0.3;
}

.sort-arrows i {
    transition: opacity var(--transition-fast);
}

.targeting-donors__col.sort-asc .sort-arrows i:first-child,
.targeting-donors__col.sort-desc .sort-arrows i:last-child {
    opacity: 1;
    color: var(--tcc-primary);
}

.targeting-donors__col.sort-asc .sort-arrows,
.targeting-donors__col.sort-desc .sort-arrows {
    opacity: 1;
}

.targeting-donors__tab {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.targeting-donors__tab:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.targeting-donors__tab--active {
    background: var(--tcc-primary-light);
    color: var(--tcc-primary);
    font-weight: var(--font-semibold);
}

.targeting-donors__count {
    font-size: var(--text-xs);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-full);
    margin-left: 0.25rem;
}

.targeting-donors__tab--active .targeting-donors__count {
    background: var(--tcc-primary);
    color: white;
}

.targeting-donors__body {
    flex: 1;
    overflow-y: auto;
}

.targeting-donors__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ===========================================
 * DONOR ROW (COMPACT)
 * =========================================== */

.donor-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

/* Zebra striping - alternating row backgrounds */
.donor-row:nth-child(even) {
    background: rgba(248, 250, 252, 0.5);
}

.donor-row:nth-child(odd) {
    background: white;
}

/* Enhanced hover effect with lift and shadow */
.donor-row:hover {
    background: var(--tcc-primary-light);
    box-shadow: 0 4px 12px rgba(39, 53, 102, 0.15),
                inset 0 0 0 1px var(--tcc-primary-medium);
    transform: translateY(-1px);
    z-index: 1;
}

/* Hover action buttons container */
.donor-row__hover-actions {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.donor-row:hover .donor-row__hover-actions {
    opacity: 1;
    pointer-events: auto;
}

.donor-row:hover .donor-row__contact {
    opacity: 0;
}

/* Hover action button styles */
.donor-row__hover-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.donor-row__hover-btn--call {
    background: var(--tcc-primary);
    color: white;
}

.donor-row__hover-btn--call:hover {
    background: var(--tcc-primary-hover);
    transform: scale(1.1);
}

.donor-row__hover-btn--email {
    background: var(--tcc-accent);
    color: white;
}

.donor-row__hover-btn--email:hover {
    background: var(--tcc-accent-hover);
    transform: scale(1.1);
}

.donor-row__hover-btn--profile {
    background: var(--color-bg-secondary);
    color: var(--tcc-primary);
    border: 1px solid var(--color-border-light);
}

.donor-row__hover-btn--profile:hover {
    background: var(--tcc-primary-light);
    transform: scale(1.1);
}

.donor-row--selected {
    background: var(--tcc-primary-light) !important;
    border-left: 3px solid var(--tcc-primary);
    padding-left: calc(1.5rem - 3px);
}

.donor-row__info {
    flex: 1;
    min-width: 0;
}

.donor-row__name {
    font-weight: var(--font-semibold);
    color: var(--color-text);
    margin-bottom: 0.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.donor-row__star {
    color: var(--tcc-accent);
}

.donor-row__details {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    display: flex;
    gap: 0.75rem;
}

.donor-row__lastamt {
    font-weight: var(--font-semibold);
    color: var(--color-text);
    width: 80px;
    text-align: right;
    white-space: nowrap;
}

.donor-row__lifetime {
    font-weight: var(--font-semibold);
    color: var(--tcc-accent);
    width: 90px;
    text-align: right;
    white-space: nowrap;
}

.donor-row__date {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    width: 100px;
    text-align: center;
    white-space: nowrap;
}

.donor-row__lastcall {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    width: 100px;
    text-align: center;
    white-space: nowrap;
}

.donor-row__contact {
    display: flex;
    gap: 0.375rem;
    font-size: var(--text-sm);
    width: 70px;
    justify-content: center;
}

.donor-row__contact i {
    opacity: 0.5;
}

.donor-row__contact i.has-contact {
    opacity: 1;
    color: var(--tcc-primary);
}

/* ===========================================
 * ACTION PANEL (RIGHT)
 * =========================================== */

.targeting-actions {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 1rem;
    height: fit-content;
}

.action-widget {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
                0 4px 16px rgba(39, 53, 102, 0.06);
    border: 1px solid var(--color-border-light);
    overflow: hidden;
    transition: all 0.3s ease;
}

.action-widget:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1),
                0 8px 24px rgba(39, 53, 102, 0.08);
    transform: translateY(-2px);
}

.action-widget__header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--color-bg-secondary) 0%, rgba(248, 250, 252, 0.5) 100%);
    border-bottom: 1px solid var(--color-border-light);
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-widget__header--primary {
    background: linear-gradient(135deg, var(--tcc-primary-light) 0%, rgba(39, 53, 102, 0.12) 100%);
    color: var(--tcc-primary);
}

.action-widget__header--accent {
    background: linear-gradient(135deg, var(--tcc-accent-light) 0%, rgba(227, 24, 55, 0.12) 100%);
    color: var(--tcc-accent);
}

.action-widget__body {
    padding: 1rem;
}

/* Quick Call Widget */
.quick-call__name {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.quick-call__phone {
    font-size: var(--text-base);
    color: var(--tcc-primary);
    font-weight: var(--font-medium);
    margin-bottom: 0.5rem;
}

.quick-call__info {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.quick-call__actions {
    display: flex;
    gap: 0.5rem;
}

/* Quick Email Widget */
.quick-email__address {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    word-break: break-all;
}

/* Donor Summary Widget */
.donor-summary__stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border-light);
}

.donor-summary__stat:last-child {
    border-bottom: none;
}

.donor-summary__label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.donor-summary__value {
    font-weight: var(--font-semibold);
    color: var(--color-text);
}

.donor-summary__value--amount {
    color: var(--tcc-accent);
}

.donor-summary__value--lifetime {
    color: var(--tcc-accent);
}

/* Empty State */
.targeting-empty {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.targeting-empty__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.targeting-empty__text {
    font-size: var(--text-lg);
}

/* ===========================================
 * TARGETING STATS ROW (Above main layout)
 * =========================================== */

.targeting-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
    .targeting-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .targeting-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===========================================
 * PAGINATION
 * =========================================== */

.targeting-donors__footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-bg-secondary);
}

.targeting-pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.targeting-pagination__info {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* ===========================================
 * RESPONSIVE ADJUSTMENTS
 * =========================================== */

@media (max-width: 1400px) {
    .targeting-actions {
        width: 280px;
    }
}

@media (max-width: 1200px) {
    .targeting-layout {
        grid-template-columns: auto 1fr;
    }

    .targeting-actions {
        display: none;
    }
}

@media (max-width: 992px) {
    .targeting-layout {
        grid-template-columns: 1fr;
    }

    .targeting-filters {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1040;
        border-radius: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .targeting-filters--open {
        transform: translateX(0);
    }

    .targeting-filters-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1039;
        display: none;
    }

    .targeting-filters-overlay--visible {
        display: block;
    }
}

/* ===========================================
 * MOBILE FILTER TOGGLE
 * =========================================== */

.targeting-mobile-controls {
    display: none;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 992px) {
    .targeting-mobile-controls {
        display: flex;
    }
}

/* ===========================================
 * MOBILE DONOR ROW LAYOUT
 * Convert horizontal row to stacked card on small screens
 * =========================================== */

@media (max-width: 768px) {
    /* Hide column headers — not useful on mobile */
    .targeting-donors__columns {
        display: none;
    }

    /* Reflow donor row into a card layout */
    .donor-row {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.25rem;
    }

    /* Name takes full width as the first line */
    .donor-row__info {
        flex: 1 1 100%;
        min-width: 0;
        margin-bottom: 0.25rem;
    }

    .donor-row__name {
        font-size: 0.95rem;
    }

    /* Second line: amounts + date in a row */
    .donor-row__lastamt {
        width: auto;
        text-align: left;
        font-size: 0.85rem;
    }

    .donor-row__lastamt::before {
        content: "Last: ";
        font-weight: 400;
        color: #6c757d;
        font-size: 0.75rem;
    }

    .donor-row__lifetime {
        width: auto;
        text-align: left;
        font-size: 0.85rem;
        margin-left: 0.75rem;
    }

    .donor-row__lifetime::before {
        content: "Total: ";
        font-weight: 400;
        color: #6c757d;
        font-size: 0.75rem;
    }

    .donor-row__date {
        width: auto;
        text-align: left;
        font-size: 0.8rem;
        margin-left: 0.75rem;
    }

    /* Hide last call and contact icons on mobile — accessible via profile */
    .donor-row__lastcall {
        display: none;
    }

    .donor-row__contact {
        display: none;
    }

    /* Hide hover actions on mobile — no hover on touch */
    .donor-row__hover-actions {
        display: none;
    }

    /* Remove hover lift effect on mobile (causes jank on touch) */
    .donor-row:hover {
        transform: none;
        box-shadow: none;
    }

    /* Active (tap) state instead */
    .donor-row:active {
        background: var(--tcc-primary-light, #e8edf5);
    }

    /* Tabs: horizontal scroll with smaller text */
    .targeting-donors__tabs {
        gap: 0.125rem;
        -webkit-overflow-scrolling: touch;
    }

    .targeting-donors__tab {
        padding: 0.375rem 0.625rem;
        font-size: 0.8rem;
    }

    .targeting-donors__count {
        font-size: 0.65rem;
        padding: 0.1rem 0.3rem;
    }

    /* Header padding reduce */
    .targeting-donors__header {
        padding: 0.75rem 1rem;
    }
}

/* Extra small phones */
@media (max-width: 480px) {
    .donor-row__date {
        display: none;
    }

    .donor-row__lifetime {
        margin-left: auto;
    }
}
