/**
 * Matrix Console - Clean CSS Design System
 * Separated from PHP for proper architecture
 */

/* CSS Variables - Design System */
:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --secondary: #6B7280;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #06B6D4;
    
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #F1F5F9;
    --bg-surface: #FFFFFF;
    --bg-overlay: rgba(0, 0, 0, 0.5);
    
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    
    --border-primary: #E5E7EB;
    --border-secondary: #D1D5DB;
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-full: 9999px;
    
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 30px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-elevated: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-dropdown: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-ios: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-ios-elevated: 0 4px 14px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-ios-floating: 0 8px 30px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.08);
    
    --radius-elevated: 12px;
    --radius-dropdown: 16px;
    --radius-ios: 14px;
    --radius-ios-large: 20px;

    /* Backward compatibility aliases for templates */
    --card-bg: var(--bg-surface);
    --bg: var(--bg-secondary);
    --border: var(--border-primary);
    --radius: var(--radius-md);
    --hover: var(--bg-tertiary);
    --text: var(--text-primary);
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #60A5FA;
    --primary-dark: #3B82F6;
    --secondary: #9CA3AF;
    --success: #34D399;
    --warning: #FBBF24;
    --error: #F87171;
    --info: #22D3EE;

    --bg-primary: #111827;
    --bg-secondary: #1F2937;
    --bg-tertiary: #374151;
    --bg-surface: #1F2937;
    --bg-overlay: rgba(0, 0, 0, 0.7);

    --text-primary: #F9FAFB;
    --text-secondary: #D1D5DB;
    --text-muted: #9CA3AF;

    --border-primary: #374151;
    --border-secondary: #4B5563;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-elevated: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-ios: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-ios-elevated: 0 4px 14px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);

    /* Backward compatibility aliases */
    --card-bg: var(--bg-surface);
    --bg: var(--bg-secondary);
    --border: var(--border-primary);
    --hover: var(--bg-tertiary);
    --text: var(--text-primary);
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 6px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    opacity: 0.7;
}

.theme-toggle-btn:hover {
    opacity: 1;
    background: var(--bg-tertiary);
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Layout Container */
.matrix-container {
    display: block;
    min-height: 100vh;
    position: relative;
    /* CSS Custom Properties for maintainable sizing */
    --sidebar-width-expanded: 240px;
    --sidebar-width-collapsed: 80px;
    --sidebar-transition-duration: 0.25s;
}

/* Sidebar Base Styles */
.matrix-container .matrix-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width-expanded);
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-primary);
    padding: var(--space-lg);
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: width var(--sidebar-transition-duration) ease,
                padding var(--sidebar-transition-duration) ease;
}

/* Hide scrollbar for webkit browsers */
.matrix-container .matrix-sidebar::-webkit-scrollbar {
    display: none;
}

/* Collapsed Sidebar State - Clean modern design */
.matrix-container .matrix-sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    padding: var(--space-lg) var(--space-sm);
}

/* Main Content Area */
.matrix-container .matrix-main {
    margin-left: var(--sidebar-width-expanded);
    padding: var(--space-xl);
    overflow-x: auto;
    overflow-y: visible;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width-expanded));
    transition: margin-left var(--sidebar-transition-duration) ease,
                width var(--sidebar-transition-duration) ease;
}

