/* ============================================
   IOS STYLE HEADER - LIGHT & DARK MODE READY
   Clean & Optimized Version
============================================ */


/* ============================================
   1. MAIN HEADER CONTAINER - FORCE TRANSPARENT
============================================ */
.main-header {
    background: transparent !important;
    background-color: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 12px 0;
}

/* ============================================
   BACK BUTTON STYLES
============================================ */
.back-button-container {
    display: flex;
    align-items: center;
    margin-right: auto;
}

.back-button {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.back-button:hover {
    background: var(--color-accent-primary);
    border-color: var(--color-accent-primary);
    transform: translateY(-1px);
}

.back-button i {
    width: 24px;
    height: 24px;
}

/* ============================================
   2. HEADER ACTIONS (Right side buttons)
============================================ */
.header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    margin-left: auto !important; /* ⬅️ INI YANG PENTING */
    justify-content: flex-end !important;
}

/* ============================================
   3. ICON BUTTONS STYLES
============================================ */
.header-icon-btn {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.header-icon-btn:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    transform: translateY(-1px);
}

/* Notification badge */
.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-accent-primary);
    color: white;
    border-radius: 10px;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid var(--color-bg-secondary);
}

/* Dark mode toggle */
.dark-mode-toggle .dark-mode-icon {
    position: relative;
    width: 20px;
    height: 20px;
}

.dark-mode-toggle .light-icon,
.dark-mode-toggle .dark-icon {
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.3s ease;
}

.dark-mode-toggle .light-icon {
    opacity: 1;
    transform: scale(1);
}

.dark-mode-toggle .dark-icon {
    opacity: 0;
    transform: scale(0.5);
}

.dark-mode .dark-mode-toggle .light-icon {
    opacity: 0;
    transform: scale(0.5);
}

.dark-mode .dark-mode-toggle .dark-icon {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   4. USER MENU - PERBAIKAN TANPA BORDER
============================================ */
.user-menu {
    position: relative;
}

/* User button */
.user-btn {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

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

/* User avatar - TANPA BORDER */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
}

/* Guest user icon */
.user-guest {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.user-guest .user-icon {
    width: 20px;
    height: 20px;
}

/* Vendor badge */
.vendor-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--color-accent-teal);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 2px solid var(--color-bg-card);
}

/* ============================================
   5. USER DROPDOWN - PERBAIKAN TANPA BORDER
============================================ */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-bg-card);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border);
    padding: 8px;
    min-width: 220px;
    z-index: 1000;
    margin-top: 8px;
}

.dark-mode .user-dropdown {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Guest dropdown wider for forms */
.user-dropdown-guest {
    min-width: 320px;
}

/* User info in dropdown */
.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: var(--color-bg-secondary);
    margin-bottom: 8px;
}

/* Dropdown avatar - TANPA BORDER */
.dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    /* TIDAK ADA BORDER DI SINI */
}

.dropdown-user-details strong {
    color: var(--color-text-primary);
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    color: var(--color-text-secondary);
    font-size: 12px;
}

/* ============================================
   FORCE REMOVE ALL AVATAR BORDERS (SAFETY)
============================================ */
.user-avatar,
.dropdown-avatar,
.guest-avatar {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Pastikan tidak ada border inheritance */
.user-btn img,
.user-menu img,
.dropdown-user-info img {
    border: none !important;
}

/* ============================================
   6. AUTHENTICATION FORMS (Guest dropdown)
============================================ */

/* Auth tabs */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin: 0 16px;
}

.auth-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 0;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

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

.auth-tab.active {
    color: var(--color-accent-teal);
    border-bottom-color: var(--color-accent-teal);
}

.auth-tab i {
    width: 16px;
    height: 16px;
}

/* Auth forms container */
.quick-auth-form {
    padding: 16px;
}

/* Form groups */
.form-group {
    margin-bottom: 12px;
}

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

/* Form inputs */
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-accent-teal);
    box-shadow: 0 0 0 3px rgba(var(--color-accent-teal-rgb, 0, 153, 153), 0.1);
}

/* Password field */
.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-secondary);
    opacity: 0.7;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    z-index: 2;
}

.toggle-password:hover {
    opacity: 1;
    background: var(--color-border);
}

/* Password toggle icons */
.toggle-password .eye-off-icon {
    display: none;
}

.toggle-password .eye-icon {
    display: block;
}

.password-visible .toggle-password .eye-icon {
    display: none;
}

.password-visible .toggle-password .eye-off-icon {
    display: block;
}

/* Form options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0 16px;
    font-size: 0.85rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-accent-teal);
}

.forgot-link {
    color: var(--color-accent-pink);
    text-decoration: none;
    font-size: 0.85rem;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* Form hint */
.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

.form-hint a {
    color: var(--color-accent-teal);
    text-decoration: underline;
}

/* ============================================
   7. BUTTONS
============================================ */

/* Primary button (login) */
.btn-primary {
    background: var(--color-accent-teal);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--color-accent-teal-dark, #008080);
    transform: translateY(-1px);
}

