/* Global Navigation Component Styles */

/* Unified header bar styling */
.unified-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 15px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    height: 50px;
    position: relative;
}

.header-left {
    flex: 0 0 auto;
}

/* Wraps .header-center + .header-right; display:contents keeps desktop flex/absolute layout unchanged */
.header-nav-cluster {
    display: contents;
}

.header-logo {
    max-width: 120px; /* Smaller to fit compact header */
    height: auto;
    cursor: default !important;
    pointer-events: none !important;
    margin-top: 15px; /* Fine-tuned positioning for optimal buffer room */
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* View tabs only (centered on desktop). + Deck lives in .header-right next to the welcome menu. */
.header-app-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Top-level app tabs (Database View / Deck Builder) - now in unified header */
.app-tabs {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
.app-tab-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
}
.app-tab-button.active {
    background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
    border-color: #4ecdc4;
    color: #1a1a2e;
    box-shadow: 0 6px 18px rgba(78, 205, 196, 0.45);
}

/* User menu — bar shows icon-only; welcome copy lives in dropdown header */
.user-menu { position: relative; }
.user-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    box-sizing: border-box;
    /* Dark blue + neon teal — aligned with .app-tab-button / active deck tab palette */
    background: rgba(22, 33, 62, 0.75);
    color: #4ecdc4;
    border: 1px solid rgba(78, 205, 196, 0.42);
    border-radius: 6px;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}
.user-menu-toggle:hover {
    background: rgba(26, 26, 46, 0.92);
    border-color: #4ecdc4;
    color: #6fe8de;
    box-shadow: 0 0 14px rgba(78, 205, 196, 0.28);
}
.user-menu-toggle.open {
    border-color: #4ecdc4;
    box-shadow: 0 4px 18px rgba(78, 205, 196, 0.38);
}
.user-menu-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.55), 0 4px 16px rgba(78, 205, 196, 0.25);
}
/* Hamburger icon (three bars) */
.user-menu-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 4px;
    width: 18px;
    height: 14px;
    flex-shrink: 0;
}
.user-menu-hamburger-line {
    display: block;
    height: 2px;
    width: 100%;
    background: currentColor;
    border-radius: 1px;
    box-shadow: 0 0 5px rgba(78, 205, 196, 0.35);
    transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}
.user-menu-toggle:hover .user-menu-hamburger-line {
    box-shadow: 0 0 8px rgba(78, 205, 196, 0.5);
}
.user-menu-toggle.open .user-menu-hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.user-menu-toggle.open .user-menu-hamburger-line:nth-child(2) {
    opacity: 0;
}
.user-menu-toggle.open .user-menu-hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}
.user-greeting-line2 {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    min-width: 0;
}
.user-menu-dropdown-header .user-greeting-copy {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.15em;
    font-size: 15px;
    font-weight: 600;
    color: #ecf0f1;
    line-height: 1.3;
    text-align: right;
}
.user-menu-dropdown-header {
    width: 100%;
    padding: 4px 6px 10px 6px;
    margin: 0 0 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    text-align: right;
    box-sizing: border-box;
}
.user-menu-dropdown-items .user-menu-item:first-child {
    margin-top: 0;
}
/* One column as wide as the longest label — every .user-menu-item matches that width */
.user-menu-dropdown-items {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
    justify-items: stretch;
}
.user-menu-dropdown-items .user-menu-item {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.user-menu-dropdown {
    position: absolute;
    top: 110%;
    right: 0;
    /* Solid panel to match app cards/modals */
    background: #2c3e50;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px;
    min-width: 0;
    max-width: min(260px, calc(100vw - 16px));
    width: max-content;
    display: none;
    flex-direction: column;
    align-items: stretch;
    z-index: 9999;
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}
.user-menu-dropdown.show {
    display: flex;
}
.user-menu-dropdown .user-menu-item {
    width: 100%;
    max-width: 100%;
}
.user-menu-item {
    width: 100%;
    text-align: left;
    background: #34495e;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 8px 0;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.user-menu-item:hover {
    background: #3b5775;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* Colored variants to match app button palette */
.user-menu-item--primary {
    background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
    color: #1a1a2e;
    border-color: #4ecdc4;
}
.user-menu-item--primary:hover {
    background: linear-gradient(135deg, #5dd5cc, #3bc1b6);
}

.user-menu-item--accent {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #ffffff;
    border-color: #e74c3c;
}
.user-menu-item--accent:hover {
    background: linear-gradient(135deg, #ec7063, #d63031);
}

/* Make Log Out match the neutral theme (same as Change Password) */
.user-menu-item--danger {
    background: #34495e;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.18);
}
.user-menu-item--danger:hover {
    background: #3b5775;
}

/* New Deck Button in Global Nav */
.new-deck-btn {
    background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
    color: #1a1a2e;
    border: 1px solid #4ecdc4;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
    white-space: nowrap;
}

.new-deck-btn:hover {
    background: linear-gradient(135deg, #5dd5cc, #3bc1b6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.new-deck-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

/* Legacy logout button style for test compatibility */
.logout-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.logout-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.create-deck-btn {
    background: linear-gradient(135deg, #4ecdc4, #2cb1a6);
    color: #1a1a2e;
    border: 1px solid #4ecdc4;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

.create-deck-btn:hover {
    background: linear-gradient(135deg, #5dd5cc, #3bc1b6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

/* Create User Button and Dropdown */
.create-user-container {
    position: relative;
    display: inline-block;
}

.create-user-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #ffffff;
    border: 1px solid #e74c3c;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.create-user-btn:hover {
    background: linear-gradient(135deg, #ec7063, #d63031);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.create-user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #2c3e50;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 16px;
    min-width: 250px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    margin-top: 4px;
}

.create-user-dropdown.show {
    display: block;
}

.create-user-dropdown .form-group {
    margin-bottom: 12px;
}

.create-user-dropdown label {
    display: block;
    color: #ecf0f1;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}

.create-user-dropdown input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #ecf0f1;
    font-size: 14px;
    box-sizing: border-box;
}

.create-user-dropdown input:focus {
    outline: none;
    border-color: #e74c3c;
    background: rgba(255, 255, 255, 0.15);
}

.create-user-dropdown input::placeholder {
    color: rgba(236, 240, 241, 0.6);
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.save-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.save-btn:hover {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    transform: translateY(-1px);
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ecf0f1;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Ensure all global navigation popups and tooltips appear above main content */
.unified-header .create-user-container,
.unified-header .create-user-dropdown,
.unified-header [title] {
    z-index: 9999 !important;
}

/* Ensure global navigation elements have proper stacking context */
.unified-header {
    z-index: 100;
}

.unified-header .create-user-container {
    z-index: 9999;
}

/* Responsive adjustments for unified header */
@media (max-width: 900px) {
    .unified-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .header-left,
    .header-center,
    .header-right {
        flex: none;
    }
    
    .header-logo {
        max-width: 120px;
    }
}

@media (max-width: 600px) {
    .unified-header {
        padding: 6px 12px;
    }
    
    .header-logo {
        max-width: 100px;
    }
    
    .header-right {
        flex-direction: column;
        gap: 8px;
    }
}