/* Main Content when Sidebar is Collapsed */
.matrix-container .matrix-sidebar.collapsed + .matrix-main {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

/* Sidebar Toggle Button - Subtle but visible */
.matrix-container .matrix-sidebar .sidebar-toggle-btn {
    position: fixed;
    top: var(--space-lg);
    left: calc(var(--sidebar-width-expanded) - 16px);
    width: 24px;
    height: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1010;
    opacity: 0.8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.matrix-container .matrix-sidebar .sidebar-toggle-btn:hover {
    background: var(--bg-secondary);
    opacity: 1;
    border-color: var(--border-secondary);
}

/* Toggle Icon - Light blue color */
.matrix-container .matrix-sidebar .toggle-icon {
    font-size: 12px;
    color: var(--primary);
    transition: transform var(--sidebar-transition-duration) ease;
    line-height: 1;
    font-weight: bold;
}

/* Rotate arrow when collapsed */
.matrix-container .matrix-sidebar.collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* Adjust button position when collapsed */
.matrix-container .matrix-sidebar.collapsed .sidebar-toggle-btn {
    left: calc(var(--sidebar-width-collapsed) - 16px);
}

/* Hide text elements when collapsed - Higher specificity */
.matrix-container .matrix-sidebar.collapsed .sidebar-text,
.matrix-container .matrix-sidebar.collapsed .user-time,
.matrix-container .matrix-sidebar.collapsed .logout-text {
    display: none;
}

/* Center logo in collapsed state */
.matrix-container .matrix-sidebar.collapsed .sidebar-header {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
}

.matrix-container .matrix-sidebar.collapsed .sidebar-header h2 {
    justify-content: center;
}

/* Reduce navigation spacing when collapsed */
.matrix-container .matrix-sidebar.collapsed .matrix-nav {
    margin-top: var(--space-md) !important;
}

/* Modern collapsed navigation - like Slack/Discord */
.matrix-container .matrix-sidebar.collapsed .nav-item {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-sm);
    margin: var(--space-xs) 0;
    border-radius: var(--radius-md);
    min-height: 48px;
    position: relative;
}

/* Tooltip for collapsed nav items */
.matrix-container .matrix-sidebar.collapsed .nav-item::before {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + var(--space-md));
    top: 50%;
    transform: translateY(-50%);
    background: var(--text-primary);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1020;
    pointer-events: none;
}

.matrix-container .matrix-sidebar.collapsed .nav-item::after {
    content: '';
    position: absolute;
    left: calc(100% + var(--space-xs));
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 4px solid var(--text-primary);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1020;
}

.matrix-container .matrix-sidebar.collapsed .nav-item:hover::before,
.matrix-container .matrix-sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Show mini labels in collapsed state */
.matrix-container .matrix-sidebar.collapsed .nav-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Enhanced hover effects for collapsed items */
.matrix-container .matrix-sidebar.collapsed .nav-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(2px);
}

.matrix-container .matrix-sidebar.collapsed .nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--primary);
    box-shadow: inset 3px 0 0 var(--primary);
}

.matrix-container .matrix-sidebar.collapsed .nav-item.active .nav-label {
    color: var(--primary);
    font-weight: 600;
}

.matrix-container .matrix-sidebar.collapsed .nav-item.active .nav-icon {
    color: var(--primary);
}

/* Make icons larger when collapsed for better visibility */
.matrix-container .matrix-sidebar.collapsed .nav-icon {
    font-size: 20px;
}

/* User Section Styles */
.user-section {
    display: flex;
    flex-direction: column;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-avatar {
    font-size: var(--font-size-lg);
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.username {
    font-weight: 500;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.user-time {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

/* User Profile Link */
.user-profile-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
    flex: 1;
}

.user-profile-link:hover {
    background: var(--bg-tertiary);
}

/* Role Badges */
.user-role {
    margin-top: 2px;
}

.role-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #78350f;
}

.role-user {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.role-viewer {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* User Actions (session timer + logout) */
.user-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-secondary);
}

.logout-form {
    margin: 0;
    flex-shrink: 0;
}

/* Compact Logout Button */
.logout-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-xs);
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
    transform: translateY(-1px);
}

.logout-icon {
    font-size: 12px;
}

/* Modern collapsed user section */
.matrix-container .matrix-sidebar.collapsed .user-section {
    align-items: center;
    text-align: center;
}

.matrix-container .matrix-sidebar.collapsed .user-info {
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    width: 100%;
}

.matrix-container .matrix-sidebar.collapsed .user-avatar {
    font-size: 24px;
    margin-bottom: var(--space-xs);
}

