/* ========================
   IMPORTS
   ======================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ========================
   VARIABLES
   ======================== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-white: #ffffff;
    --text-gray: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --font-heading: 'Manrope', sans-serif;
    --font-body: 'Inter', sans-serif;

    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ========================
   RESET
   ======================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: var(--text-gray);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========================
   TYPOGRAPHY
   ======================== */
h1,
h2,
h3 {
    font-family: var(--font-heading);
    color: var(--text-white);
    font-weight: 700;
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

/* ========================
   LAYOUT
   ======================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

/* ========================
   HEADER
   ======================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow);
}

.header h1 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-offline {
    background: var(--error);
    box-shadow: 0 0 10px var(--error);
}

.status-connecting {
    background: var(--warning);
    box-shadow: 0 0 10px var(--warning);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ========================
   CARDS
   ======================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border);
    animation: fadeIn 0.5s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border);
}

.card-header h2 {
    color: var(--text-white);
}

.card-body {
    color: var(--text-gray);
}

/* ========================
   STATUS GRID
   ======================== */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.device-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    color: var(--text-gray);
    font-size: 0.9rem;
}

.info-row .value {
    color: var(--text-white);
    font-weight: 500;
}

/* ========================
   DETECTION
   ======================== */
.last-detection {
    text-align: center;
    padding: var(--spacing-md);
}

.detection-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-sm);
    filter: drop-shadow(0 0 20px rgba(239, 68, 68, 0.5));
}

.detection-active {
    filter: drop-shadow(0 0 20px rgba(16, 185, 129, 0.8)) !important;
    animation: detectPulse 1s ease;
}

@keyframes detectPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.detection-text {
    font-size: 1.1rem;
    color: var(--text-white);
    margin-bottom: var(--spacing-xs);
}

.detection-time {
    font-size: 0.9rem;
    color: var(--text-gray);
}

.pulse-animation {
    animation: cardPulse 0.5s ease;
}

@keyframes cardPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

/* ========================
   STATISTICS
   ======================== */
.stats-card .card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-md);
}

.stat-box {
    text-align: center;
    padding: var(--spacing-md);
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius);
    border: 1px solid rgba(99, 102, 241, 0.2);
    transition: all 0.3s ease;
}

.stat-box:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================
   CHARTS
   ======================== */
.charts-section {
    margin-bottom: var(--spacing-lg);
}

.chart-card .card-body {
    height: 300px;
    position: relative;
}

/* ========================
   LOGS
   ======================== */
.logs-section {
    margin-bottom: var(--spacing-lg);
}

.logs-container {
    background: #0a0f1a;
    border-radius: var(--radius);
    padding: var(--spacing-sm);
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.logs-container::-webkit-scrollbar {
    width: 8px;
}

.logs-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.logs-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.log-entry {
    padding: var(--spacing-xs);
    margin: var(--spacing-xs) 0;
    border-left: 3px solid;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    display: flex;
    gap: var(--spacing-sm);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-time {
    color: var(--text-gray);
    flex-shrink: 0;
}

.log-message {
    color: var(--text-white);
}

.log-info {
    border-left-color: var(--primary);
}

.log-success {
    border-left-color: var(--success);
}

.log-warning {
    border-left-color: var(--warning);
}

.log-error {
    border-left-color: var(--error);
}

.btn-clear {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--error);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: var(--font-body);
}

.btn-clear:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* ========================
   FOOTER
   ======================== */
.footer {
    text-align: center;
    padding: var(--spacing-lg) 0;
    color: var(--text-gray);
    font-size: 0.9rem;
    border-top: 1px solid var(--border);
    margin-top: var(--spacing-xl);
}

.footer-info {
    margin-top: var(--spacing-xs);
    font-family: monospace;
    font-size: 0.8rem;
}

/* ========================
   ANIMATIONS
   ======================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-grid .card:nth-child(1) {
    animation-delay: 0.1s;
}

.status-grid .card:nth-child(2) {
    animation-delay: 0.2s;
}

.status-grid .card:nth-child(3) {
    animation-delay: 0.3s;
}

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-sm);
    }

    .header {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .chart-card .card-body {
        height: 250px;
    }

    .stat-value {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .header .icon {
        font-size: 2rem;
    }

    .card {
        padding: var(--spacing-sm);
    }

    .logs-container {
        font-size: 0.8rem;
    }
}