/* ========================================
   Components CSS - Reusable UI Components
   ======================================== */

/* ========================================
   Top Header Bar
   ======================================== */
.top-header {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 64px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    transition: left 0.3s ease;
}

.sidebar-nav.collapsed ~ .top-header {
    left: 70px;
}

.top-header-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    height: 100%;
    padding: 0 1.5rem;
    list-style: none;
    margin: 0;
}

.top-header-item {
    display: flex;
    align-items: center;
}

.top-header-link {
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.top-header-link:hover {
    background-color: rgba(0, 113, 113, 0.08);
}

.user-menu-container {
    position: relative;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-menu-button:hover {
    background-color: rgba(0, 113, 113, 0.08);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-tenant {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.dropdown-arrow {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
    fill: currentColor;
}

.user-menu-button[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
    border-radius: var(--border-radius-sm);
    margin: 0.25rem 0.5rem;
}

.user-dropdown-item:hover {
    background-color: rgba(0, 113, 113, 0.08);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .top-header {
        left: 0;
    }

    .sidebar-nav.mobile-open ~ .top-header {
        left: 260px;
    }
}

/* ========================================
   Sidebar Navigation
   ======================================== */
body {
    display: flex;
    min-height: 100vh;
    padding-top: 64px;
}

.sidebar-nav {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.sidebar-nav.collapsed {
    width: 70px;
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav.collapsed .sidebar-header {
    justify-content: center;
    padding: 1.5rem 0.5rem;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.sidebar-logo-text {
    transition: opacity 0.3s ease;
}

.sidebar-nav.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav.collapsed .sidebar-logo {
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--link-hover-bg);
    color: var(--primary-color);
}

.sidebar-toggle svg {
    transition: transform 0.3s ease;
}

.sidebar-nav.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-menu {
    flex: 1 1 auto;
    padding: 1rem 0;
    list-style: none;
    overflow: visible;
}

.menu-item {
    margin: 0;
}

.menu-item-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    border-radius: var(--border-radius-sm);
}

.sidebar-nav.collapsed .menu-item-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.menu-item-link:hover {
    background: rgba(0, 113, 113, 0.08);
    border-left-color: var(--primary-color);
}

.menu-item-link.active {
    background: var(--primary-lighter);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.menu-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: currentColor;
}

.menu-text {
    transition: opacity 0.3s ease;
}

.sidebar-nav.collapsed .menu-text {
    display: none;
}

.sidebar-nav.collapsed .menu-arrow {
    display: none;
}

.sidebar-nav.collapsed .submenu {
    display: none;
}

.menu-parent {
    background: none;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    border-radius: var(--border-radius-sm);
    text-align: left;
}

.sidebar-nav.collapsed .menu-parent {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.menu-parent:hover {
    background: rgba(0, 113, 113, 0.08);
    border-left-color: var(--primary-color);
}

.menu-parent-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.menu-parent.expanded .menu-arrow {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--light-bg);
}

.submenu.open {
    max-height: 2000px;
    overflow: visible;
}

.submenu-group {
    padding: 0.5rem 0;
}

.submenu-group-title {
    padding: 0.5rem 1rem 0.25rem 3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.submenu-item {
    margin: 0;
}

.submenu-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem 0.625rem 3rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    border-radius: var(--border-radius-sm);
}

.submenu-link:hover {
    background: rgba(0, 113, 113, 0.08);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.submenu-link.active {
    background: var(--primary-lighter);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--border-radius-md);
    transition: all 0.2s ease;
}

.user-section:hover {
    background: var(--link-hover-bg);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    transition: opacity 0.3s ease;
}

.sidebar-nav.collapsed .user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logout-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0.75rem 1rem;
    color: var(--danger-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: var(--border-radius-sm);
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-nav.collapsed .logout-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.sidebar-nav.collapsed .logout-link svg {
    margin-right: 0 !important;
}

.sidebar-nav.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
}

.sidebar-nav.collapsed .tenant-selector {
    display: none !important;
}

/* Main content area adjustment for sidebar */
.main-wrapper {
    margin-left: 260px;
    flex: 1;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

.sidebar-nav.collapsed ~ .main-wrapper {
    margin-left: 70px;
}

/* Top header for user actions */
.top-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

/* Mobile Header - Hidden by default */
.mobile-header {
    display: none;
}

.mobile-menu-toggle {
    display: none;
}

.mobile-logo {
    display: none;
}

/* Tablet responsive - Remove sidebar margin for better content space */
@media (max-width: 968px) and (min-width: 769px) {
    .main-wrapper {
        margin-left: 70px !important;
    }

    .sidebar-nav {
        width: 70px;
    }

    .sidebar-nav .sidebar-logo-text,
    .sidebar-nav .menu-text,
    .sidebar-nav .menu-arrow,
    .sidebar-nav .submenu {
        display: none;
    }

    .top-header {
        left: 70px;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .top-header {
        display: none;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
        z-index: 1000;
        padding: 0 1rem;
    }

    .mobile-menu-toggle {
        display: block;
        position: absolute;
        left: 1rem;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 0.75rem;
        border-radius: var(--border-radius-md);
        cursor: pointer;
        box-shadow: var(--shadow-md);
        transition: all 0.3s ease;
    }

    .mobile-menu-toggle:hover {
        background: var(--primary-dark);
        transform: scale(1.05);
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    .mobile-logo {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        text-decoration: none;
        color: var(--text-primary);
    }

    .mobile-logo-icon {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
    }

    .mobile-logo-text {
        font-size: 1.125rem;
        font-weight: 700;
        color: var(--text-primary);
    }

    .main-wrapper {
        margin-top: 60px;
    }

    .sidebar-nav {
        transform: translateX(-100%);
        top: 60px;
        height: calc(100vh - 60px);
    }

    .sidebar-nav.mobile-open {
        transform: translateX(0);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
    }

    .main-wrapper {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* ========================================
   Page Headers & Titles
   ======================================== */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.header {
    margin-bottom: 2rem;
}

/* ========================================
   Stat Cards & Dashboard Components
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.queued::before { background: var(--info-color); }
.stat-card.processed::before { background: var(--success-color); }
.stat-card.failed::before { background: var(--danger-color); }
.stat-card.queue-size::before { background: var(--warning-color); }
.stat-card.workers::before { background: var(--secondary-color); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 24px;
}

.stat-card.queued .stat-icon { background: rgba(59, 130, 246, 0.1); color: var(--info-color); }
.stat-card.processed .stat-icon { background: rgba(16, 185, 129, 0.1); color: var(--success-color); }
.stat-card.failed .stat-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger-color); }
.stat-card.queue-size .stat-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.stat-card.workers .stat-icon { background: rgba(139, 92, 246, 0.1); color: var(--secondary-color); }

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========================================
   Login Components
   ======================================== */
.login-container {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 2rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.brand-section {
    text-align: center;
    margin-bottom: 2.5rem;
}

.brand-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
}

/* ========================================
   Domain & Info Components
   ======================================== */
.domain-info {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.domain-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.domain-value {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--light-bg);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.info-row {
    display: flex;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-primary);
    width: 200px;
    flex-shrink: 0;
}

.info-value {
    color: var(--text-secondary);
    flex: 1;
}

/* ========================================
   Verification Components
   ======================================== */
.verify-details {
    background: var(--light-bg) !important;
}

.verify-details td {
    padding: 2rem 1.5rem;
}

.verify-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.verify-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}

.verify-section h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.verify-item {
    margin-bottom: 0.75rem;
}

.verify-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.verify-value {
    color: var(--text-primary);
    font-family: monospace;
    background: var(--light-bg);
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    word-break: break-all;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-width: 100%;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.status-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.status-pass {
    background: var(--success-color);
}

.status-fail {
    background: var(--danger-color);
}
/* ========================================
   Tenant Selector Component
   ======================================== */
.tenant-selector {
    margin-left: auto;
    margin-right: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tenant-selector.visible {
    display: block !important;
    opacity: 1;
}

.tenant-select {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 200px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.tenant-select:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.tenant-select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.tenant-select option {
    background: var(--card-bg);
    color: var(--text-primary);
}