/* Show username in collapsed state */
.matrix-container .matrix-sidebar.collapsed .username {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matrix-container .matrix-sidebar.collapsed .logout-btn {
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    width: 32px;
    height: 32px;
    justify-content: center;
    margin-top: var(--space-sm);
}

.matrix-header {
    background: linear-gradient(135deg, var(--bg-surface) 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border-primary);
    padding: var(--space-lg) var(--space-xl);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.header-main {
    flex: 1;
}

/* Trend Indicators */
.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    margin-left: var(--space-xs);
}

.trend-up {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.trend-down {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.trend-neutral {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

.trend-arrow {
    font-size: 0.65rem;
}

.system-time {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-family: 'Courier New', Consolas, monospace;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

.system-time .time-icon {
    font-size: 1rem;
}

.system-time .time-value {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 70px;
}

.system-time .time-zone {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    padding: 2px 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.page-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.page-icon {
    font-size: 1.5rem;
    opacity: 0.9;
}

.title-text {
    line-height: 1.2;
}

.breadcrumbs {
    margin-top: var(--space-sm);
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--font-size-sm);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.breadcrumb-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.breadcrumb-link:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-weight: 300;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
}


/* Navigation */
.matrix-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Nav Groups - Collapsible Sections */
.nav-group {
    margin-bottom: var(--space-xs);
}

.nav-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.nav-group-header:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.nav-group-header .nav-icon {
    font-size: var(--font-size-sm);
}

.nav-group-header .nav-chevron {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
}

.nav-group.collapsed .nav-group-header .nav-chevron {
    transform: rotate(-90deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: var(--space-sm);
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.2s;
}

.nav-group.collapsed .nav-group-items {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    padding-top: 0;
    padding-bottom: 0;
}

.nav-group.has-active .nav-group-header {
    color: var(--primary);
}

/* Collapsed sidebar: hide group headers, show only icons */
.matrix-sidebar.collapsed .nav-group-header {
    display: none;
}

.matrix-sidebar.collapsed .nav-group-items {
    padding-left: 0;
    max-height: none;
    opacity: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-icon {
    font-size: var(--font-size-lg);
}

.nav-label {
    font-weight: 500;
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-lg);
}

.card-title {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
}

.stat-number {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* iOS-Inspired Elevated Form Styles */
.form-input-elevated {
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(135deg, #ffffff 0%, #fbfcfd 100%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-ios);
    font-size: var(--font-size-base);
    font-weight: 400;
    letter-spacing: -0.01em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-ios);
}

.form-input-elevated:hover {
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: var(--shadow-ios-elevated);
}

.form-input-elevated:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08), var(--shadow-ios-elevated);
}

/* Floating Label Input Group */
.input-group-floating {
    position: relative;
    margin-bottom: var(--space-lg);
}

.input-group-floating .form-input-elevated {
    padding-top: 18px;
    padding-bottom: 14px;
}

.floating-label {
    position: absolute;
    top: -8px;
    left: 14px;
    background: #ffffff;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    z-index: 1;
}

.input-group-floating .form-input-elevated:focus + .floating-label {
    color: var(--primary);
}

/* Date Input Specific Adjustments */
.date-inputs .input-group-floating {
    margin-bottom: 0;
}

.date-inputs .floating-label {
    background: linear-gradient(135deg, #ffffff 0%, #fbfcfd 100%);
}

/* Form Group Alignment Fix */
.form-group {
    margin-bottom: var(--space-lg);
    position: relative;
    overflow: visible;
}

.form-group .form-label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--text-primary);
}


/* Better form flex alignment */
.flex[style*="align-items: end"] .form-group {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-secondary);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

/* iOS-Inspired Elevated Button Styles */
.btn-elevated {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-ios);
    font-weight: 500;
    letter-spacing: -0.01em;
    box-shadow: var(--shadow-ios);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.btn-elevated::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transition: left 0.6s ease;
}

.btn-elevated:hover::before {
    left: 100%;
}

.btn-elevated:hover {
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: var(--shadow-ios-elevated);
    transform: translateY(-1px);
}

.btn-elevated:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-ios);
    transition: transform 0.1s ease;
}

.btn-elevated-primary {
    background: linear-gradient(135deg, #4f83f7 0%, #396ce3 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-ios);
    box-shadow: var(--shadow-ios-elevated);
}

.btn-elevated-primary:hover {
    background: linear-gradient(135deg, #396ce3 0%, #2563eb 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-ios-floating);
}

.btn-elevated-primary:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-elevated-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-ios-elevated);
}

.btn-elevated-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-ios-floating);
}

