/**
 * CodeIQ UI Theme - "Glass & Air" & "The Control Deck"
 * Comprehensive UI/UX upgrade for global navigation, session HUD, action toolbar, and polish
 *
 * This file complements table-modern.css (which handles table-specific styles)
 * and overrides selected styles from main.css to achieve the new design vision.
 */

/* ============================================
   PHASE 1: FOUNDATION - CSS VARIABLES & THEMING
   ============================================ */

:root {
    /* CodeIQ Specific Color Adjustments for UI Elements */
    --primary-light-bg: var(--primary-50);    /* For subtle backgrounds */
    --primary-active-bg: var(--primary-100);  /* For active/hover states */
    --primary-text: var(--primary-700);       /* For primary text elements */

    --success-light-bg: var(--success-50);
    --success-text: var(--success-700);
    --warning-light-bg: var(--warning-50);
    --warning-text: var(--warning-700);
    --error-light-bg: var(--error-50);
    --error-text: var(--error-700);

    /* Shadows for floating elements */
    --shadow-sm-subtle: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md-subtle: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
}

/* ============================================
   PHASE 2: GLOBAL NAVIGATION (.tab-bar) - SLIM & SLEEK
   ============================================ */

/* The Global Navigation Container - Brand Purple Gradient */
.tab-bar {
    background: linear-gradient(135deg, rgba(250, 248, 245, 0.98) 0%, rgba(245, 242, 237, 0.95) 50%, rgba(253, 245, 247, 0.95) 100%) !important;
    backdrop-filter: blur(10px) !important; /* Modern frosted glass effect */
    border-bottom: 1px solid rgba(154, 64, 84, 0.12) !important;
    height: 60px !important; /* Fixed, sleeker height */
    min-height: 60px !important; /* Override existing min-height */
    padding: 0 var(--space-6) !important; /* Consistent horizontal padding */
    box-shadow: 0 2px 8px rgba(154, 64, 84, 0.06) !important;
    display: flex !important; /* Ensure flex properties are set */
    align-items: center !important;
    position: sticky !important; /* Keep it at the top */
    top: 0 !important;
    z-index: var(--z-sticky) !important;
}

/* Individual Tabs (Navigation Pills) - Pale Purple Inactive */
.tab {
    background: linear-gradient(135deg, rgba(154, 64, 84, 0.06) 0%, rgba(196, 87, 106, 0.04) 100%) !important;
    border: none !important; /* Remove old heavy borders */
    border-right: none !important; /* Remove right border */
    border-radius: 8px !important; /* Creates the "pill" shape */
    margin-right: var(--space-2) !important; /* Small gap between tabs */
    padding: var(--space-2) var(--space-4) !important; /* Consistent padding */
    opacity: 0.85 !important;
    transition: all 0.2s ease !important;
    min-width: auto !important; /* Let content dictate width */
    max-width: 280px !important; /* Keep existing max-width */
    position: relative !important; /* For active indicator */
    display: flex !important;
    align-items: center !important;
    gap: var(--space-2) !important;
}

.tab:hover {
    background: linear-gradient(135deg, rgba(154, 64, 84, 0.12) 0%, rgba(196, 87, 106, 0.08) 100%) !important;
    opacity: 1 !important; /* Full opacity on hover */
}

/* Active Tab - Prominent Magenta */
.tab.active {
    background: linear-gradient(135deg, rgba(196, 87, 106, 0.15) 0%, rgba(196, 87, 106, 0.12) 100%) !important;
    color: #9a4054 !important; /* Magenta text for active */
    border-bottom: none !important; /* Remove old underline style from main.css */
    opacity: 1 !important; /* Full opacity for active tab */
    font-weight: var(--font-weight-semibold) !important;
    box-shadow: inset 0 -2px 8px rgba(196, 87, 106, 0.08) !important;
}

/* Active Tab Indicator (Magenta left border) */
.tab.active::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 25%; /* Vertically center the indicator */
    height: 50%; /* Make it shorter */
    width: 3px;
    border-radius: 4px;
    background: linear-gradient(180deg, #c4576a 0%, #c4576a 100%) !important; /* Magenta gradient */
}