/* Success button (register) */
.btn-success {
    background: var(--color-success, #28a745);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    width: 100%;
}

.btn-success:hover {
    background: var(--color-success-dark, #218838);
    transform: translateY(-1px);
}

/* Loading states */
.btn-primary.loading,
.btn-success.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after,
.btn-success.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   8. RESPONSIVE DESIGN
============================================ */
@media (max-width: 768px) {
    .header-container {
        padding: 0 16px;
        gap: 16px;
    }
    
    .header-actions {
        gap: 8px;
    }
    
    .header-icon-btn {
        width: 36px;
        height: 36px;
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .user-dropdown-guest {
        min-width: 280px;
        right: 0;
        left: auto;
    }
    
    .vendor-badge {
        width: 14px;
        height: 14px;
        font-size: 8px;
    }
    
    .role-badge {
        font-size: 0.65rem;
        padding: 1px 6px;
    }
}

/* ============================================
   TOAST NOTIFICATION SYSTEM
============================================ */

#toast-container {
    position: fixed !important;
    top: 80px !important; /* Di bawah header */
    right: 20px !important;
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    pointer-events: none !important; /* Biarkan click through */
}

.toast {
    background: var(--color-bg-card) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 12px !important;
    padding: 16px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    max-width: 350px !important;
    pointer-events: auto !important; /* Toast bisa di-click */
    animation: toastSlideIn 0.3s ease forwards !important;
    backdrop-filter: blur(10px) !important;
    border-left: 4px solid var(--color-accent-teal) !important;
}

.toast.error {
    border-left-color: var(--color-accent-pink) !important;
}

.toast.success {
    border-left-color: var(--color-accent-teal) !important;
}

.toast i {
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
}

.toast span {
    flex: 1 !important;
    font-size: 0.9rem !important;
    color: var(--color-text-primary) !important;
}

.toast button {
    background: none !important;
    border: none !important;
    color: var(--color-text-secondary) !important;
    cursor: pointer !important;
    padding: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0.7 !important;
    flex-shrink: 0 !important;
}

.toast button:hover {
    opacity: 1 !important;
}

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

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

/* ============================================
   LOADING STATES & ANIMATIONS
============================================ */

/* Smooth transitions for all interactive elements */
.header-icon-btn,
.user-btn,
.dropdown-item,
.btn-primary,
.btn-success {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Loading overlay */
.spa-loading {
    position: relative;
}

.spa-loading::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    pointer-events: all;
}

.dark-mode .spa-loading::after {
    background: rgba(0, 0, 0, 0.8);
}

/* ============================================
   FIX FOR ALPINE.JS DROPDOWNS
============================================ */
[x-cloak] {
    display: none !important;
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
============================================ */
.header-icon-btn:focus,
.user-btn:focus,
.form-input:focus,
.btn-primary:focus,
.btn-success:focus {
    outline: 2px solid var(--color-accent-teal);
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   EMERGENCY FIXES FOR JS ERRORS
============================================ */

/* Pastikan toast container ada */
#toast-container:empty {
    display: none !important;
}

/* Fix untuk dropdown yang tidak hilang */
.user-dropdown {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-dropdown[style*="display: none"] {
    display: none !important;
}

/* ============================================
   RESPONSIVE FIXES
============================================ */
@media (max-width: 480px) {
    .header-actions {
        gap: 6px !important;
    }
    
    .header-icon-btn {
        width: 34px !important;
        height: 34px !important;
        border-radius: 10px !important;
    }
    
    .user-dropdown-guest {
        position: fixed !important;
        top: 70px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        min-width: auto !important;
        max-width: calc(100vw - 20px) !important;
    }
    
    #toast-container {
        top: 70px !important;
        right: 10px !important;
        left: 10px !important;
        align-items: center !important;
    }
    
    .toast {
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* ============================================
   PRINT STYLES
============================================ */
@media print {
    .header-actions,
    .user-dropdown,
    #toast-container {
        display: none !important;
    }
}

/* ============================================
   AVATAR BORDER FIX - PERMANENT
============================================ */

/* Ensure NO borders on avatars */
.user-avatar,
.dropdown-avatar,
.user-btn img[class*="avatar"] {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Override any inherited borders */
.user-menu .user-avatar,
.header-actions .user-avatar,
#header-container .user-avatar {
    border: 0 !important;
    border-width: 0 !important;
}

/* Make sure hover states don't add borders */
.user-btn:hover .user-avatar,
.user-avatar:hover {
    border: none !important;
    box-shadow: none !important;
}

/* ============================================
   DROPDOWN ITEMS FIX - OVERRIDE BROWSER DEFAULTS
============================================ */

/* Target SEMUA <a> tags dalam dropdown */
.user-dropdown a.dropdown-item,
.user-dropdown .dropdown-item {
    /* RESET browser default link styles */
    color: var(--color-text-primary) !important;
    text-decoration: none !important;
    
    /* Layout */
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 12px 16px !important;
    width: 100% !important;
    
    /* Visual */
    background: var(--color-bg-secondary) !important;
    border-radius: 12px !important;
    border: none !important;
    cursor: pointer !important;
    
    /* Typography */
    font-size: 15px !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    
    /* Transition */
    transition: all 0.2s ease !important;
    
    /* Reset visited/link states */
    &:visited, &:link, &:active {
        color: var(--color-text-primary) !important;
    }
}

/* Hover state */
.user-dropdown a.dropdown-item:hover,
.user-dropdown .dropdown-item:hover {
    background: var(--color-accent-primary) !important;
    color: white !important;
    transform: translateX(4px) !important;
}

/* Icon styling */
.user-dropdown a.dropdown-item i,
.user-dropdown .dropdown-item i {
    color: var(--color-text-secondary) !important;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
}

.user-dropdown a.dropdown-item:hover i,
.user-dropdown .dropdown-item:hover i {
    color: white !important;
}

/* Span/text styling */
.user-dropdown a.dropdown-item span,
.user-dropdown .dropdown-item span {
    flex: 1 !important;
    text-align: left !important;
    white-space: nowrap !important;
    display: inline !important;
}

/* Specific untuk logout */
.user-dropdown a.logout-btn,
.user-dropdown .logout-btn {
    color: var(--color-accent-red) !important;
}

.user-dropdown a.logout-btn:hover,
.user-dropdown .logout-btn:hover {
    background: var(--color-accent-red) !important;
    color: white !important;
}