.btn-elevated-success:active {
    transform: translateY(-1px) scale(0.98);
}

/* Tables */
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.data-table tr:hover {
    background: var(--bg-secondary);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-inactive {
    background: rgba(107, 114, 128, 0.1);
    color: var(--secondary);
}

/* Notifications */
.notification {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.notification-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.notification-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.notification-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.notification-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid var(--info);
    color: var(--info);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.notification-close {
    background: none;
    border: none;
    font-size: var(--font-size-lg);
    cursor: pointer;
    opacity: 0.7;
}

.notification-close:hover {
    opacity: 1;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: var(--space-xs);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    gap: var(--space-md);
}

.search-box {
    flex: 1;
    max-width: 300px;
}

.control-buttons {
    display: flex;
    gap: var(--space-sm);
}

/* Responsive */
@media (max-width: 768px) {
    .matrix-container {
        flex-direction: column;
    }
    
    .matrix-sidebar {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: none;
    }
}

/* Page Content */
.page-content {
    margin-top: var(--space-lg);
}

/* iOS-Inspired Elevated Card Styles */
.card-elevated {
    background: linear-gradient(135deg, #ffffff 0%, #fbfcfd 100%);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-ios-large);
    padding: var(--space-xl);
    box-shadow: var(--shadow-ios);
    transition: box-shadow 0.2s ease;
    position: relative;
    overflow: visible;
}

.card-elevated::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
}

/* Keyframe Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Animation Classes */
.animate-slide-down {
    animation: slideDown 0.2s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.2s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.font-mono { font-family: 'Courier New', monospace; }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.font-bold { font-weight: 700; }
.font-weight-500 { font-weight: 500; }
.opacity-50 { opacity: 0.5; }
.opacity-70 { opacity: 0.7; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--space-lg); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-sm); }
.gap-4 { gap: var(--space-lg); }
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Additional Button Variants */
.btn-info {
    background: var(--info);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

/* Ensure proper spacing */
body, html {
    height: 100%;
    font-size: 14px;
}

/* Fix layout issues */
.matrix-main {
    min-height: 100vh;
}

/* ========================================
   CLICKABLE STAT CARDS - Dashboard Navigation
   ======================================== */

/* Link reset for stat cards used as anchors */
a.stat-card {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Clickable indicator - subtle arrow on hover */
.stat-card.clickable {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card.clickable::after {
    content: '→';
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    opacity: 0;
    transform: translateX(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.stat-card.clickable:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.stat-card.clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* FTD Hero Card - Green gradient for deposits */
.ftd-hero-card {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25);
}

.ftd-hero-card::before {
    display: none;
}

.ftd-hero-card .stat-number {
    color: white !important;
}

.ftd-hero-card .stat-label {
    color: rgba(255, 255, 255, 0.9) !important;
}

.ftd-hero-card:hover {
    box-shadow: 0 12px 35px rgba(16, 185, 129, 0.35);
}

/* Invalid Leads Card - Red accent */
.stat-card.invalid-leads::before {
    background: var(--error) !important;
}

.stat-card.invalid-leads .stat-number {
    color: var(--error);
}

/* Valid Leads Card - Success/teal accent */
.stat-card.valid-leads::before {
    background: var(--info) !important;
}

.stat-card.valid-leads .stat-number {
    color: var(--info);
}

/* Duplicates Card - Warning/orange accent */
.stat-card.duplicates::before {
    background: var(--warning) !important;
}

.stat-card.duplicates .stat-number {
    color: var(--warning);
}

/* API Rejected Card - Error accent */
.stat-card.api-rejected::before {
    background: var(--error) !important;
}

.stat-card.api-rejected .stat-number {
    color: var(--error);
}

/* Success Card - Green accent */
.stat-card.success::before {
    background: var(--success) !important;
}

.stat-card.success .stat-number {
    color: var(--success);
}

/* Stat card sub-info (percentage display) */
.stat-subinfo {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* ========================================
   DASHBOARD SECTION STYLES
   ======================================== */

/* Section Headers */
.dashboard-section-header {
    margin: var(--space-lg) 0 var(--space-md) 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.dashboard-section-header .date-hint {
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    margin-left: 8px;
    color: var(--text-muted);
}

/* Status indicator dot */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-dot.success { background: var(--success); }
.status-dot.warning { background: var(--warning); }
.status-dot.error { background: var(--error); }
.status-dot.info { background: var(--info); }
.status-dot.muted { background: var(--text-muted); }

/* Sub-stat tags (used in dashboard breakdowns) */
.sub-stat-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Skeleton loading states */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-card {
    height: 120px;
}

.skeleton-row {
    height: 48px;
    margin-bottom: var(--space-xs);
}

/* ========================================
   MOBILE RESPONSIVE STYLES - Enhanced 2025
   ======================================== */

/* Mobile Hamburger Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 44px;
    height: 44px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

/* Sidebar Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Tablet Styles (768px - 1024px) */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .controls-bar {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .search-box {
        min-width: 200px;
        max-width: none;
    }
}

/* Mobile Styles (max-width: 768px) */
@media (max-width: 768px) {
    /* Show hamburger menu */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide sidebar by default, show with overlay */
    .matrix-sidebar {
        position: fixed !important;
        top: 0;
        left: -280px !important;
        width: 280px !important;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
    }

    .matrix-sidebar.open {
        left: 0 !important;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Main content full width on mobile */
    .matrix-main {
        margin-left: 0 !important;
        padding: var(--space-md) !important;
        padding-top: 4rem !important; /* Space for hamburger button */
        width: 100% !important;
    }

    /* Stats grid - 1 column on mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-md);
    }

    /* Controls bar - stack vertically */
    .controls-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: var(--space-md);
    }

    .search-box {
        max-width: none !important;
        width: 100%;
    }

    .filter-buttons {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    /* Tables - horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
        font-size: var(--font-size-sm);
    }

    th, td {
        padding: var(--space-sm) !important;
        white-space: nowrap;
    }

    /* Buttons - full width or better spacing */
    .btn {
        font-size: var(--font-size-sm);
        padding: var(--space-sm) var(--space-md);
    }

    .action-buttons {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .action-buttons .btn {
        width: 100%;
    }

    /* Form elements */
    .form-group {
        margin-bottom: var(--space-md);
    }

    .form-control, select, input[type="text"], input[type="email"], input[type="password"] {
        font-size: 16px !important; /* Prevent iOS zoom */
        width: 100%;
    }

    /* Page header */
    .page-header h1 {
        font-size: var(--font-size-xl);
    }

    /* Cards */
    .card {
        padding: var(--space-md);
    }

    .card-header h2 {
        font-size: var(--font-size-lg);
    }

    /* Hide sidebar toggle button (use hamburger instead) */
    .sidebar-toggle-btn {
        display: none !important;
    }

    /* Navigation items */
    .nav-item {
        padding: var(--space-md);
        font-size: var(--font-size-base);
    }

    /* User section at bottom */
    .user-section {
        padding: var(--space-md);
    }

    /* Responsive padding */
    .container {
        padding: var(--space-md);
    }
}

/* Small Mobile Styles (max-width: 480px) */
@media (max-width: 480px) {
    .matrix-main {
        padding: var(--space-sm) !important;
        padding-top: 3.5rem !important;
    }

    .mobile-menu-btn {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .stats-grid {
        gap: var(--space-sm);
    }

    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }

    .stat-label {
        font-size: var(--font-size-xs);
    }

    .page-header h1 {
        font-size: var(--font-size-lg);
    }

    .btn {
        font-size: var(--font-size-xs);
        padding: var(--space-xs) var(--space-sm);
    }

    table {
        font-size: var(--font-size-xs);
    }

    th, td {
        padding: var(--space-xs) !important;
    }

    .filter-buttons .btn {
        font-size: var(--font-size-xs);
        padding: var(--space-xs) var(--space-sm);
    }
}