/* ==========================================================================
   ELITE DRAWDOWN MONITOR CSS
   Glassmorphism, SVG Arc Gauges, Real-Time Alerts
   ========================================================================== */

/* Layout & Globals */
.dd-container { margin-left: 20px; padding: 32px; min-height: 100vh; color: #ffffff; font-family: 'Inter', sans-serif; display: flex; flex-direction: column; gap: 24px; position: relative; }
.dd-layout-2col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; }

/* Utilities */
.hidden { display: none !important; opacity: 0; pointer-events: none; }
.m-0 { margin: 0; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; } .mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; } .pt-16 { padding-top: 16px; } .border-top { border-top: 1px solid rgba(255,255,255,0.1); }
.text-xs { font-size: 0.75rem; } .text-sm { font-size: 0.85rem; } .text-muted { color: rgba(255,255,255,0.6); } .w-full { width: 100%; } .text-center { text-align: center; } .text-right { text-align: right; }
.uppercase { text-transform: uppercase; } .letter-spacing { letter-spacing: 1px; } .font-bold { font-weight: 700; } .tabular-nums { font-variant-numeric: tabular-nums; }
.flex-between { display: flex; justify-content: space-between; align-items: center; } .flex-align-center { display: flex; align-items: center; } .gap-8 { gap: 8px; } .gap-16 { gap: 16px; }

