/**
 * CRMVibe Design System CSS
 * Modern glassmorphism + dark/light theme support
 */

/* ==========================================================================
   CSS CUSTOM PROPERTIES (Theme Variables)
   ========================================================================== */

:root {
    /* Light theme (default) */
    --surface-0: #f8fafc;
    --surface-1: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --border-subtle: #e2e8f0;
    --border-default: #cbd5e1;
    --border-strong: #94a3b8;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #7c3aed;
    --accent-light: #8b5cf6;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --danger-muted: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-muted: rgba(245, 158, 11, 0.15);
    --shadow-color: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.8);
}

.dark {
    --surface-0: #0a0a0f;
    --surface-1: #12121a;
    --surface-2: #1a1a24;
    --surface-3: #24242e;
    --border-subtle: #2a2a36;
    --border-default: #3a3a48;
    --border-strong: #4a4a58;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #7c3aed;
    --accent-light: #8b5cf6;
    --accent-glow: rgba(124, 58, 237, 0.35);
    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.2);
    --danger: #ef4444;
    --danger-muted: rgba(239, 68, 68, 0.2);
    --warning: #f59e0b;
    --warning-muted: rgba(245, 158, 11, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.4);
    --glass-bg: rgba(18, 18, 26, 0.8);
}

/* ==========================================================================
   BASE STYLES
   ========================================================================== */

body {
    background-color: var(--surface-0);
    color: var(--text-primary);
}

/* ==========================================================================
   GLASSMORPHISM UTILITIES
   ========================================================================== */

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.glass-strong {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

/* ==========================================================================
   CARD STYLES
   ========================================================================== */

.card-base {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -2px var(--shadow-color);
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    box-shadow: 0 8px 32px -8px var(--shadow-color);
}

.card-hover {
    transition: transform 200ms ease-out, box-shadow 200ms ease-out, border-color 200ms ease-out;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -12px var(--shadow-color);
    border-color: var(--border-default);
}

.card-glow:hover {
    box-shadow: 0 20px 40px -12px var(--accent-glow);
}

/* ==========================================================================
   SKELETON LOADING
   ========================================================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3) 50%,
        var(--surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

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

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

/* Fade in up (for staggered lists) */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fade-in-up 300ms ease-out forwards;
}

.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

/* Glow pulse */
@keyframes glow-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.glow-pulse {
    animation: glow-pulse 2s ease-in-out infinite;
}

/* Scale in */
@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scale-in 200ms ease-out forwards;
}

/* Number counter pulse */
@keyframes number-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.number-updated {
    animation: number-pulse 300ms ease-out;
}

/* ==========================================================================
   MICRO-INTERACTIONS
   ========================================================================== */

/* Button press */
.btn-press:active {
    transform: scale(0.97);
}

/* Link underline animation */
.link-hover {
    position: relative;
}

.link-hover::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 200ms ease-out;
}

.link-hover:hover::after {
    width: 100%;
}

/* Status dot with pulse */
.status-dot {
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: inherit;
    animation: status-pulse 2s ease-out infinite;
}

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

/* ==========================================================================
   GRADIENT UTILITIES
   ========================================================================== */

.gradient-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
}

.gradient-success {
    background: linear-gradient(135deg, var(--success) 0%, #10b981 100%);
}

.gradient-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #f97316 100%);
}

.gradient-mesh {
    background:
        radial-gradient(at 40% 20%, rgba(124, 58, 237, 0.15) 0px, transparent 50%),
        radial-gradient(at 80% 80%, rgba(59, 130, 246, 0.1) 0px, transparent 50%);
}

/* ==========================================================================
   HIDE SCROLLBAR
   ========================================================================== */

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ==========================================================================
   CUSTOM SCROLLBAR (dark theme friendly)
   ========================================================================== */

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ==========================================================================
   FOCUS STATES
   ========================================================================== */

.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.focus-ring:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ==========================================================================
   THEME TRANSITION
   ========================================================================== */

html.transitioning,
html.transitioning *,
html.transitioning *::before,
html.transitioning *::after {
    transition: background-color 300ms ease-out, border-color 300ms ease-out, color 200ms ease-out !important;
}

/* ==========================================================================
   SANITIZATION DIALOG READABILITY
   ========================================================================== */

.dialog-readable-panel {
    white-space: normal;
    line-height: 1.7;
}

.dialog-row {
    margin: 0 0 0.35rem;
    padding: 0.35rem 0.55rem 0.35rem 0.8rem;
    border-left: 2px solid var(--border-subtle);
    border-radius: 0.5rem;
    background: linear-gradient(90deg, var(--surface-2) 0%, transparent 72%);
    transition: border-color 160ms ease-out, background 160ms ease-out;
}

.dialog-row:last-child {
    margin-bottom: 0;
}

.dialog-row-empty {
    border-left-style: dashed;
    opacity: 0.45;
}

.dialog-row:hover {
    border-left-color: var(--accent);
    background: linear-gradient(90deg, rgba(124, 58, 237, 0.08) 0%, transparent 78%);
}

.dark .dialog-row {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0%, transparent 72%);
}

.dark .dialog-row:hover {
    background: linear-gradient(90deg, rgba(124, 58, 237, 0.18) 0%, transparent 78%);
}

/* Diff grid: paired 2-column layout */
.diff-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.5rem;
    position: relative;
}

/* Central column divider */
.diff-grid::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: var(--border-subtle);
    pointer-events: none;
}

/* Paired hover (JS adds this class to both cells in a row) */
.dialog-row-hover {
    border-left-color: var(--accent);
    background: linear-gradient(90deg, rgba(124, 58, 237, 0.08) 0%, transparent 78%);
}

.dark .dialog-row-hover {
    background: linear-gradient(90deg, rgba(124, 58, 237, 0.18) 0%, transparent 78%);
}
