/**
 * Modern Professional Header/Navbar Styles
 * Clean, elegant design matching the sidebar
 */

/* ===== CSS Variables ===== */
:root {
    --header-height: 64px;
    --header-bg: #ffffff;
    --header-bg-glass: rgba(255, 255, 255, 0.85);
    --header-border: #e2e8f0;
    --header-text: #1e293b;
    --header-text-muted: #64748b;
    --header-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --header-btn-bg: #f1f5f9;
    --header-btn-hover: #e2e8f0;
    --header-btn-active: #3b82f6;
    --header-dropdown-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15);
    --header-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --header-bg: #1e293b;
    --header-bg-glass: rgba(30, 41, 59, 0.9);
    --header-border: #334155;
    --header-text: #f1f5f9;
    --header-text-muted: #94a3b8;
    --header-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --header-btn-bg: #334155;
    --header-btn-hover: #475569;
    --header-dropdown-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.4);
}

/* ===== Main Header Container ===== */
.header-modern {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--header-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--header-transition);
}

.header-modern.scrolled {
    background: var(--header-bg-glass);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    gap: 16px;
}

/* ===== Header Left Section ===== */
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mobile Menu Toggle */
.header-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--header-btn-bg);
    border: none;
    border-radius: 10px;
    color: var(--header-text);
    cursor: pointer;
    transition: var(--header-transition);
}

.header-menu-toggle:hover {
    background: var(--header-btn-hover);
}

.header-menu-toggle svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 1024px) {
    .header-menu-toggle {
        display: flex;
    }
}

/* Breadcrumb / Page Title */
.header-breadcrumb {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--header-text-muted);
}

@media (min-width: 768px) {
    .header-breadcrumb {
        display: flex;
    }
}

.header-breadcrumb-separator {
    color: var(--header-border);
}

.header-page-title {
    font-weight: 600;
    color: var(--header-text);
}

/* ===== Header Center - Search ===== */
.header-search {
    flex: 1;
    max-width: 480px;
    display: none;
    position: relative;
}

@media (min-width: 768px) {
    .header-search {
        display: block;
    }
}

.header-search-wrapper {
    position: relative;
    width: 100%;
}

.header-search-input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 44px;
    background: var(--header-btn-bg);
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 14px;
    color: var(--header-text);
    transition: var(--header-transition);
    outline: none;
}

.header-search-input::placeholder {
    color: var(--header-text-muted);
}

.header-search-input:focus {
    background: var(--header-bg);
    border-color: var(--header-btn-active);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.header-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--header-text-muted);
    pointer-events: none;
}

.header-search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--header-text-muted);
}

.header-search-shortcut kbd {
    padding: 2px 5px;
    background: var(--header-btn-bg);
    border-radius: 3px;
    font-family: inherit;
    font-size: 10px;
}

/* Search Spinner */
.header-search-spinner {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-search-spinner .spinner {
    width: 18px;
    height: 18px;
    color: var(--header-btn-active);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Search Results Dropdown ===== */
.header-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    box-shadow: var(--header-dropdown-shadow);
    max-height: 400px;
    overflow: hidden;
    z-index: 9999;
}

.search-results-content {
    max-height: 340px;
    overflow-y: auto;
    padding: 8px;
}

.search-results-content::-webkit-scrollbar {
    width: 6px;
}

.search-results-content::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-content::-webkit-scrollbar-thumb {
    background: var(--header-border);
    border-radius: 3px;
}

.search-result-group {
    margin-bottom: 8px;
}

.search-result-group:last-child {
    margin-bottom: 0;
}

.search-result-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--header-text-muted);
}

.search-group-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-group-icon svg {
    width: 14px;
    height: 14px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--header-text);
    cursor: pointer;
    transition: var(--header-transition);
}

.search-result-item:hover,
.search-result-item.selected {
    background: var(--header-btn-bg);
}

.search-result-item.selected {
    background: rgba(59, 130, 246, 0.1);
}

.search-result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--header-btn-bg);
    border-radius: 8px;
    flex-shrink: 0;
}

.search-result-item:hover .search-result-icon,
.search-result-item.selected .search-result-icon {
    background: var(--header-btn-hover);
}

.search-result-icon svg {
    width: 18px;
    height: 18px;
    color: var(--header-text-muted);
}

