/* Family Profile Styles */

.family-main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header-left {
    flex: 1;
}

.page-title {
    font-size: 2rem;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    margin: 0;
}

.page-header-right {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color, #e5e7eb);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.stat-icon-blue { color: #3b82f6; }
.stat-icon-green { color: #10b981; }
.stat-icon-purple { color: #8b5cf6; }
.stat-icon-yellow { color: #f59e0b; }

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color, #e5e7eb);
    padding-bottom: 0;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 500;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Family Grid */
.family-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.family-card {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.family-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.family-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-secondary, #f9fafb);
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.family-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.family-info {
    flex: 1;
}

.family-info h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.relationship-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    text-transform: capitalize;
}

.family-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
}

.btn-icon-danger:hover {
    background: #ef4444;
    color: white;
}

.family-card-body {
    padding: 1.25rem;
}

.family-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item .value {
    font-weight: 500;
    color: var(--text-primary);
}

.alert-info,
.alert-warning,
.alert-danger {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-left: 3px solid #3b82f6;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border-left: 3px solid #f59e0b;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-left: 3px solid #ef4444;
}

/* Documents Section */
.sps-card {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.document-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.doc-category {
    background: var(--bg-secondary, #f9fafb);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    position: relative;
}

.doc-category:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.doc-category-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.doc-category h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.doc-category p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.doc-count {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-color);
    color: white;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Documents Toolbar */
.documents-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 350px;
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 0.5rem 1rem;
}

.search-box svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--text-primary);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

/* Documents List */
.documents-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    transition: all 0.2s;
}

.document-item:hover {
    background: var(--bg-tertiary, #e5e7eb);
}

.document-item.expiring {
    border-left-color: #f59e0b;
}

.document-item.expired {
    border-left-color: #ef4444;
}

.document-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-info h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.category-tag,
.member-tag,
.doc-number {
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.category-tag {
    background: var(--primary-color);
    color: white;
}

.member-tag {
    background: #8b5cf6;
    color: white;
}

.doc-number {
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-secondary);
}

.expiration {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    color: var(--text-secondary);
}

.expiration.warning {
    color: #f59e0b;
}

.expiration.expired {
    color: #ef4444;
    font-weight: 500;
}

.document-actions {
    display: flex;
    gap: 0.5rem;
}

/* Filter Group */
.filter-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.filter-group select {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: var(--card-bg, #fff);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Contacts List */
.contacts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.contact-card {
    background: var(--card-bg, #fff);
    border-radius: 10px;
    border: 1px solid var(--border-color, #e5e7eb);
    padding: 1.25rem;
    position: relative;
}

.contact-priority {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 0 10px 0 10px;
}

.contact-priority.priority-1 {
    background: #ef4444;
    color: white;
}

.contact-priority.priority-2 {
    background: #f59e0b;
    color: white;
}

.contact-priority.priority-3 {
    background: #6b7280;
    color: white;
}

.contact-info {
    margin-bottom: 0.75rem;
}

.contact-info h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.contact-relationship {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.contact-phone,
.contact-email {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.95rem;
}

.contact-phone:hover,
.contact-email:hover {
    text-decoration: underline;
}

.contact-phone.alt {
    color: var(--text-secondary);
    margin-left: 1.5rem;
}

.contact-address {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.5rem;
    background: var(--bg-secondary, #f9fafb);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.contact-notes {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.contact-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
}

.modal-lg {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 6px;
    font-size: 0.95rem;
    background: var(--card-bg, #fff);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-fieldset {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.form-fieldset legend {
    padding: 0 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary, #f9fafb);
    color: var(--text-primary);
    border: 1px solid var(--border-color, #e5e7eb);
}

.btn-secondary:hover {
    background: var(--bg-tertiary, #e5e7eb);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

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

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    z-index: 2000;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.notification-success {
    background: #10b981;
    color: white;
}

.notification-error {
    background: #ef4444;
    color: white;
}

.notification-info {
    background: #3b82f6;
    color: white;
}

.notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* Dark Theme Adjustments */
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .family-card,
body[data-theme="dark"] .sps-card,
body[data-theme="dark"] .contact-card,
body[data-theme="dark"] .modal-content {
    background: var(--card-bg, #1e2433);
    border-color: var(--border-color, #374151);
}

body[data-theme="dark"] .family-card-header,
body[data-theme="dark"] .doc-category,
body[data-theme="dark"] .document-item,
body[data-theme="dark"] .contact-address {
    background: var(--bg-secondary, #252b3d);
}

body[data-theme="dark"] .document-item:hover {
    background: var(--bg-tertiary, #2d3548);
}

body[data-theme="dark"] .btn-icon {
    background: var(--bg-tertiary, #374151);
}

body[data-theme="dark"] .form-group input,
body[data-theme="dark"] .form-group select,
body[data-theme="dark"] .form-group textarea,
body[data-theme="dark"] .filter-group select,
body[data-theme="dark"] .search-box {
    background: var(--bg-secondary, #252b3d);
    border-color: var(--border-color, #374151);
}

body[data-theme="dark"] .search-box input {
    color: var(--text-primary, #e5e7eb);
}

/* Responsive */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-right {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .family-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .contacts-list {
        grid-template-columns: 1fr;
    }

    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

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

    .search-box {
        max-width: none;
    }

    .filter-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .document-categories {
        grid-template-columns: 1fr;
    }

    .family-details {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   ALLERGY SELECTOR STYLING
   ============================================ */

.allergy-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-tertiary, #f3f4f6);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.allergy-tag {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary, #374151);
}

.allergy-tag:hover {
    border-color: #ef4444;
    background: #fef2f2;
}

.allergy-tag input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #ef4444;
}

.allergy-tag input:checked + span,
.allergy-tag:has(input:checked) {
    color: #dc2626;
    font-weight: 500;
}

.allergy-tag:has(input:checked) {
    background: #fef2f2;
    border-color: #fecaca;
}

.custom-allergy-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.custom-allergy-row input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 4px;
    background: var(--bg-secondary, #ffffff);
    color: var(--text-primary, #1f2937);
}

/* Display allergies in member cards */
.member-allergies-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.allergy-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 12px;
}
