/* =============================================================
   THEA PORTAL — Design System v3.0 (Premium Light)
   Professional Inverter Monitoring & SCADA Design System
   ============================================================= */

/* ── Custom Properties (Light Theme) ────────────────────────── */
:root {
    --bg-body: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.95);
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-metric: #f8fafc;
    --bg-header: rgba(255, 255, 255, 0.85);

    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-card: rgba(0, 0, 0, 0.08);
    --border-hover: #4f46e5;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent: #4f46e5;
    --accent-light: #6366f1;
    --accent-glow: rgba(79, 70, 229, 0.15);

    --solar: #eab308;
    --solar-glow: rgba(234, 179, 8, 0.15);
    --grid-color: #3b82f6;
    --grid-glow: rgba(59, 130, 246, 0.15);
    --battery-color: #8b5cf6;
    --battery-glow: rgba(139, 92, 246, 0.15);
    --energy: #10b981;
    --energy-glow: rgba(16, 185, 129, 0.15);
    --bms: #06b6d4;
    --bms-glow: rgba(6, 182, 212, 0.15);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 32px;
    --radius-full: 999px;

    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 150ms;
    --dur: 300ms;
    --dur-slow: 500ms;
}

/* ── Reset & Core ───────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* ── Cards ──────────────────────────────────────────────────── */
.tp-card, .card, .glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all var(--dur) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.tp-card:hover, .card:hover, .glass-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--accent-light);
}

.tp-card-header, .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.tp-card-title, .card-header h2 {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Metrics ────────────────────────────────────────────────── */
.tp-metric, .metric-box {
    background: var(--bg-metric);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--dur-fast) ease;
}

.tp-metric:hover, .metric-box:hover {
    background: #ffffff;
    box-shadow: var(--shadow-md);
    border-color: var(--accent-glow);
}

.tp-metric-label, .metric-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tp-metric-value, .metric-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    font-family: 'Outfit', sans-serif;
}

.tp-metric-unit, .unit {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 2px;
}

/* ── Status Strip ───────────────────────────────────────────── */
.tp-status-strip {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.tp-status-item {
    flex: 1;
    min-width: 150px;
    background: #ffffff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: var(--shadow-sm);
}

.tp-status-label {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.12em;
    margin-bottom: 4px;
}

.tp-status-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Progress & Indicators ──────────────────────────────────── */
.tp-progress {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.tp-progress-bar {
    height: 100%;
    transition: width 1s var(--ease-out);
}

.tp-progress-bar--battery { background: var(--battery-color); }
.tp-progress-bar--solar { background: var(--solar); }
.tp-progress-bar--energy { background: var(--energy); }

/* ── Layout Grids ───────────────────────────────────────────── */
.tp-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: auto;
    gap: 24px;
    align-items: start;
}

.col-span-1 { grid-column: span 1 / span 1; }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }

.tp-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tp-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Status Grid Utility ────────────────────────────────────── */
.tp-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

/* ── Animations ─────────────────────────────────────────────── */
.animate-in {
    animation-fill-mode: both;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fade-in 0.6s cubic-bezier(0.2, 0, 0.2, 1);
}

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

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

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1600px) {
    .tp-dashboard-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1280px) {
    .tp-dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .tp-dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .tp-status-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── BMS Specific ───────────────────────────────────────────── */
.tp-bms-soc-ring {
    width: 160px;
    height: 160px;
    margin: 0 auto;
    position: relative;
}

.tp-bms-soc-value {
    font-size: 44px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

.tp-bms-metric {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    padding: 12px;
    text-align: center;
    border-radius: var(--radius-md);
}

/* ── Sparklines ─────────────────────────────────────────────── */
.tp-sparkline {
    width: 100%;
    height: 40px;
    margin-top: 12px;
}

.sparkline-line {
    stroke: var(--accent);
    stroke-width: 2;
    fill: none;
}

.sparkline-area {
    fill: var(--accent-glow);
}

/* ── Communication ──────────────────────────────────────────── */
.tp-comm-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
}

.tp-comm-item {
    background: #ffffff;
    border: 1px solid var(--border-card);
    padding: 12px;
    border-radius: var(--radius-md);
    text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .tp-layout { grid-template-columns: 1fr; }
    .tp-sidebar { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .tp-grid-2, .tp-grid-4-custom, .tp-status-strip {
        grid-template-columns: 1fr;
    }
    .tp-sidebar { grid-template-columns: 1fr; }
}

/* ── Legacy Compat & Utils ──────────────────────────────────── */
.text-solar { color: var(--solar); }
.text-energy { color: var(--energy); }
.text-battery { color: var(--battery-color); }
.text-indigo { color: var(--accent); }

.bg-emerald-50 { background-color: #ecfdf5; }
.text-emerald-700 { color: #047857; }
.bg-rose-50 { background-color: #fff1f2; }
.text-rose-700 { color: #be123c; }

/* ── Device Info ────────────────────────────────────────────── */
.tp-device-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tp-device-item {
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
}

.tp-device-label {
    font-size: 9px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.tp-device-value {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
}

/* ── Custom Utilities from Base ────────────────────────────── */
.sidebar-link.active {
    background-color: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    border-right: 3px solid #4f46e5;
}

.sidebar-link:hover:not(.active) {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Modern Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.nav-gradient {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px currentColor;
}
.led.green { background: #10b981; color: #10b981; }
.led.red { background: #ef4444; color: #ef4444; }
.led.yellow { background: #f59e0b; color: #f59e0b; }

@keyframes animate-led-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}
.animate-led-pulse { animation: animate-led-pulse 1.5s ease-in-out infinite; }

/* ── Electric Flow Animation ────────────────────────────────── */
.electric-path {
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 2px currentColor);
    transition: stroke 0.5s ease;
}

.flow-dots {
    stroke-dasharray: 0.1, 15;
    stroke-width: 6;
    animation: flow-dots 2s linear infinite;
    opacity: 0.9;
}

@keyframes flow-dots {
    from { stroke-dashoffset: 100; }
    to { stroke-dashoffset: 0; }
}

.mimic-card {
    min-height: auto !important;
    display: flex;
    flex-direction: column;
    padding: 1.5rem !important;
}

/* ── Indian Flag & Waving Effect ────────────────────────────── */
.flag-container {
    perspective: 1000px;
}

.waving-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(0, 0, 0, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: flag-wave 4s ease-in-out infinite;
}

/* ── Fixed Layer SCADA Aesthetics ────────────────────────────── */
.scada-header-fixed {
    background: #ffffff !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.scada-footer-fixed {
    background: #ffffff !important;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

/* ── Premium Fixed Header & Nav ────────────────────────────── */
.tp-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    background: #ffffff;
    height: 70px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.tp-header-inner {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tp-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 12px;
}

.tp-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
}

.tp-brand-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.tp-nav {
    display: flex;
    gap: 8px;
}

.tp-nav-item {
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.2s ease;
}

.tp-nav-item:hover {
    background: #f1f5f9;
    color: var(--accent);
}

.tp-nav-item.active {
    background: rgba(79, 70, 229, 0.08);
    color: var(--accent);
}

.tp-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.tp-conn-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.tp-conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
}

.tp-conn-dot.online {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

#info-conn-text {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
}
