/* Global Header Styles */

.global-header {
    background: var(--card-bg-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.global-header .header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 300px; /* Match user button width */
    justify-content: flex-start;
    gap: 12px;
}

/* Global Back Button */
.header-back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.header-back-button:hover:not(:disabled) {
    background: rgba(0, 91, 150, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.header-back-button:disabled,
.header-back-button[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
}

.header-back-button i {
    font-size: 16px;
}

.header-back-button-text {
    display: inline-block;
}

.header-logo {
    height: 36px;
    width: auto;
    border-radius: 1em;
    corner-shape: squircle;
    transition: all 0.3s ease;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo-link:hover .header-logo {
    corner-shape: superellipse(0.8);
    transform: scale(1.1);
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0; /* Allow content to shrink */
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap;
    justify-content: center;
}

.header-title {
    margin: 0;
    color: var(--text-color);
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 300px; /* Match user button width */
    justify-content: flex-end;
    gap: 10px;
}

/* "My tasks" header link + badge */
.my-tasks-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.my-tasks-link:hover {
    background: rgba(0, 91, 150, 0.10);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.my-tasks-link i {
    color: var(--primary-color);
    font-size: 16px;
}

.my-tasks-badge {
    min-width: 20px;
    height: 20px;
    padding: 0px 1px 0px 0px;
    border-radius: 999px;
    background: #dc3545;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: auto;
}

.user-button:hover {
    background: rgba(0, 91, 150, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.user-button i.fa-user-circle {
    font-size: 20px;
    color: var(--primary-color);
}

.user-button i.fa-chevron-down {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.user-button.active i.fa-chevron-down {
    transform: rotate(180deg);
}

.user-name {
    flex: 1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
    margin-left: 16px;
    display: inline-block;
    transition: opacity 0.2s ease;
}

.user-name.loading {
    opacity: 0.6;
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-strong);
    min-width: 200px;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 4px;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    cursor: pointer;
}

.dropdown-item:hover {
    background: rgba(0, 91, 150, 0.1);
    color: var(--primary-color);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 14px;
}

.dropdown-divider {
    margin: 8px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.logout-button {
    color: #dc3545 !important;
}

.logout-button:hover {
    background: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .global-header .header-container {
        padding: 0 16px;
        gap: 12px;
    }
    
    .header-left,
    .header-right {
        min-width: 80px; /* Smaller width on mobile */
    }

    .my-tasks-text {
        display: none;
    }

    .my-tasks-link {
        padding: 8px 10px;
    }

    .header-back-button {
        padding: 8px 10px;
        gap: 0;
    }

    .header-back-button-text {
        display: none;
    }
    
    .header-center {
        flex: 1;
        min-width: 0;
    }
    
    .header-title {
        font-size: 20px;
    }
    
    .header-content {
        gap: 8px;
    }
    
    .user-button {
        min-width: auto;
        padding: 8px 12px;
    }
    
    .user-name {
        display: none;
    }
    
    .user-dropdown {
        right: -10px;
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .header-logo {
        height: 32px;
    }
    
    .user-button {
        padding: 6px 10px;
    }
    
    .user-button i.fa-user-circle {
        font-size: 18px;
    }
}

/* Animation for dropdown */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-dropdown.show {
    animation: fadeInDown 0.3s ease-out;
}