/* Tab text styling */
.tab-title {
    font-weight: var(--font-weight-medium) !important;
    color: var(--text-primary) !important; /* Default text color */
    font-size: var(--font-size-sm) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.tab.active .tab-title {
    color: var(--primary-700) !important; /* Darker purple for active tab title */
}

/* CodeIQ Brand Logo/Title within the tab bar */
.codeiq-brand {
    padding: var(--space-2) var(--space-6) !important;
    border-right: 1px solid var(--border-light) !important;
    min-width: 200px !important; /* Ensure visual balance */
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: var(--space-3) !important;
}

.codeiq-logo {
    height: 40px !important; /* Smaller, more compact logo */
    width: auto !important;
    object-fit: contain !important;
    max-width: 120px !important;
}

/* ============================================
   PHASE 3: SESSION HUD (METRICS STRIP) - Brand Purple Background
   ============================================ */

.session-stats {
    display: flex !important;
    align-items: center !important;
    gap: 32px !important; /* Spacing between individual metrics */
    padding: var(--space-4) var(--space-5) var(--space-6) var(--space-5) !important; /* Vertical + horizontal padding */
    margin-bottom: 0 !important; /* Remove excess margin */
    border-bottom: 1px solid rgba(154, 64, 84, 0.1) !important; /* Brand purple border */
    border-radius: 12px !important;
    background: linear-gradient(135deg, rgba(250, 248, 245, 0.85) 0%, rgba(245, 242, 237, 0.8) 50%, rgba(253, 245, 247, 0.75) 100%) !important;
    border: 1px solid rgba(154, 64, 84, 0.08) !important;
    flex-wrap: wrap !important; /* Allow wrapping on smaller screens */
    grid-template-columns: none !important; /* Override grid layout */
}

.stat-card {
    background: transparent !important; /* Remove card background */
    box-shadow: none !important; /* Remove shadows */
    border: none !important; /* Remove borders */
    padding: 0 !important; /* Remove internal padding */
    text-align: left !important;
    position: relative !important;
    display: flex !important;
    flex-direction: column-reverse !important; /* Puts label above value */
    flex-shrink: 0 !important;
    transform: none !important; /* Disable hover transform */
}

.stat-card::before {
    display: none !important; /* Remove gradient top border */
}

/* Add a vertical divider between stats (except the last one) */
.stat-card:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -16px; /* Position half-way in the gap */
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--gray-200); /* Light grey divider */
}

.stat-value {
    font-size: var(--font-size-2xl) !important; /* Slightly smaller than before */
    font-weight: var(--font-weight-bold) !important;
    color: #9a4054 !important; /* Brand magenta for metric values */
    line-height: 1.2 !important;
    letter-spacing: -0.02em !important; /* Slightly tighter text */
    margin-bottom: 4px !important; /* Space between value and label */
}

.stat-label {
    font-size: var(--font-size-xs) !important; /* Smaller, uppercase label */
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9a4054 !important; /* Dark purple for labels */
    font-weight: var(--font-weight-semibold) !important;
}

/* Ensure session header also looks clean */
.session-header {
    display: flex !important;
    align-items: center !important;
    gap: var(--space-4) !important;
    margin-bottom: var(--space-4) !important; /* Reduced margin */
    flex-wrap: wrap !important;
}

.session-header h2 {
    font-size: var(--font-size-2xl) !important;
    font-weight: var(--font-weight-bold) !important;
    color: var(--text-primary) !important;
    flex: 1 !important;
    min-width: 200px !important;
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* ============================================
   PHASE 4: ACTION TOOLBAR (SEARCH, FILTERS, RIQ BUTTON)
   ============================================ */

/* New Wrapper for Search, Filters, and RiQ Button - Brand Purple Background */
.action-toolbar {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: var(--space-4) var(--space-5) var(--space-5) var(--space-5) !important; /* Vertical + horizontal spacing */
    gap: var(--space-4) !important; /* Horizontal spacing between elements */
    flex-wrap: wrap !important; /* Allow elements to wrap on smaller screens */
    background: linear-gradient(135deg, rgba(250, 248, 245, 0.7) 0%, rgba(245, 242, 237, 0.6) 50%, rgba(253, 245, 247, 0.5) 100%) !important;
    border: 1px solid rgba(154, 64, 84, 0.08) !important;
    border-radius: 12px !important;
    margin-bottom: var(--space-4) !important;
}

/* Refined Search Input */
.transaction-search-container {
    flex: 1 !important; /* Allows search to take available space */
    max-width: 400px !important; /* Cap its width to avoid stretching too much */
    position: relative !important; /* For icon positioning */
    margin: 0 !important; /* Remove any previous margins */
    background: transparent !important; /* Ensure no background */
    padding: 0 !important; /* Remove any previous padding */
}

#transactionSearchInput {
    width: 100% !important;
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: var(--input-radius) !important;
    padding: 10px 40px 10px 16px !important; /* Padding for text and icon */
    height: 40px !important; /* Standard height */
    font-size: var(--font-size-sm) !important;
    box-shadow: var(--shadow-sm-subtle) !important;
    transition: all 0.2s ease !important;
}

#transactionSearchInput:focus {
    outline: none !important;
    border-color: var(--input-border-focus) !important;
    box-shadow: 0 0 0 3px rgba(154, 64, 84, 0.1) !important; /* Subtle focus ring */
    background: white !important;
}

.transaction-search-container span { /* The magnifying glass icon */
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--gray-400) !important;
    font-size: var(--font-size-lg) !important;
    pointer-events: none !important;
}