.search-result-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--header-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-subtitle {
    font-size: 12px;
    color: var(--header-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Search result title and subtitle rows */
.search-result-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-subtitle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Search result status text with colors */
.search-result-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-result-status.status-success {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
}

.search-result-status.status-warning {
    color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

.search-result-status.status-danger {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.search-result-status.status-info {
    color: #0284c7;
    background: rgba(2, 132, 199, 0.1);
}

/* Search result badge (transaction status) */
.search-result-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--header-btn-bg);
    color: var(--header-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Dark mode adjustments for status colors */
[data-theme="dark"] .search-result-status.status-success {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.15);
}

[data-theme="dark"] .search-result-status.status-warning {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
}

[data-theme="dark"] .search-result-status.status-danger {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

[data-theme="dark"] .search-result-status.status-info {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.search-results-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--header-text-muted);
    text-align: center;
}

.search-results-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.search-results-empty span {
    font-size: 14px;
}

.search-results-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 12px;
    background: var(--header-btn-bg);
    border-top: 1px solid var(--header-border);
    font-size: 11px;
    color: var(--header-text-muted);
}

.search-results-footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    color: var(--header-text-muted);
    margin-right: 4px;
}

/* ===== Header Right Section ===== */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Header Action Buttons ===== */
.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: var(--header-btn-bg);
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--header-text);
    text-decoration: none;
    cursor: pointer;
    transition: var(--header-transition);
    gap: 8px;
    white-space: nowrap;
}

.header-btn:hover {
    background: var(--header-btn-hover);
    color: var(--header-text);
}

.header-btn:active {
    transform: scale(0.98);
}

.header-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.header-btn-icon {
    padding: 0;
    width: 40px;
}

.header-btn-text {
    display: none;
}

@media (min-width: 768px) {
    .header-btn-text {
        display: inline;
    }
}

/* Primary Action Button */
.header-btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px -2px rgba(59, 130, 246, 0.4);
}

.header-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px -2px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

/* Success Button */
.header-btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
}

.header-btn-success:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #ffffff;
}

/* ===== Header Divider ===== */
.header-divider {
    width: 1px;
    height: 24px;
    background: var(--header-border);
    margin: 0 4px;
}

/* ===== Notification Bell ===== */
.header-notification {
    position: relative;
}

.header-notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    border: 2px solid var(--header-bg);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: notification-pulse 2s infinite;
}

@keyframes notification-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ===== Header Dropdown ===== */
.header-dropdown {
    position: relative;
}

.header-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--header-btn-bg);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--header-transition);
}

.header-dropdown-toggle:hover {
    background: var(--header-btn-hover);
}

.header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 12px;
    box-shadow: var(--header-dropdown-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--header-transition);
    z-index: 100;
    overflow: hidden;
}

.header-dropdown.open .header-dropdown-menu,
.header-dropdown:focus-within .header-dropdown-menu,
details.header-dropdown[open] .header-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--header-border);
}

.header-dropdown-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--header-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-dropdown-content {
    padding: 8px;
}

.header-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--header-text);
    text-decoration: none;
    transition: var(--header-transition);
}

.header-dropdown-item:hover {
    background: var(--header-btn-bg);
}

.header-dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--header-text-muted);
}

.header-dropdown-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--header-btn-active);
}

.header-dropdown-item.active svg {
    color: var(--header-btn-active);
}

.header-dropdown-footer {
    padding: 8px;
    border-top: 1px solid var(--header-border);
}

/* ===== User Profile Dropdown ===== */
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    background: var(--header-btn-bg);
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: var(--header-transition);
}

.header-user:hover {
    background: var(--header-btn-hover);
}

.header-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--header-bg);
    box-shadow: 0 0 0 2px var(--header-btn-active);
}

.header-user-info {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

@media (min-width: 768px) {
    .header-user-info {
        display: flex;
    }
}

.header-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--header-text);
}

.header-user-role {
    font-size: 11px;
    color: var(--header-text-muted);
}

.header-user-chevron {
    width: 16px;
    height: 16px;
    color: var(--header-text-muted);
    transition: transform 0.2s ease;
}

.header-dropdown.open .header-user-chevron {
    transform: rotate(180deg);
}

/* User dropdown specific */
.header-user-dropdown-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--header-border);
}

.header-user-dropdown-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
}

.header-user-dropdown-info {
    flex: 1;
}

.header-user-dropdown-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--header-text);
}

.header-user-dropdown-email {
    font-size: 13px;
    color: var(--header-text-muted);
}

