/* =========================
   RESET
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =========================
   BASE
========================= */
body {
    font-family: Arial, sans-serif;
    background: #f1f5f9;
    color: #0f172a;
}

a {
    text-decoration: none;
}

/* =========================
   LOGIN
========================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

.login-card,
.dashboard-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    padding: 32px;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
}

.login-logo h2 {
    font-size: 28px;
    margin-bottom: 6px;
}

.login-logo p {
    color: #64748b;
    font-size: 14px;
}

/* =========================
   FORMS
========================= */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    outline: none;
    font-size: 15px;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.full-width {
    grid-column: 1 / -1;
}

/* =========================
   BUTTONS
========================= */
.btn-primary {
    width: 100%;
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 13px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    display: inline-block;
    text-align: center;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-sm {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    border: none;
    cursor: pointer;
    text-align: center;
}

.btn-add {
    background: #0f766e;
}

.btn-edit {
    background: #2563eb;
}

.btn-activate {
    background: #16a34a;
}

.btn-inactive {
    background: #d97706;
}

.btn-block {
    background: #b91c1c;
}

.btn-delete {
    background: #7f1d1d;
}

.btn-add:hover,
.btn-edit:hover,
.btn-activate:hover,
.btn-inactive:hover,
.btn-block:hover,
.btn-delete:hover {
    opacity: 0.9;
}

/* =========================
   ALERTS
========================= */
.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
}

.alert.error {
    background: #fee2e2;
    color: #b91c1c;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

/* =========================
   LAYOUT
========================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    min-height: 100vh;
}

.content-area {
    padding: 24px;
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
    width: 250px;
    background: #0f172a;
    color: #fff;
    padding: 24px 18px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.sidebar-brand {
    text-align: center;
    margin-bottom: 28px;
}

.sidebar-brand img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 10px;
}

.sidebar-brand h2 {
    font-size: 20px;
}

.sidebar-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, #30B1B1, transparent);
    margin: 18px 0 22px 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link {
    color: #cbd5e1;
    padding: 12px 14px;
    border-radius: 10px;
    transition: 0.3s;
}

.nav-link:hover {
    background: #1e293b;
    color: #fff;
}

.logout-link {
    background: #7f1d1d;
    color: #fff;
}

/* =========================
   TOPBAR
========================= */
.topbar {
    background: #fff;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.topbar h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.topbar p {
    color: #64748b;
    font-size: 14px;
}

/* =========================
   PAGE HEADER
========================= */
.page-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* =========================
   CARDS
========================= */
.page-card,
.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

.page-card h2 {
    margin-bottom: 20px;
}

/* =========================
   DASHBOARD STATS
========================= */
.stats-grid,
.dashboard-top-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.dashboard-top-row {
    margin-bottom: 24px;
}

.stat-card {
    border-radius: 18px;
    color: #fff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.stat-card h3 {
    font-size: 16px;
    color: #64748b;
    margin-bottom: 10px;
}

.stat-card p {
    font-size: 28px;
    font-weight: bold;
}

.stat-card-teal {
    background: linear-gradient(135deg, #30B1B1, #1d8f8f);
}

.stat-card-green {
    background: linear-gradient(135deg, #16a34a, #15803d);
}

.stat-card-orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.stat-title {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-subtext {
    font-size: 13px;
    opacity: 0.9;
}

/* =========================
   SECTION HEADER
========================= */
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 24px;
    color: #0f172a;
    margin-bottom: 4px;
}

.section-subtitle {
    font-size: 14px;
    color: #64748b;
}

.last-refresh-box {
    background: #ffffff;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #dbeafe;
    color: #334155;
    font-size: 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

/* =========================
   TABLES
========================= */
.table-wrapper,
.device-table-wrap {
    overflow-x: auto;
}

.custom-table,
.device-info-table {
    width: 100%;
    border-collapse: collapse;
}

.custom-table th,
.custom-table td,
.device-info-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    font-size: 14px;
}

.custom-table th {
    background: #f8fafc;
}

.device-info-table td:first-child {
    width: 220px;
    color: #475569;
    font-weight: 600;
    background: #f8fafc;
}

/* =========================
   STATUS BADGES
========================= */
.status-badge,
.status-chip {
    display: inline-block;
    font-weight: 700;
    border-radius: 20px;
}

.status-badge {
    padding: 6px 10px;
    font-size: 12px;
}

.status-chip {
    padding: 8px 14px;
    border-radius: 30px;
    font-size: 13px;
}

.status-badge.active,
.status-chip.online {
    background: #dcfce7;
    color: #166534;
}

.status-badge.inactive {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.blocked,
.status-chip.offline {
    background: #fee2e2;
    color: #991b1b;
}

/* =========================
   DEVICE CARDS
========================= */
.device-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.device-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    border: 1px solid #e2e8f0;
}

.device-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
}

.device-card-header h3 {
    font-size: 22px;
    color: #0f172a;
    margin-bottom: 6px;
}

.device-card-header p {
    color: #64748b;
    font-size: 14px;
}

.device-meta-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.meta-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
}

.meta-box span {
    display: block;
    color: #64748b;
    font-size: 13px;
    margin-bottom: 8px;
}

.meta-box strong {
    font-size: 18px;
    color: #0f172a;
}

/* =========================
   BATTERY SECTION
========================= */
.battery-section {
    margin-top: 8px;
    margin-bottom: 20px;
}

.battery-section h4 {
    font-size: 18px;
    margin-bottom: 14px;
    color: #0f172a;
}

.battery-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 12px;
}

.battery-box {
    background: #f8fafc;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    padding: 14px 10px;
    text-align: center;
}

.battery-title {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 8px;
    font-weight: 600;
}

.battery-soc {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.battery-present {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 8px;
    border-radius: 20px;
}

.battery-present.yes {
    background: #dcfce7;
    color: #166534;
}

.battery-present.no {
    background: #fee2e2;
    color: #991b1b;
}

/* =========================
   EMPTY STATE
========================= */
.empty-state-card {
    text-align: center;
    padding: 40px 20px;
}


/* =========================
   FILTER BAR
========================= */
.filter-bar {
    display: flex;
    align-items: end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.search-group {
    flex: 1;
    min-width: 260px;
}

.status-group {
    min-width: 180px;
}

.filter-group input,
.filter-group select {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    outline: none;
    background: #fff;
}

.filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* =========================
   PAGINATION
========================= */
.pagination-wrap {
    margin-top: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 14px;
    color: #64748b;
}

.pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.page-link {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
}

.page-link:hover {
    background: #e2e8f0;
}

.page-link.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* =========================
   VIEW DETAILS
========================= */
.btn-view {
    background: #0891b2;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.detail-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px;
}

.detail-item span {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 8px;
}

.detail-item strong {
    font-size: 16px;
    color: #0f172a;
    word-break: break-word;
}

@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        align-items: stretch;
    }
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1200px) {
    .device-meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .battery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
        width: calc(100% - 220px);
    }

    .stats-grid,
    .dashboard-top-row,
    .grid-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: relative;
        width: 100%;
        bottom: auto;
    }

    .app-layout {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .device-meta-grid {
        grid-template-columns: 1fr;
    }

    .battery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .device-card-header h3 {
        font-size: 18px;
    }
}