/* Segmented Control for Filters (e.g., "All", "Auto-coded", "Unmatched") */
.filter-group {
    display: inline-flex !important;
    background: linear-gradient(135deg, rgba(154, 64, 84, 0.06) 0%, rgba(196, 87, 106, 0.04) 100%) !important;
    padding: 4px !important;
    border-radius: 8px !important;
    flex-shrink: 0 !important;
    border: 1px solid rgba(154, 64, 84, 0.1) !important;
}

.filter-btn {
    background: transparent !important;
    border: none !important;
    padding: 6px 12px !important;
    font-size: var(--font-size-sm) !important;
    font-weight: var(--font-weight-medium) !important;
    color: var(--gray-600) !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
}

.filter-btn:hover:not(.active) {
    background: var(--gray-100) !important;
    color: var(--gray-700) !important;
}

.filter-btn.active {
    background: linear-gradient(135deg, #c4576a 0%, #c4576a 100%) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(196, 87, 106, 0.3) !important;
    font-weight: var(--font-weight-semibold) !important;
}

/* RiQ Button Specific Styling */
#riq-button-container {
    margin-bottom: 0 !important; /* Remove any lingering margins */
    display: flex !important;
    align-items: center !important;
    gap: var(--space-3) !important;
    flex-shrink: 0 !important;
}

#riq-analyse-button {
    background: linear-gradient(135deg, #ffffff 0%, #fdf5f7 100%) !important; /* Light, glassy background */
    border: 1px solid var(--primary-200) !important; /* Subtle purple border */
    color: var(--primary-700) !important; /* CodeIQ purple text */
    box-shadow: var(--shadow-sm-subtle) !important;
    height: 40px !important;
    padding: 0 16px !important;
    border-radius: 8px !important;
    font-weight: var(--font-weight-semibold) !important;
    font-size: var(--font-size-sm) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

#riq-analyse-button:hover {
    border-color: var(--primary-400) !important;
    box-shadow: 0 0 0 3px rgba(154, 64, 84, 0.1) !important; /* Subtle hover effect */
    background: var(--primary-50) !important;
}

#riq-analyse-button img {
    width: 20px !important; /* Smaller RiQ logo */
    height: 20px !important;
}

/* ============================================
   PHASE 9: POLISH & TRANSITIONS - STICKY COLUMNS & LOADING
   ============================================ */

/* Sticky Checkbox Column */
.transaction-table th.sticky-column,
.transaction-table td.checkbox-cell {
    position: sticky !important;
    left: 0 !important;
    z-index: 15 !important; /* Higher than regular cells, lower than header */
    background-color: var(--table-bg) !important; /* Ensure it covers content sliding under */
    border-right: 1px solid var(--table-border-color) !important; /* Visual separation */
}

/* Sticky Date Column (second column) */
.transaction-table th.sticky-column-2,
.transaction-table td.date-cell.sticky {
    position: sticky !important;
    left: 60px !important; /* Adjust based on checkbox column width */
    z-index: 15 !important;
    background-color: var(--table-bg) !important;
    border-right: 1px solid var(--table-border-color) !important;
}

/* Ensure sticky headers are above sticky cells */
.transaction-table thead th.sticky-column,
.transaction-table thead th.sticky-column-2 {
    z-index: 25 !important; /* Higher than regular sticky cells */
}

/* Loading Skeletons */
.skeleton-row {
    background-color: var(--gray-100) !important;
    animation: pulse-bg 1.5s infinite ease-in-out !important;
}

.skeleton-cell {
    padding: var(--cell-padding-y) var(--cell-padding-x) !important;
    height: 38px !important; /* Match typical row height */
    border-bottom: 1px solid var(--table-border-color) !important;
}

.skeleton-line {
    background-color: var(--gray-200) !important;
    height: 12px !important;
    border-radius: 4px !important;
    width: 80% !important; /* Simulate varying content length */
    margin-bottom: 4px !important;
}

.skeleton-line-short {
    width: 40% !important;
}

@keyframes pulse-bg {
    0% { background-color: var(--gray-100); }
    50% { background-color: var(--gray-200); }
    100% { background-color: var(--gray-100); }
}

/* Floating Action Bar */
.floating-action-bar {
    position: fixed !important;
    bottom: var(--space-6) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: var(--z-fixed) !important; /* Ensure it's above most content */
    background: rgba(255, 255, 255, 0.9) !important; /* Slightly translucent */
    backdrop-filter: blur(8px) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-xl) !important;
    padding: var(--space-3) var(--space-6) !important;
    box-shadow: var(--shadow-xl) !important; /* Prominent shadow to make it float */
    display: flex !important;
    align-items: center !important;
    gap: var(--space-4) !important;
    transition: all 0.3s ease-out !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.floating-action-bar.visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) !important; /* Subtle lift on show */
}

.fab-count {
    font-size: var(--font-size-sm) !important;
    font-weight: var(--font-weight-medium) !important;
    color: var(--primary-700) !important;
    white-space: nowrap !important;
}

.fab-actions {
    display: flex !important;
    gap: var(--space-3) !important;
}

/* Additional Polish - Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu.show {
    animation: fadeIn 0.2s ease-out !important;
}
