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

:root {
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --text-main: #334155;
    --text-muted: #64748b;
    --text-white: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --border-color: #e2e8f0;
    --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);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    display: block;
    min-height: 100vh;
}

/* Modern Top Navigation */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.max-w-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.brand i {
    color: var(--primary);
    font-size: 1.5rem;
}

/* Desktop Nav Links */
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.nav-link:hover {
    color: var(--primary);
    background: #f1f5f9;
}

.nav-link.active {
    background: #eff6ff;
    color: var(--primary);
}

.nav-link i {
    font-size: 1.1rem;
}

/* User Profile in Nav */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-left: 1.5rem;
    border-left: 1px solid var(--border-color);
    margin-left: 1rem;
}

.nav-user img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-user-info {
    display: block;
}

.nav-user-info div:first-child {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.nav-user-info div:last-child {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Mobile Menu Toggle */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.5rem;
}

/* Main Content Adjustments */
.main-content {
    margin: 0 auto;
    padding: 2rem 1.5rem;
    max-width: 1400px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

/* Grid Layouts */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Cards */
.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background: #dbeafe;
    color: #2563eb;
}

.stat-icon.green {
    background: #dcfce7;
    color: #166534;
}

.stat-icon.red {
    background: #fee2e2;
    color: #991b1b;
}

.stat-icon.purple {
    background: #f3e8ff;
    color: #7e22ce;
}

.stat-info .label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.stat-info .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
}

.card {
    background: var(--bg-card);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.card-body {
    padding: 1.5rem;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.75rem 1.5rem;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #f8fafc;
}

/* Badges & Buttons */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-online {
    background-color: var(--success-bg);
    color: var(--success-text);
}

.badge-offline {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Detail Page Specifics */
.detail-header-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.device-id {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.os-logo {
    width: 64px;
    height: 64px;
    background: #f1f5f9;
    color: #475569;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.spec-item {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 0.75rem;
}

.spec-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.spec-val {
    font-weight: 600;
    color: #334155;
}

/* Responsive Media Queries */
@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .nav-user-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .max-w-container {
        padding: 0 1rem;
    }

    .mobile-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 70px;
        /* navbar height */
        left: 0;
        width: 100%;
        background: white;
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        gap: 0;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: 1rem;
        border-radius: 0;
        border-bottom: 1px solid #f1f5f9;
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .nav-user {
        display: none;
        /* Simplify mobile menu by hiding user partial, or move it inside nav-links */
    }

    /* Move user info to bottom of nav-links on mobile? */
    /* For simplicity, we just hide the top right user block and maybe rely on a settings link */

    .detail-header-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .device-id {
        width: 100%;
    }

    /* Responsive Table / Card System */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Hide table headers but keep accessible-ish */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    thead {
        display: none;
        /* Simpler for layout to avoid ghosts */
    }

    tr {
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        padding: 1.25rem;
        box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    tr:hover {
        background-color: white;
    }

    td {
        border-bottom: 1px solid #f1f5f9;
        padding: 0.75rem 0;
        text-align: right;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        min-height: 40px;
    }

    td:last-child {
        border-bottom: none;
        padding-top: 1rem;
        justify-content: flex-end;
    }

    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.85rem;
        text-align: left;
        margin-right: 1rem;
        flex-shrink: 0;
    }

    /* Helper to remove card background on mobile to prevent nesting look */
    .mobile-noborder {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .table-responsive,
    div[style*="overflow-x: auto"] {
        overflow-x: visible !important;
    }
}

/* Footer */
.main-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.footer-version {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--primary);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.action-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 200px;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.action-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-size: 1.2rem;
}

.action-text {
    display: flex;
    flex-direction: column;
}

.action-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.action-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Search Bar */
.search-container {
    position: relative;
    max-width: 300px;
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: white;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}