@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #e6ebf4; /* iOS Light Style base background */
    --bg-card: rgba(255, 255, 255, 0.45); /* High transparency frosted glass */
    --border-color: rgba(255, 255, 255, 0.6); /* Refractive light border */
    --text-main: #1c1c1e; /* iOS Dark Text */
    --text-muted: #8e8e93; /* iOS Muted Grey */
    
    --color-active: #34c759; /* iOS System Green */
    --color-active-bg: rgba(52, 199, 89, 0.15);
    
    --color-inactive: #8e8e93; /* iOS System Grey */
    --color-inactive-bg: rgba(142, 142, 147, 0.15);
    
    --color-alert: #ff3b30; /* iOS System Red */
    --color-alert-bg: rgba(255, 59, 48, 0.15);
    
    --color-warning: #ff9500; /* iOS System Orange */
    --color-warning-bg: rgba(255, 149, 0, 0.15);
    
    --color-primary: #007aff; /* iOS System Blue */
    --color-primary-bg: rgba(0, 122, 255, 0.12);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    padding: 20px;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background animated glow blobs (iPhone 17 style) */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
    mix-blend-mode: multiply;
}

.bg-glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(165, 180, 252, 0.5) 0%, rgba(129, 140, 248, 0.3) 100%);
    top: -150px;
    left: -150px;
    animation: float-slow 25s infinite ease-in-out alternate;
}

.bg-glow-2 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(244, 143, 177, 0.5) 0%, rgba(240, 98, 146, 0.3) 100%);
    bottom: -200px;
    right: -200px;
    animation: float-slow 30s infinite ease-in-out alternate-reverse;
}

.bg-glow-3 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(165, 243, 252, 0.6) 0%, rgba(103, 232, 249, 0.3) 100%);
    top: 30%;
    left: 45%;
    animation: float-slow 20s infinite ease-in-out alternate;
}

@keyframes float-slow {
    0% {
        transform: translate(0px, 0px) scale(1);
    }
    50% {
        transform: translate(40px, -60px) scale(1.1);
    }
    100% {
        transform: translate(-30px, 30px) scale(0.9);
    }
}

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Glassmorphism Common Styles */
.glass-effect {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.06), inset 0 1px 2px 0 rgba(255, 255, 255, 0.4);
}

/* Header */
header {
    background: var(--bg-card);
    backdrop-filter: blur(25px) saturate(190%);
    -webkit-backdrop-filter: blur(25px) saturate(190%);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px 0 rgba(31, 38, 135, 0.05), inset 0 1px 2px 0 rgba(255, 255, 255, 0.5);
}

.header-title-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-icon {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
}

.header-titles h1 {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.header-titles p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.header-status-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.active {
    background-color: var(--color-active-bg);
    color: #1e6d30;
    border-color: rgba(52, 199, 89, 0.3);
}

.status-indicator.active .status-dot {
    background-color: var(--color-active);
    box-shadow: 0 0 10px var(--color-active);
    animation: pulse 2s infinite;
}

.status-indicator.alert {
    background-color: var(--color-alert-bg);
    color: #b91c1c;
    border-color: rgba(255, 59, 48, 0.3);
}

.status-indicator.alert .status-dot {
    background-color: var(--color-alert);
    box-shadow: 0 0 10px var(--color-alert);
    animation: pulse-red 2s infinite;
}

/* Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1.62fr 1fr;
    }
}

.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* iOS Glass Card Design */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 24px;
    box-shadow: 0 10px 35px 0 rgba(31, 38, 135, 0.05), inset 0 1px 2px 0 rgba(255, 255, 255, 0.6);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text-main);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Twin Visualization Container */
.twin-container {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    height: 330px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.01);
}

.twin-svg {
    width: 100%;
    height: 100%;
    max-height: 300px;
}

/* SVG animations */
.flow-line {
    stroke-dasharray: 6, 6;
    animation: dash 0.8s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -12;
    }
}

.student-avatar {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(12px);
}

