/* ==========================================================================
   Topbar Component Styles
   - Notifications dropdown
   - Profile dropdown
   - Residence selector
   - Search dropdown
   - Mobile responsive
   ========================================================================== */

/* Notification Wrapper */
.notification-wrapper {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    background: var(--accent-red, #ef4444);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Notification Dropdown */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 340px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.notification-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.notif-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}

.notif-count {
    font-size: 0.75rem;
    color: var(--accent-red, #ef4444);
    font-weight: 600;
    background: #fef2f2;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
}

.notif-list {
    max-height: 320px;
    overflow-y: auto;
}

.notif-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: #94a3b8;
}

.notif-empty ion-icon {
    font-size: 3rem;
    color: #10b981;
    margin-bottom: 0.75rem;
}

.notif-empty p {
    margin: 0;
    font-size: 0.875rem;
}

.notif-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    border-bottom: 1px solid #f8fafc;
}

.notif-item:hover {
    background: #f8fafc;
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fef2f2;
    color: var(--accent-red, #ef4444);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-icon ion-icon {
    font-size: 1.1rem;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-client {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-detail {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.notif-time {
    font-size: 0.7rem;
    color: var(--accent-red, #ef4444);
    font-weight: 600;
    margin-top: 4px;
}

.notif-footer {
    padding: 0.875rem;
    border-top: 1px solid #f1f5f9;
    text-align: center;
}

.notif-footer a {
    font-size: 0.8rem;
    color: var(--primary, #6366f1);
    text-decoration: none;
    font-weight: 600;
}

.notif-footer a:hover {
    text-decoration: underline;
}

/* Profile Button & Dropdown */
.profile-btn {
    overflow: hidden;
    padding: 0 !important;
}

.avatar-letter {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary, #6366f1), #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 240px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.profile-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid #e2e8f0;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #6366f1), #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.profile-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}

.profile-role {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: capitalize;
}

.profile-menu {
    padding: 0.5rem;
}

.profile-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    text-decoration: none;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.profile-link:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.profile-link.danger {
    color: var(--accent-red, #ef4444);
}

.profile-link.danger:hover {
    background: #fef2f2;
}

.profile-link ion-icon {
    font-size: 1.1rem;
}

/* Residence Selector */
.residence-selector-wrapper {
    position: relative;
}

.residence-selector-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
}

.residence-selector-btn:hover {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-color: #cbd5e1;
}

.residence-selector-btn ion-icon {
    font-size: 1.1rem;
    color: var(--primary, #6366f1);
}

.residence-selector-btn .chevron {
    font-size: 0.8rem;
    color: #94a3b8;
    transition: transform 0.2s;
}

.residence-selector-btn:hover .chevron {
    transform: rotate(180deg);
}

.residence-name {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.residence-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.residence-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.residence-dropdown-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}

.residence-list {
    max-height: 280px;
    overflow-y: auto;
}

.residence-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    border-bottom: 1px solid #f8fafc;
}

.residence-option:hover {
    background: #f8fafc;
}

.residence-option.active {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
}

.residence-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary, #6366f1), #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.residence-icon ion-icon {
    font-size: 1.2rem;
}

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

.residence-option-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.residence-option-stats {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.residence-option .active-check {
    color: var(--primary, #6366f1);
    font-size: 1.2rem;
}

.residence-dropdown-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid #f1f5f9;
}

.residence-dropdown-footer a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--primary, #6366f1);
    text-decoration: none;
    font-weight: 600;
}

.residence-dropdown-footer a:hover {
    text-decoration: underline;
}

.residence-dropdown-footer ion-icon {
    font-size: 1rem;
}

/* Mobile Page Title - hidden on desktop */
.mobile-page-title {
    display: none;
}

@media (max-width: 640px) {
    /* Mobile page title */
    .mobile-page-title {
        display: block;
        order: 0;
    }

    .mobile-page-title h1 {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--text-main, #1e293b);
        margin: 0;
    }

    /* Bottom sheet styles handled in mobile.css */
    .notification-dropdown,
    .profile-dropdown,
    .residence-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 80vh;
        z-index: 1001;
    }

    .residence-selector-btn .residence-name {
        display: none;
    }

    .residence-selector-btn {
        padding: 0.5rem 0.75rem;
    }
}

/* Search Dropdown Styles */
.search-pill {
    position: relative;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 350px;
    max-width: 90vw;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1002;
    overflow: hidden;
}

.search-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-dropdown-content {
    max-height: 400px;
    overflow-y: auto;
}

.search-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover {
    background: #f8fafc;
}

.search-dropdown-item ion-icon {
    font-size: 1.25rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

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

.search-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown-more {
    display: block;
    text-align: center;
    padding: 0.75rem;
    background: #f8fafc;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.2s;
}

.search-dropdown-more:hover {
    background: #f1f5f9;
}

.search-no-results {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .search-dropdown {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        max-height: 60vh;
    }

    .search-dropdown-content {
        max-height: calc(60vh - 60px);
    }
}