/* Palette */
.text-purple { color: #c084fc; } .text-cyan { color: #06b6d4; } .text-gold { color: #fbbf24; } .text-red { color: #ef5350; } .text-green { color: #22c55e; } .text-white { color: #ffffff; } .text-orange { color: #f97316; }
.bg-red { background: #ef5350; } .bg-green { background: #22c55e; } .bg-orange { background: #f97316; } .bg-gold { background: #fbbf24; } .bg-cyan { background: #06b6d4; } .bg-white { background: #ffffff; }

/* Animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulseDanger { 0% { box-shadow: 0 0 0 0 rgba(239,83,80,0.6); } 70% { box-shadow: 0 0 0 25px rgba(239,83,80,0); } 100% { box-shadow: 0 0 0 0 rgba(239,83,80,0); } }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.fade-in { animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.pulse { animation: pulseDanger 2s infinite; border-radius: 8px; }
.spinning { animation: spin 1s linear infinite; }

/* Cards & Buttons */
.dd-card { background: rgba(255,255,255,0.03); backdrop-filter: blur(24px) saturate(180%); border: 1px solid rgba(255,255,255,0.08); border-radius: 24px; padding: 24px; box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05); transition: all 0.4s; }

.dd-btn { padding: 10px 20px; border-radius: 12px; font-weight: 700; font-size: 0.85rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.3s; border: none; text-transform: uppercase; font-family: inherit; }
.dd-btn--primary { background: linear-gradient(135deg, #a855f7, #7e22ce); color: white; box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3); }
.dd-btn--primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5); }
.dd-btn--secondary { background: rgba(255,255,255,0.05); color: white; border: 1px solid rgba(255,255,255,0.1); }
.dd-btn--secondary:hover { background: rgba(255,255,255,0.1); border-color: #c084fc; color: #c084fc; }
.dd-btn--danger { background: linear-gradient(135deg, #ef5350, #c62828); color: white; box-shadow: 0 4px 15px rgba(239,83,80,0.3); border-radius: 8px; }

.dd-input, .dd-select { width: 100%; padding: 10px 14px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); color: white; border-radius: 8px; transition: 0.3s; font-family: inherit; font-size: 0.85rem; outline: none; }
.dd-input:focus, .dd-select:focus { border-color: #c084fc; box-shadow: 0 0 0 2px rgba(192,132,252,0.2); }
.dd-form-group { margin-bottom: 16px; }
.dd-form-group label { display: block; margin-bottom: 8px; font-size: 0.85rem; color: rgba(255,255,255,0.8); font-weight: 600; }
.dd-form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Switch Toggle */
.dd-switch { position: relative; display: inline-block; width: 42px; height: 22px; flex-shrink: 0; }
.dd-switch input { opacity: 0; width: 0; height: 0; }
.dd-slider-toggle { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 24px; }
.dd-slider-toggle:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
.dd-switch input:checked + .dd-slider-toggle { background-color: #a855f7; }
.dd-switch input:checked + .dd-slider-toggle:before { transform: translateX(20px); }

/* Danger Banner */
.dd-danger { background: radial-gradient(circle at left, rgba(239,83,80,0.2) 0%, rgba(0,0,0,0.8) 100%); border: 2px solid #ef5350; border-radius: 16px; padding: 24px 32px; box-shadow: 0 0 40px rgba(239,83,80,0.3), inset 0 0 20px rgba(239,83,80,0.2); animation: slideDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; position: relative; z-index: 100; margin-bottom: 8px; }
.dd-danger-icon { font-size: 2.5rem; color: #ef5350; display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; background: rgba(239,83,80,0.1); border-radius: 50%; }

/* Header Elements */
.dd-header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 24px; }
.dd-header__title { font-size: 2.2rem; font-weight: 800; margin: 0 0 8px 0; letter-spacing: 1px; text-transform: uppercase; }
.dd-header__subtitle { color: #c084fc; margin: 0; font-size: 1rem; }
.dd-header__stats { display: flex; gap: 24px; }
.dd-stat-card { text-align: center; }
.dd-stat-val { display: block; font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.dd-stat-label { font-size: 0.75rem; color: rgba(255,255,255,0.5); text-transform: uppercase; }

/* Overview Strip */
.dd-overview { display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.03); padding: 16px 24px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); }
.dd-overview-item { font-size: 0.9rem; color: rgba(255,255,255,0.6); display: flex; gap: 8px; align-items: center; }

/* Challenge Cards Grid */
.dd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 24px; }
.dd-c-card { display: flex; flex-direction: column; padding: 24px; position: relative; overflow: hidden; }
.dd-c-card.border-warn { border-color: rgba(251,191,36,0.5); box-shadow: 0 0 20px rgba(251,191,36,0.1); }
.dd-c-card.border-dang { border-color: rgba(239,83,80,0.6); box-shadow: 0 0 25px rgba(239,83,80,0.2); }

.c-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.c-title { font-size: 1.1rem; font-weight: 800; margin: 0 0 4px 0; }
.c-size { font-size: 0.8rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 1px; }
.c-bal { font-size: 1.8rem; font-weight: 800; tabular-nums: tabular-nums; line-height: 1; }

.c-gauges-row { display: flex; gap: 16px; margin-bottom: 24px; justify-content: center; }

/* Arc Gauge CSS */
.dd-gauge-wrap { position: relative; width: 140px; height: 80px; overflow: hidden; display: flex; flex-direction: column; align-items: center; }
.dd-arc-svg { width: 140px; height: 140px; position: absolute; top: 0; left: 0; }
.arc-bg { fill: none; stroke: rgba(255,255,255,0.1); stroke-width: 12; stroke-linecap: round; }
.arc-fill { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 198; stroke-dashoffset: 198; transition: stroke-dashoffset 1s cubic-bezier(0.16,1,0.3,1); }
/* Arc gradients defined inline in JS */

.gauge-needle-group { transform-origin: 70px 70px; transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.g-val-txt { position: absolute; bottom: 5px; font-weight: 800; font-size: 1.1rem; }
.g-lbl-txt { position: absolute; bottom: -20px; font-size: 0.7rem; color: rgba(255,255,255,0.5); text-transform: uppercase; white-space: nowrap; }

.c-metrics { display: flex; justify-content: space-between; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 16px; font-size: 0.8rem; color: rgba(255,255,255,0.6); }
.c-metrics .val { color: white; font-weight: 700; }

.c-actions { display: flex; gap: 12px; margin-top: 16px; }

/* Badges */
.dd-badge { font-size: 0.7rem; font-weight: 800; padding: 4px 8px; border-radius: 6px; letter-spacing: 1px; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }

/* Modals */
.dd-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.dd-modal__overlay { position: absolute; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); }
.dd-modal__content { position: relative; background: #0d0b12; border: 1px solid rgba(255,255,255,0.1); border-radius: 24px; box-shadow: 0 20px 50px rgba(0,0,0,0.5); animation: fadeInUp 0.3s ease-out; }
.dd-modal__close { position: absolute; top: 24px; right: 24px; background: none; border: none; color: rgba(255,255,255,0.5); font-size: 1.5rem; cursor: pointer; transition: 0.3s; z-index: 10; }
.dd-modal__close:hover { color: white; }

/* Detail Content Overrides */
.dd-detail-content { width: 95%; max-width: 1100px; height: 90vh; display: flex; flex-direction: column; padding: 32px; overflow-y: auto; }
.dd-detail-header { border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 24px; display: flex; justify-content: space-between; align-items: center; }

/* Chart Area */
.dd-chart-container { width: 100%; height: 280px; position: relative; background: rgba(255,255,255,0.02); border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); overflow: hidden; }
.chart-svg { width: 100%; height: 100%; overflow: visible; padding: 10px; }
.chart-axis { stroke: rgba(255,255,255,0.1); stroke-width: 1; }
.chart-line-eq { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.chart-line-hwm { fill: none; stroke: #fbbf24; stroke-width: 1.5; stroke-dasharray: 4; }
.chart-line-floor { fill: none; stroke: #ef5350; stroke-width: 2; }
.chart-bar-dd { fill: #ef5350; opacity: 0.6; transition: 0.2s; }
.chart-bar-dd:hover { opacity: 1; }

.dd-chart-legend { display: flex; gap: 16px; justify-content: center; font-size: 0.8rem; color: rgba(255,255,255,0.6); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.l-box { width: 12px; height: 4px; border-radius: 2px; }

/* Decomposition Grid */
.dd-decomp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.decomp-item { background: rgba(0,0,0,0.3); padding: 12px; border-radius: 8px; font-size: 0.85rem; display: flex; justify-content: space-between; border-left: 2px solid #a855f7; }

/* Worst List */
.dd-worst-list { display: flex; flex-direction: column; gap: 8px; }
.worst-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: rgba(0,0,0,0.2); border-radius: 8px; font-size: 0.85rem; border-left: 3px solid #ef5350; }

/* Verdict Box */
.dd-verdict-box { padding: 12px 16px; border-radius: 8px; font-weight: 700; text-align: center; font-size: 0.95rem; }
.v-good { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #22c55e; }
.v-warn { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: #fbbf24; }
.v-bad { background: rgba(239,83,80,0.1); border: 1px solid rgba(239,83,80,0.3); color: #ef5350; }

/* Defs container */
.svg-defs-hidden { width: 0; height: 0; position: absolute; }