.student-avatar.present {
    opacity: 1;
    transform: translateY(0);
}

/* Metrics Grid - iPhone 17 Control Center style */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 640px) {
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.metric-card {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px 0 rgba(31, 38, 135, 0.02), inset 0 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.metric-card:hover {
    transform: scale(1.03);
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 10px 25px 0 rgba(31, 38, 135, 0.06), inset 0 1px 1px 0 rgba(255, 255, 255, 0.7);
}

.metric-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 5px rgba(0,0,0,0.01);
}

.metric-card.voltage .metric-icon-wrapper {
    background-color: var(--color-primary-bg);
    color: var(--color-primary);
}

.metric-card.current .metric-icon-wrapper {
    background-color: var(--color-warning-bg);
    color: #d97706;
}

.metric-card.presence .metric-icon-wrapper.active {
    background-color: var(--color-active-bg);
    color: var(--color-active);
    box-shadow: 0 0 10px rgba(52, 199, 89, 0.2);
}

.metric-card.validation .metric-icon-wrapper.active {
    background-color: var(--color-active-bg);
    color: var(--color-active);
    box-shadow: 0 0 10px rgba(52, 199, 89, 0.2);
}

.metric-card.validation .metric-icon-wrapper.alert {
    background-color: var(--color-alert-bg);
    color: var(--color-alert);
    box-shadow: 0 0 10px rgba(255, 59, 48, 0.2);
}

.metric-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: -0.1px;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.metric-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Timeline / Activity Logs */
.timeline-container {
    max-height: 270px;
    overflow-y: auto;
    padding-right: 4px;
}

.timeline {
    position: relative;
    padding-left: 20px;
    border-left: 1.5px solid rgba(28, 28, 30, 0.1);
    margin-left: 8px;
}

.timeline-item {
    position: relative;
    margin-bottom: 16px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -27px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #c7c7cc;
    border: 2px solid var(--bg-card);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.timeline-dot.system { background-color: var(--color-inactive); }
.timeline-dot.presence { background-color: var(--color-primary); }
.timeline-dot.power { background-color: var(--color-warning); }
.timeline-dot.validation { background-color: var(--color-active); }
.timeline-dot.anomaly { background-color: var(--color-alert); }

.timeline-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.timeline-text {
    font-size: 13px;
    color: var(--text-main);
    font-weight: 500;
}

/* Tab & Controls */
.control-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.04);
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 20px;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn.active {
    background: #ffffff;
    color: var(--text-main);
    box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Simulator controls - iOS grid design */
.sim-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-sim {
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.6);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.01), inset 0 1px 1px rgba(255,255,255,0.8);
}

.btn-sim:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.btn-sim:active {
    transform: translateY(1px);
}

.btn-sim.primary {
    background-color: var(--color-primary-bg);
    color: #0056b3;
    border-color: rgba(0, 122, 255, 0.2);
}
.btn-sim.primary:hover { background-color: rgba(0, 122, 255, 0.18); }

.btn-sim.success {
    background-color: var(--color-active-bg);
    color: #1e6d30;
    border-color: rgba(52, 199, 89, 0.2);
}
.btn-sim.success:hover { background-color: rgba(52, 199, 89, 0.22); }

.btn-sim.danger {
    background-color: var(--color-alert-bg);
    color: #b91c1c;
    border-color: rgba(255, 59, 48, 0.2);
}
.btn-sim.danger:hover { background-color: rgba(255, 59, 48, 0.22); }

.btn-sim.full-width {
    grid-column: span 2;
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0,0,0,0.05);
}
.btn-sim.full-width:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-muted);
    letter-spacing: -0.1px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    font-family: var(--font-sans);
    font-size: 13px;
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-main);
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.btn-mqtt {
    width: 100%;
    background: linear-gradient(135deg, #007aff, #0056b3);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.25s;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.btn-mqtt:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

/* Pulses & animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(52, 199, 89, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0);
    }
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(255, 59, 48, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
    }
}

/* Scrollbar override for glass */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}
