﻿/* admin.css - Admin page */

/* ==================== ADMIN PAGE ==================== */

/* Under Construction Banner */
.admin-wip-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-left: 4px solid #f59e0b;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.admin-wip-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fef3c7;
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.admin-wip-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.admin-wip-content strong {
    font-size: 0.9rem;
    color: #92400e;
}

.admin-wip-content span {
    font-size: 0.8rem;
    color: #a16207;
    line-height: 1.4;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1200px) {
    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.admin-stat-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.admin-stat-icon.users { background: #dbeafe; color: #3b82f6; }
.admin-stat-icon.accounts { background: #F4F0E9; color: #1E6332; }
.admin-stat-icon.active { background: #fef3c7; color: #f59e0b; }
.admin-stat-icon.pending { background: #fee2e2; color: #ef4444; }

.admin-stat-info h3 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1f2937;
}

.admin-stat-info p {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.admin-section {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.admin-section-header {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    padding: 1.25rem 1.5rem;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-section-header h5 {
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-section-body {
    padding: 1.5rem;
}

.user-list-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s ease;
}

.user-list-item:hover {
    background: #f9fafb;
}

.user-list-item:last-child {
    border-bottom: none;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.user-avatar.admin-role {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.user-avatar.standard-role {
    background: linear-gradient(135deg, #F4F0E9 0%, #E8DFD0 100%);
    color: #2F8542;
}

.user-avatar.no-access-role {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #9ca3af;
}

.user-info {
    flex: 1;
}

.user-info h6 {
    margin: 0 0 0.25rem 0;
    font-weight: 600;
}

.user-info p {
    margin: 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.user-role-tag {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 1rem;
}

.user-role-tag.admin {
    background: #fef2f2;
    color: #dc2626;
}

.user-role-tag.standard {
    background: #F4F0E9;
    color: #2F8542;
}

.user-role-tag.no-access {
    background: #f3f4f6;
    color: #6b7280;
}

.user-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 1rem;
}

.user-status.active { background: #18A74B; }
.user-status.inactive { background: #d1d5db; }

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.user-actions .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.account-access-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.account-access-tag {
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
}

/* Analytics Drilldown Modal */
.analytics-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.analytics-modal.show {
    display: flex;
}

.analytics-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.analytics-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1E6332 0%, #214A3E 100%);
    color: white;
}

.analytics-modal-header h5 {
    margin: 0;
    font-weight: 600;
}

.analytics-modal-header .close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.analytics-modal-header .close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.analytics-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.analytics-modal-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analytics-modal-summary .summary-stat {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.analytics-modal-summary .summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1E6332;
}

.analytics-modal-summary .summary-label {
    font-size: 0.85rem;
    color: #6b7280;
}

.analytics-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
}

/* Add User Modal */
.add-user-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.add-user-modal.show {
    opacity: 1;
    visibility: visible;
}

.add-user-modal-content {
    background: #fff;
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.add-user-modal.show .add-user-modal-content {
    transform: scale(1);
}

.add-user-modal-header {
    background: linear-gradient(135deg, #1E6332 0%, #2F8542 100%);
    padding: 1.5rem;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.add-user-modal-header h5 {
    margin: 0;
    font-weight: 600;
}

.add-user-modal-header .close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-user-modal-body {
    padding: 1.5rem;
}

.add-user-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ==================== ADMIN PANEL LIVE DATA STYLES ==================== */

/* Loading state */
.admin-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 1.5rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    min-height: 320px;
    text-align: center;
}

/* Filter chips (inside dark section header) */
.admin-filter-chips {
    display: flex;
    gap: 0.3rem;
}

.admin-filter-chip {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.75);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.admin-filter-chip:hover,
.admin-filter-chip.active {
    background: rgba(255, 255, 255, 0.92);
    border-color: transparent;
    color: #1f2937;
}

/* Search input inside dark section header */
.admin-search-input {
    width: 170px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 0.5rem;
    font-size: 0.82rem;
}

.admin-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.admin-search-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
    box-shadow: none;
    outline: none;
}

/* ==================== VIEW TOGGLE ==================== */

/* Toolbar row: allow two flex groups to wrap on small screens */
.admin-toolbar {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.admin-view-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    padding: 3px;
    gap: 3px;
}

.admin-view-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    padding: 0.3rem 0.9rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.4;
}

.admin-view-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.admin-view-btn.active {
    background: #fff;
    color: #1f2937;
    font-weight: 600;
}

/* ==================== BY FUNERAL HOME VIEW ==================== */

.admin-fh-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 1rem;
}

.admin-fh-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.admin-fh-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    border-color: #d1fae5;
}

.admin-fh-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    background: #f8fafc;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.admin-fh-header:hover {
    background: #F4F0E9;
}

.admin-fh-header-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}

.admin-fh-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.625rem;
    background: linear-gradient(135deg, #F4F0E9 0%, #E8DFD0 100%);
    color: #2F8542;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.admin-fh-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: #1f2937;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
}

.admin-fh-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.admin-fh-chip {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 2rem;
    white-space: nowrap;
    line-height: 1.5;
}

.admin-fh-chip.total { background: #e0f2fe; color: #0369a1; }
.admin-fh-chip.hub   { background: #F4F0E9; color: #1E6332; }
.admin-fh-chip.noacc { background: #f3f4f6; color: #6b7280; }

.admin-fh-chevron {
    color: #9ca3af;
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 1rem;
}

.admin-fh-chevron.expanded {
    transform: rotate(180deg);
}

.admin-fh-contacts {
    border-top: 1px solid #F4F0E9;
    background: #fff;
}

/* Shown inside an FH accordion when the current filter yields no contacts */
.admin-fh-empty-row {
    padding: 0.75rem 1.5rem;
    font-size: 0.8rem;
    color: #9ca3af;
    font-style: italic;
}

/* ==================== SHARED CONTACT ROW ==================== */

.admin-contact-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.admin-contact-row:last-child {
    border-bottom: none;
}

.admin-contact-row:hover {
    background: #f9fafb;
}

/* For rows inside an FH accordion, tighten left indent */
.admin-fh-contacts .admin-contact-row {
    padding-left: 1.5rem;
}

.admin-contact-info {
    flex: 1;
    min-width: 0;
}

.admin-contact-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-contact-email {
    font-size: 0.78rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.1rem;
}

.admin-contact-sep {
    color: #d1d5db;
    margin: 0 0.2rem;
}

.admin-contact-pills {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

.admin-contact-fh-pill {
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.15rem 0.55rem;
    border-radius: 2rem;
    white-space: nowrap;
}

/* By Contact view — flat list container */
.admin-contact-list {
    /* rows carry their own padding */
}

/* ==================== EMPTY STATE ==================== */

.admin-empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 3rem 1.5rem;
}

.admin-empty-state i {
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.3;
}

.admin-empty-state p {
    margin: 0;
    font-size: 0.9rem;
}

/* ==================== CARD GRID (expanded sections) ==================== */

/* Grid wrapper used inside both FH and Contact expanded sections */
.admin-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    background: #fafafa;
    border-top: 1px solid #F4F0E9;
}

/* Contact card — shown in FH grid, clickable drill-through to Contact view */
.admin-grid-contact-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.625rem;
    padding: 0.875rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.3rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.2s, transform 0.15s, box-shadow 0.15s;
}

.admin-grid-contact-card:hover {
    background: #F4F0E9;
    border-color: #86efac;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 99, 50, 0.12);
}

.admin-grid-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
    margin: 0 0 0.1rem;
}

.admin-grid-contact-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: #1f2937;
    line-height: 1.3;
    word-break: break-word;
}

.admin-grid-contact-email {
    font-size: 0.7rem;
    color: #9ca3af;
    word-break: break-all;
    line-height: 1.2;
}

.admin-grid-role {
    margin: 0.1rem 0 0;
}

/* Drill-through hint — visible on hover */
.admin-grid-drill {
    font-size: 0.68rem;
    color: #1E6332;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.15s;
    margin-top: 0.15rem;
}

.admin-grid-contact-card:hover .admin-grid-drill {
    opacity: 1;
}

/* Location card — shown in Contact grid, clickable drill-through to FH view */
.admin-location-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.625rem;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.2s, transform 0.15s, box-shadow 0.15s;
}

.admin-location-card:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.1);
}

.admin-location-icon {
    width: 38px;
    height: 38px;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.admin-location-info {
    min-width: 0;
}

.admin-location-name {
    font-weight: 600;
    font-size: 0.84rem;
    color: #1f2937;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-location-drill {
    font-size: 0.68rem;
    color: #1d4ed8;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.15s;
    margin-top: 0.15rem;
}

.admin-location-card:hover .admin-location-drill {
    opacity: 1;
}

/* View container — no extra chrome */
.admin-view-container {
    min-height: 60px;
}
