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

:root {
    --sidebar-width: 240px;
    --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(59,130,246,0.2);
    --content-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--content-bg);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ── Layout ── */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    background: var(--sidebar-bg);
    width: var(--sidebar-width);
    flex-shrink: 0;
    padding: 0;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 12px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sidebar .brand i {
    font-size: 1.4rem;
    color: #3b82f6;
}

.sidebar hr {
    margin: 8px 16px;
    border-color: rgba(255,255,255,0.08);
}

.sidebar .nav-item {
    margin: 2px 8px;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: rgba(255,255,255,0.6);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
    box-shadow: inset 3px 0 0 #3b82f6;
}

.sidebar .nav-link i {
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
}

.sidebar-close {
    display: none;
}

/* ── Sidebar toggle button ── */
.sidebar-toggle {
    display: none;
}

/* ── Sidebar overlay ── */
.sidebar-overlay {
    display: none;
}

/* ── Main content ── */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 28px 32px;
    background: var(--content-bg);
}

/* ── Mobile ── */
@media (max-width: 767.98px) {
    .layout-wrapper {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.25s ease;
    }

    .sidebar.show {
        left: 0;
    }

    .sidebar-close {
        display: inline-block;
    }

    .sidebar-toggle {
        display: flex;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 50;
        width: 40px;
        height: 40px;
        border: none;
        border-radius: var(--radius-sm);
        background: #1e293b;
        color: #fff;
        font-size: 1.3rem;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 99;
        background: rgba(0,0,0,0.4);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        padding: 60px 16px 28px;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

/* ── Cards ── */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    background: #fff;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 20px;
    font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-body {
    padding: 20px;
}

.card-footer {
    background: transparent;
    border-top: 1px solid #f1f5f9;
    padding: 14px 20px;
    border-radius: 0 0 var(--radius) var(--radius) !important;
}

/* ── Stat cards ── */
.stat-card {
    border-radius: var(--radius);
    padding: 24px;
    color: #fff;
    border: none;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}

.stat-card h5 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 12px;
}

.stat-card h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0;
}

.stat-card > i {
    font-size: 2rem;
    opacity: 0.3;
    position: absolute;
    bottom: 16px;
    right: 16px;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.bg-gradient-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.bg-gradient-info {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.bg-gradient-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* ── Table ── */
.table {
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: #1e293b;
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border: none;
}

.table thead th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.table thead th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.table tbody tr {
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}

/* ── Progress bars ── */
.progress {
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.5s ease;
}

/* ── Badges ── */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

/* ── Buttons ── */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 8px 18px;
    transition: all 0.2s;
}

.btn-outline-primary {
    border-color: #3b82f6;
    color: #3b82f6;
}

.btn-outline-primary:hover {
    background: #3b82f6;
    border-color: #3b82f6;
}

.btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* ── Device cards ── */
.device-card {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.device-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.device-card .card-header {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.device-card .card-body {
    padding: 18px 20px;
}

.device-card .card-body p {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.btn-group .btn {
    font-size: 0.85rem;
    padding: 6px 14px;
}

/* ── Spinner ── */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ── Page head ── */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-head h3 {
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    font-size: 1.5rem;
}

.page-head h3 i {
    margin-right: 10px;
    color: #3b82f6;
}

/* ── Chart canvas ── */
canvas {
    width: 100% !important;
    height: auto !important;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state h4 {
    font-weight: 600;
    margin-bottom: 8px;
}

/* ── Footer ── */
.footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 16px 32px;
    margin-left: var(--sidebar-width);
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

@media (max-width: 767.98px) {
    .footer {
        margin-left: 0;
        padding: 12px 16px;
    }
}

/* ── Error UI ── */
#blazor-error-ui {
    display: none;
    background: #fef2f2;
    color: #991b1b;
    bottom: 0;
    padding: 10px 20px;
    position: fixed;
    width: 100%;
    z-index: 1000;
    border-top: 2px solid #ef4444;
    font-size: 0.9rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 10px;
}

/* ── Login Page ── */
.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header i {
    font-size: 2.5rem;
    color: #3b82f6;
    margin-bottom: 12px;
}

.login-header h3 {
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.login-header p {
    font-size: 0.9rem;
    margin: 0;
}

/* ── User Bar ── */
.user-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0 0 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.user-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

.user-name i {
    margin-right: 6px;
    color: #3b82f6;
}