/* ===== Date Display ===== */
.header-date {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--header-btn-bg);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--header-text);
}

@media (min-width: 1024px) {
    .header-date {
        display: flex;
    }
}

.header-date svg {
    width: 16px;
    height: 16px;
    color: var(--header-text-muted);
}

/* ===== Quick Actions Grid ===== */
.header-quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
}

.header-quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--header-btn-bg);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--header-text-muted);
    text-decoration: none;
    text-align: center;
    transition: var(--header-transition);
}

.header-quick-action:hover {
    background: var(--header-btn-hover);
    color: var(--header-text);
    transform: translateY(-2px);
}

.header-quick-action svg {
    width: 22px;
    height: 22px;
}

/* ===== Language Selector ===== */
.header-lang-flag {
    width: 22px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
}

.header-lang-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--header-text);
}

/* ===== Theme Toggle ===== */
.header-theme-toggle {
    position: relative;
    overflow: hidden;
}

.header-theme-toggle .theme-icon-sun,
.header-theme-toggle .theme-icon-moon {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

[data-theme="dark"] .header-theme-toggle .theme-icon-sun {
    transform: rotate(-90deg) scale(0);
    opacity: 0;
}

[data-theme="dark"] .header-theme-toggle .theme-icon-moon {
    transform: rotate(0) scale(1);
    opacity: 1;
}

[data-theme="light"] .header-theme-toggle .theme-icon-sun,
:root:not([data-theme="dark"]) .header-theme-toggle .theme-icon-sun {
    transform: rotate(0) scale(1);
    opacity: 1;
}

[data-theme="light"] .header-theme-toggle .theme-icon-moon,
:root:not([data-theme="dark"]) .header-theme-toggle .theme-icon-moon {
    position: absolute;
    transform: rotate(90deg) scale(0);
    opacity: 0;
}

/* ===== Print Styles ===== */
@media print {
    .header-modern {
        display: none !important;
    }
}

/* ===== Animation for dropdown items ===== */
.header-dropdown-item {
    opacity: 0;
    transform: translateX(-10px);
    animation: slideIn 0.2s ease forwards;
}

.header-dropdown-item:nth-child(1) { animation-delay: 0.05s; }
.header-dropdown-item:nth-child(2) { animation-delay: 0.1s; }
.header-dropdown-item:nth-child(3) { animation-delay: 0.15s; }
.header-dropdown-item:nth-child(4) { animation-delay: 0.2s; }
.header-dropdown-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== AI Button ===== */
.header-btn-ai {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px -2px rgba(139, 92, 246, 0.4);
}

.header-btn-ai:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px -2px rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
}

.header-btn-ai svg {
    width: 18px;
    height: 18px;
}

/* ===== POS Button ===== */
.header-btn-pos {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px -2px rgba(16, 185, 129, 0.4);
}

.header-btn-pos:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

/* ===== Enhanced User Profile ===== */
.header-user-avatar-wrapper {
    position: relative;
}

.header-user-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--header-bg);
    border-radius: 50%;
}

.header-user-dropdown-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.header-user-dropdown-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid var(--header-bg);
    border-radius: 50%;
}

.header-user-dropdown-role {
    margin-top: 6px;
}

.header-user-role-badge {
    display: inline-block;
    padding: 3px 10px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--header-btn-active);
    text-transform: capitalize;
}

[data-theme="dark"] .header-user-role-badge {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Enhanced User Menu */
.header-user-menu {
    min-width: 280px !important;
}

.header-user-dropdown-header {
    padding: 20px 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
}

[data-theme="dark"] .header-user-dropdown-header {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.header-user-dropdown-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    object-fit: cover;
    border: 3px solid var(--header-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Logout Button */
.header-logout-btn {
    color: #ef4444 !important;
    transition: all 0.2s ease;
}

.header-logout-btn svg {
    color: #ef4444 !important;
}

.header-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* ===== Responsive adjustments ===== */
@media (max-width: 640px) {
    .header-inner {
        padding: 0 12px;
    }

    .header-right {
        gap: 4px;
    }

    .header-btn {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
    }

    .header-btn svg {
        width: 16px;
        height: 16px;
    }

    .header-divider {
        display: none;
    }

    .header-date {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .header-btn-ai .header-btn-text,
    .header-btn-pos .header-btn-text {
        display: none;
    }
}
