/* ============================================
   Fafafa Proxy Pool - Modern Design System
   ============================================ */

/* CSS Variables - Design Tokens */
:root {
    /* Primary Colors - Deep Blue Theme */
    --color-primary: #2563eb;
    --color-primary-dark: #1e40af;
    --color-primary-light: #3b82f6;
    --color-primary-glow: rgba(37, 99, 235, 0.15);
    
    /* Accent Colors */
    --color-accent: #8b5cf6;
    --color-accent-light: #a78bfa;
    
    /* Status Colors */
    --color-success: #10b981;
    --color-success-light: #34d399;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #06b6d4;
    
    /* Neutral Colors */
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;
    
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.3);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   Global Styles & Animations
   ============================================ */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-feature-settings: "kern" 1, "liga" 1;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Selection */
::selection {
    background-color: var(--color-primary-glow);
    color: var(--color-primary-dark);
}

/* ============================================
   Card Components
   ============================================ */

.dashboard-card {
    position: relative;
    transition: all var(--transition-base);
    overflow: hidden;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-base);
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.dashboard-card:hover::before {
    transform: scaleX(1);
}

.stat-card {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Table Enhancements
   ============================================ */

.table-row {
    transition: all var(--transition-fast);
    position: relative;
}

.table-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-primary);
    transform: scaleY(0);
    transition: transform var(--transition-base);
}

.table-row:hover {
    background-color: var(--color-gray-50);
    transform: none;
}

.table-row:hover::before {
    transform: scaleY(1);
}

/* ============================================
   Button Enhancements
   ============================================ */

.btn-primary {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width var(--transition-slow), height var(--transition-slow);
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* ============================================
   Modal Animations
   ============================================ */

.modal-backdrop {
    animation: fadeIn var(--transition-base);
}

.modal-content {
    animation: slideUp var(--transition-base);
}

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

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

/* ============================================
   Status Badges
   ============================================ */

.status-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: all var(--transition-base);
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-badge:hover {
    transform: scale(1.05);
}

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

/* ============================================
   Loading States
   ============================================ */

.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--color-primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 25%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ============================================
   Form Enhancements
   ============================================ */

.form-input {
    transition: all var(--transition-base);
    position: relative;
}

.form-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.form-input:focus-within {
    border-color: var(--color-primary);
}

/* ============================================
   Chart Container
   ============================================ */

.chart-container {
    position: relative;
    height: 300px;
    padding: var(--space-md);
}

.chart-container canvas {
    animation: fadeIn var(--transition-slow);
}

/* ============================================
   Navigation Enhancements
   ============================================ */

.nav-link {
    position: relative;
    transition: all var(--transition-base);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-base);
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
}

/* ============================================
   Gradient Backgrounds
   ============================================ */

.gradient-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
}

.gradient-success {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-light) 100%);
}

.gradient-mesh {
    background: 
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(37, 99, 235, 0.1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
}

/* ============================================
   Utility Classes
   ============================================ */

.hover-lift {
    transition: transform var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-2px);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow);
}

.fade-in {
    animation: fadeIn var(--transition-base);
}

.slide-in-right {
    animation: slideInRight var(--transition-base);
}

/* CSP-friendly Alpine cloak (avoid inline style="display:none") */
[x-cloak] {
    display: none !important;
}

