/* ========================================
   HEADER AUTHENTICATION STYLES
   ======================================== */

/* Top Bar Full Width Layout */
.top {
    width: 100%;
    padding: 15px 0;  /* Add vertical padding (top and bottom) */
    position: relative;
    z-index: 10000;  /* Very high - ensure top bar is above navigation */
}

.top .container-fluid {
    max-width: 100%;
    padding-left: 20px !important;
    padding-right: 20px !important;
}

.top .row {
    display: flex;
    align-items: center;
    margin: 0;
}

.top-contact {
    display: flex;
    align-items: center;
}

.top-contact ul {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.top-contact ul li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-contact ul li i {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.top-contact ul li span {
    display: flex;
    align-items: center;
    line-height: 1;
}

.top-right {
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-social {
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-social ul {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    gap: 10px;
}

.top-social ul li {
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-social ul li a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.top-social ul li a i {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Top Right Actions Container */
.top-right-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
}

.language-selector {
    flex: 1;
}

.language-selector .form-control {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 13px;
    padding: 6px 10px;
    transition: all 0.3s ease;
}

.language-selector .form-control:focus {
    border-color: #11D694;
    box-shadow: 0 0 0 3px rgba(17, 214, 148, 0.1);
}

/* ========================================
   LOGIN PEJABAT BUTTON
   ======================================== */
.btn-login-pejabat {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #11D694 0%, #0ea578 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    border: none;
    box-shadow: 0 2px 8px rgba(17, 214, 148, 0.2);
}

.btn-login-pejabat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(17, 214, 148, 0.4);
    color: white;
    text-decoration: none;
}

.btn-login-pejabat:active {
    transform: translateY(0);
}

.btn-login-pejabat i {
    font-size: 14px;
}

/* ========================================
   USER DROPDOWN
   ======================================== */
.user-dropdown {
    position: relative;
    z-index: 10001;  /* Higher than .top to ensure dropdown appears above everything */
}

.btn-user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 180px;
}

.btn-user-dropdown:hover {
    border-color: #11D694;
    box-shadow: 0 2px 8px rgba(17, 214, 148, 0.15);
}

.btn-user-dropdown:focus {
    outline: none;
    border-color: #11D694;
    box-shadow: 0 0 0 3px rgba(17, 214, 148, 0.1);
}

/* User Avatar (small, in button) */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid #11D694;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* User Info in Button */
.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
    max-width: 140px;  /* Limit width for long names */
    overflow: hidden;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.user-role {
    font-size: 11px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Chevron Icon */
.btn-user-dropdown .fa-chevron-down {
    font-size: 12px;
    color: #666;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.btn-user-dropdown .fa-chevron-down.rotate {
    transform: rotate(180deg);
}

/* ========================================
   USER DROPDOWN MENU
   ======================================== */
.user-dropdown-menu {
    position: fixed;  /* FIXED instead of absolute - escape parent container! */
    top: auto;  /* Will be set by JavaScript */
    right: auto;  /* Will be set by JavaScript */
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    z-index: 99999 !important;  /* Maximum z-index with !important to override everything */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

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

/* Dropdown Header */
.user-dropdown-menu .dropdown-header {
    padding: 20px;
    background: linear-gradient(135deg, #11D694 0%, #0ea578 100%);
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.dropdown-user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dropdown-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dropdown-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: white;
    flex: 1;
    min-width: 0;
}

.dropdown-user-info strong {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-user-info span {
    font-size: 13px;
    opacity: 0.95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-vip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    width: fit-content;
}

.badge-vip i {
    font-size: 10px;
}

/* Dropdown Divider */
.user-dropdown-menu .dropdown-divider {
    margin: 0;
    border-top: 1px solid #e0e0e0;
}

/* Dropdown Items */
.user-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.user-dropdown-menu .dropdown-item:hover {
    background: #f8f9fa;
    color: #11D694;
}

.user-dropdown-menu .dropdown-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: #666;
}

.user-dropdown-menu .dropdown-item:hover i {
    color: #11D694;
}

/* Logout Item (special styling) */
.dropdown-item-logout {
    color: #e74c3c !important;
}

.dropdown-item-logout:hover {
    background: #fee !important;
    color: #c0392b !important;
}

.dropdown-item-logout i {
    color: #e74c3c !important;
}

.dropdown-item-logout:hover i {
    color: #c0392b !important;
}

.dropdown-logout-form {
    margin: 0;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet */
@media (max-width: 991px) {
    .top-right-actions {
        gap: 8px;
    }

    .btn-login-pejabat {
        padding: 6px 16px;
        font-size: 12px;
    }

    .btn-login-pejabat span {
        display: none;
    }

    .btn-login-pejabat i {
        font-size: 16px;
    }

    .btn-user-dropdown {
        min-width: 150px;
        padding: 5px 10px;
    }

    .user-info {
        max-width: 120px;  /* Smaller on tablet */
    }

    .user-avatar {
        width: 28px;
        height: 28px;
    }

    .user-name {
        font-size: 12px;
    }

    .user-role {
        font-size: 10px;
    }

    .user-dropdown-menu {
        min-width: 260px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    /* Adjust padding on mobile */
    .top {
        padding: 12px 0;  /* Slightly less vertical padding on mobile */
    }

    .top .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* Stack sections vertically on mobile */
    .top .row > div {
        margin-bottom: 10px;
    }

    .top-contact {
        justify-content: center;
    }

    .top-right {
        justify-content: center;
    }

    .top-right-actions {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        justify-content: center;
    }

    .language-selector {
        flex: 0 1 auto;
        max-width: 150px;
    }

    .btn-login-pejabat {
        justify-content: center;
        padding: 8px 16px;
        flex-shrink: 0;
    }

    .btn-login-pejabat span {
        display: inline;
    }

    .btn-user-dropdown {
        min-width: auto;
        flex-shrink: 1;
    }

    .user-info {
        max-width: 100px;  /* Even smaller on mobile */
    }

    .user-dropdown-menu {
        left: auto;
        right: 0;
        min-width: 260px;
    }

    .dropdown-user-info strong {
        font-size: 14px;
    }

    .dropdown-user-info span {
        font-size: 12px;
    }
}

/* Very Small Mobile */
@media (max-width: 480px) {
    .btn-user-dropdown {
        padding: 6px 10px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
    }

    .user-name {
        font-size: 13px;
    }

    .user-role {
        font-size: 11px;
    }

    .dropdown-user-avatar {
        width: 50px;
        height: 50px;
    }

    .user-dropdown-menu .dropdown-header {
        padding: 15px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.btn-user-dropdown:focus-visible,
.btn-login-pejabat:focus-visible {
    outline: 3px solid #11D694;
    outline-offset: 2px;
}

.dropdown-item:focus-visible {
    outline: 2px solid #11D694;
    outline-offset: -2px;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-dropdown-menu.show {
    animation: slideDown 0.3s ease;
}

/* Loading State (optional for future use) */
.btn-user-dropdown.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-user-dropdown.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(17, 214, 148, 0.2);
    border-top-color: #11D694;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
