/**
 * css/components/navbar.css
 * Navigation Bar Styles
 */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: var(--z-fixed);
    box-shadow: var(--shadow-sm);
}

.navbar-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--spacing-lg);
    max-width: 100%;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.status-bar-spacer {
  height: env(safe-area-inset-top, 0px);
  background-color: inherit;
  display: none;
}

/* Show only in Capacitor */
.capacitor-app .status-bar-spacer {
  display: block;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.brand-icon {
    font-size: var(--font-size-2xl);
}

.brand-text {
    font-size: var(--font-size-lg);
}

.navbar-search {
    flex: 1;
    max-width: 500px;
    margin: 0 var(--spacing-xl);
    position: relative;
}

.search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-sm) 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-lighter);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.farm-selector {
    position: relative;
}

.farm-select-dropdown {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 200px;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.farm-select-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-lighter);
}

.farm-select-btn {
    display: none;
}

.navbar-item {
    position: relative;
}

.icon-button {
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    position: relative;
    transition: background-color var(--transition-fast);
}

.icon-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger-color);
    color: white;
    border-radius: var(--radius-full);
    padding: 2px 6px;
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
}

.user-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
    color: var(--text-primary);
}

.user-button:hover {
    background-color: var(--bg-secondary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

/* Dropdowns */
.notifications-dropdown,
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 320px;
    max-height: 400px;
    overflow: hidden;
    z-index: var(--z-dropdown);
    display: none;
}

.notifications-dropdown {
    min-width: 380px;
}

.dropdown-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-header h3 {
    font-size: var(--font-size-base);
    margin: 0;
    color: var(--text-primary);
}

.dropdown-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.notifications-list {
    max-height: 300px;
    overflow-y: auto;
}

.no-notifications {
    padding: var(--spacing-2xl);
    text-align: center;
    color: var(--text-tertiary);
}

.no-notifications i {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.no-notifications p {
    margin: 0;
    font-size: var(--font-size-sm);
}

.notification-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color-light);
    transition: background-color var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.notification-item:hover {
    background-color: var(--bg-secondary);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item.unread {
    background-color: var(--primary-lighter);
}

.notification-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-icon i {
    font-size: var(--font-size-lg);
    color: white;
}

.notification-vaccine_due {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.notification-low_production {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.notification-market_update {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.notification-breeding_reminder {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.notification-health_alert {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.notification-payment_due {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
}

.notification-default {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin-bottom: 4px;
}

.notification-message {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
}

.notification-time {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.mark-read-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-md);
    flex-shrink: 0;
    transition: background-color var(--transition-fast);
}

.mark-read-btn:hover {
    background-color: var(--bg-secondary);
}

.user-info {
    padding: var(--spacing-lg);
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.user-avatar-large {
    width: 60px;
    height: 60px;
}

.user-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-details {
    flex: 1;
}

.user-full-name {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 4px;
    color: var(--text-primary);
}

.user-email {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: var(--font-size-sm);
}

.dropdown-item:hover {
    background-color: var(--bg-secondary);
}

.dropdown-item i {
    width: 20px;
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-secondary {
    background: var(--gray-400);
    color: white;
}

.badge-primary {
    background: var(--primary-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    cursor: pointer;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Mobile */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: block;
    }
    
    .brand-text {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar-container {
        padding: 0 var(--spacing-md);
    }
    
    .navbar-search {
        display: none;
    }
    
    .navbar-actions {
        gap: var(--spacing-sm);
    }
    
    .farm-selector {
        position: static;
    }
    
    .farm-select-dropdown {
        display: none;
        position: fixed;
        top: var(--navbar-height);
        left: 0;
        right: 0;
        min-width: 100%;
        max-width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        border: none;
        border-bottom: 1px solid var(--border-color);
        border-radius: 0;
        box-shadow: var(--shadow-lg);
        z-index: var(--z-dropdown);
        padding: 0;
        background-image: none;
    }
    
    .farm-select-dropdown option {
        padding: var(--spacing-md);
        cursor: pointer;
        background: var(--bg-primary);
        color: var(--text-primary);
    }
    
    .farm-select-btn {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
        background: none;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: var(--font-size-sm);
        color: var(--text-primary);
        cursor: pointer;
        transition: all var(--transition-fast);
        white-space: nowrap;
        max-width: 150px;
    }
    
    .farm-select-btn:hover {
        background-color: var(--bg-secondary);
        border-color: var(--primary-color);
    }
    
    .farm-select-btn i {
        font-size: var(--font-size-sm);
        flex-shrink: 0;
    }
    
    .farm-btn-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .user-name {
        display: none;
    }
    
    .notifications-dropdown {
        min-width: 90vw;
        right: auto;
        left: 100%;
        transform: translateX(-50%);
    }
    
    .user-dropdown {
        right: 0;
        min-width: 280px;
    }
}

@media (max-width: 480px) {
    .navbar-actions {
        gap: 4px;
    }
    
    .icon-button {
        padding: 6px;
    }
    
    .farm-select-btn {
        padding: 6px 8px;
        max-width: 120px;
        font-size: 12px;
    }
    
    .notifications-dropdown {
        min-width: 100vw;
        left: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .user-dropdown {
        min-width: 90vw;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
}