/* Login page background/animation (moved from inline <style>) */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.gradient-animated {
    background: linear-gradient(-45deg, #2563eb, #3b82f6, #8b5cf6, #a78bfa);
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

.glass-morphism {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.floating-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.6;
    animation: float 6s ease-in-out infinite;
}

.orb-delay-0 { animation-delay: 0s; }
.orb-delay-2 { animation-delay: 2s; }
.orb-delay-4 { animation-delay: 4s; }

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Responsive Utilities
   ============================================ */

@media (max-width: 640px) {
    .stat-card {
        padding: var(--space-md);
    }
    
    .chart-container {
        height: 250px;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .no-print {
        display: none !important;
    }
    
    .dashboard-card,
    .stat-card {
        box-shadow: none !important;
        border: 1px solid var(--color-gray-300);
    }
}

/* ============================================
   Sidebar Layout - Left Navigation
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 16rem;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 0.5rem;
    transition: all var(--transition-base);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-link svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
    opacity: 0;
    transition: opacity var(--transition-base);
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar-open {
        transform: translateX(0);
    }
    
    .sidebar-overlay-show {
        display: block;
        opacity: 1;
    }
}

/* NOTE: Old dashboard layout used a fixed sidebar and added global body padding.
   The redesigned dashboard uses a flex layout, so do NOT offset body. */
/* @media (min-width: 1024px) {
    body {
        padding-left: 16rem;
    }
} */

/* ============================================
   Dashboard helper classes (no Tailwind @apply)
   ============================================ */

.sidebar-link-active {
    background-color: #eef2ff; /* indigo-50 */
    color: #4f46e5; /* indigo-600 */
    border-right: 2px solid #4f46e5;
}

.sidebar-link-inactive {
    color: #64748b; /* slate-500 */
}

.sidebar-link-inactive:hover {
    background-color: #f8fafc; /* slate-50 */
    color: #0f172a; /* slate-900 */
}

.card-modern {
    background: #ffffff;
    border: 1px solid #f1f5f9; /* slate-100 */
    border-radius: 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.card-modern:hover {
    border-color: #e0e7ff; /* indigo-100 */
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

.grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.grid-modern--sub {
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
}

.card-exit,
.card-sub {
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 0.75rem;
    padding: 1rem;
    transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
    content-visibility: auto;
}

.card-exit:hover,
.card-sub:hover {
    border-color: #e0e7ff;
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

/* Give the browser an intrinsic height hint for virtual rendering */
.card-exit { contain-intrinsic-size: 144px; }
.card-sub { contain-intrinsic-size: 176px; }

.dot-pulse {
    position: relative;
    display: inline-flex;
    height: 0.5rem;
    width: 0.5rem;
    border-radius: 9999px;
}

.dot-pulse::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: inherit;
    opacity: 0.75;
    animation: dot-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes dot-ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ============================================
   System Status Bar
   ============================================ */

.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 36px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 50;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    transition: height 0.3s ease;
}

.status-bar.expanded {
    height: auto;
    min-height: 36px;
    max-height: 200px;
}

@media (min-width: 1024px) {
    .status-bar {
        left: 16rem;
    }
}

.status-bar-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-bar-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
    cursor: default;
}

.status-bar-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.status-bar-item.clickable {
    cursor: pointer;
}

.status-bar-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.status-bar-item .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.idle {
    background: #6b7280;
}

.status-dot.running {
    background: #10b981;
    animation: status-pulse 1.5s ease-in-out infinite;
}

.status-dot.error {
    background: #ef4444;
}

@keyframes status-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

.status-bar-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.status-bar-progress {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.status-bar-progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.status-bar-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
}

.status-bar-expand-btn {
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-bar-expand-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.status-bar-expand-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.status-bar.expanded .status-bar-expand-btn svg {
    transform: rotate(180deg);
}

/* Status bar detail panel */
.status-bar-details {
    display: none;
    position: absolute;
    bottom: 36px;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    animation: slideUp 0.2s ease;
}

.status-bar.expanded .status-bar-details {
    display: block;
}

.status-bar-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.status-bar-detail-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.status-bar-detail-card-title {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.5rem;
}

.status-bar-detail-card-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.status-bar-detail-card-sub {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

/* Adjust layout when status bar is present */
body.has-status-bar {
    /* For non-flex layouts */
    padding-bottom: 36px;
}

/* For flex layouts with h-screen (like dashboard pages) */
body.has-status-bar.h-screen {
    padding-bottom: 0;
    height: calc(100vh - 36px);
}

/* Ensure scrollable content areas have bottom padding */
body.has-status-bar main {
    padding-bottom: 1rem;
}

body.has-status-bar .overflow-y-auto {
    padding-bottom: 36px;
}
