/**
 * GenoBank BioWallet Switcher - Styles
 *
 * Purpose: Responsive, accessible styling for wallet switching UI
 * Scope: ALL *.genobank.app + genobank.io/* portals
 *
 * Features:
 * - Clean, modern design matching GenoBank brand
 * - Responsive (mobile-friendly)
 * - Dark mode support
 * - Accessible (keyboard navigation, ARIA)
 *
 * @version 1.0.0
 * @date 2025-10-06
 */

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.biowallet-switcher {
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    z-index: 1000;
}

/* ==========================================================================
   Current Wallet Display
   ========================================================================== */

.biowallet-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-width: 200px;
}

.biowallet-current:hover {
    background: #f8f9fa;
    border-color: #0066cc;
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.1);
}

.biowallet-current:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Authenticated state */
.biowallet-current.biowallet-authenticated {
    border-color: #0066cc;
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
}

/* ==========================================================================
   Icon
   ========================================================================== */

.biowallet-icon {
    font-size: 24px;
    line-height: 1;
    flex-shrink: 0;
}

/* ==========================================================================
   Info Section
   ========================================================================== */

.biowallet-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.biowallet-provider {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.biowallet-address {
    font-size: 12px;
    color: #6c757d;
    font-family: "Monaco", "Menlo", "Ubuntu Mono", "Consolas", monospace;
    display: none; /* Hidden by default, shown when authenticated */
}

/* ==========================================================================
   Dropdown Button
   ========================================================================== */

.biowallet-dropdown-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #6c757d;
    padding: 4px 6px;
    margin: -4px -6px -4px 0;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.biowallet-dropdown-btn:hover {
    background: rgba(0, 102, 204, 0.1);
    color: #0066cc;
}

.biowallet-dropdown-btn:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* ==========================================================================
   Dropdown Menu
   ========================================================================== */

.biowallet-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 280px;
    max-width: 320px;
    z-index: 9999;
    overflow: hidden;
    display: none; /* Hidden by default */
    animation: biowalletMenuSlideIn 0.2s ease;
}

@keyframes biowalletMenuSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Menu Header
   ========================================================================== */

.biowallet-menu-header {
    padding: 14px 16px;
    font-weight: 700;
    font-size: 13px;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

/* ==========================================================================
   Menu Items
   ========================================================================== */

.biowallet-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #212529;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.biowallet-menu-item:hover {
    background: #f8f9fa;
    border-left-color: #0066cc;
}

.biowallet-menu-item:active {
    background: #e9ecef;
}

/* Active (current provider) */
.biowallet-menu-item.active {
    background: #e7f3ff;
    border-left-color: #0066cc;
    font-weight: 600;
}

.biowallet-menu-item.active::after {
    content: '✓';
    margin-left: auto;
    color: #0066cc;
    font-weight: bold;
}

/* Danger (logout) */
.biowallet-menu-item.danger {
    color: #dc3545;
}

.biowallet-menu-item.danger:hover {
    background: #fff5f5;
    border-left-color: #dc3545;
}

.biowallet-menu-item.danger .biowallet-menu-icon {
    opacity: 0.8;
}

/* ==========================================================================
   Menu Item Icons
   ========================================================================== */

.biowallet-menu-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

/* ==========================================================================
   Menu Divider
   ========================================================================== */

.biowallet-menu hr {
    margin: 0;
    border: none;
    border-top: 1px solid #e9ecef;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .biowallet-current {
        min-width: auto;
        padding: 8px 12px;
    }

    .biowallet-provider {
        font-size: 13px;
    }

    .biowallet-address {
        font-size: 11px;
    }

    .biowallet-menu {
        min-width: 260px;
        right: -8px; /* Align to right edge on mobile */
    }

    .biowallet-menu-item {
        padding: 10px 14px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .biowallet-current {
        gap: 8px;
    }

    .biowallet-icon {
        font-size: 20px;
    }

    .biowallet-menu {
        min-width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        left: 16px;
        right: 16px;
    }
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .biowallet-current {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .biowallet-current:hover {
        background: #374151;
        border-color: #60a5fa;
    }

    .biowallet-current.biowallet-authenticated {
        border-color: #60a5fa;
        background: linear-gradient(135deg, #2d3748 0%, #1e293b 100%);
    }

    .biowallet-provider {
        color: #f7fafc;
    }

    .biowallet-address {
        color: #a0aec0;
    }

    .biowallet-dropdown-btn {
        color: #a0aec0;
    }

    .biowallet-dropdown-btn:hover {
        background: rgba(96, 165, 250, 0.2);
        color: #60a5fa;
    }

    .biowallet-menu {
        background: #2d3748;
        border-color: #4a5568;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .biowallet-menu-header {
        background: #1a202c;
        border-bottom-color: #4a5568;
        color: #cbd5e0;
    }

    .biowallet-menu-item {
        color: #e2e8f0;
    }

    .biowallet-menu-item:hover {
        background: #374151;
        border-left-color: #60a5fa;
    }

    .biowallet-menu-item.active {
        background: #1e3a5f;
        border-left-color: #60a5fa;
    }

    .biowallet-menu-item.danger:hover {
        background: #3f1f1f;
        border-left-color: #ef4444;
    }

    .biowallet-menu hr {
        border-top-color: #4a5568;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus styles for keyboard navigation */
.biowallet-menu-item:focus {
    outline: 2px solid #0066cc;
    outline-offset: -2px;
    background: #e7f3ff;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .biowallet-current {
        border-width: 3px;
    }

    .biowallet-menu {
        border-width: 2px;
    }

    .biowallet-menu-item {
        border-left-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .biowallet-current,
    .biowallet-dropdown-btn,
    .biowallet-menu-item {
        transition: none;
    }

    @keyframes biowalletMenuSlideIn {
        from, to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .biowallet-switcher {
        display: none;
    }
}

/* ==========================================================================
   Z-Index Management
   ========================================================================== */

/*
 * Z-index hierarchy for GenoBank ecosystem:
 * - Modal overlays: 10000+
 * - Dropdown menus: 9999
 * - Sticky headers: 1000
 * - Regular content: 1-999
 */

.biowallet-switcher {
    z-index: 1000;
}

.biowallet-menu {
    z-index: 9999;
}
