:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

#app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--background);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    border-left: 3px solid #1d4ed8;
}

.nav-item .icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
}

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

.header h2 {
    font-size: 1.875rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

.view-actions {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
}

.view-filters {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.stat-card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

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

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--background);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.data-table tbody tr:hover {
    background: var(--background);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.625rem 1.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    padding: 0.625rem 1.25rem;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-success:hover {
    background: #059669;
}

.btn-refresh {
    background: var(--surface);
    color: var(--text-primary);
    padding: 0.625rem 1.25rem;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border-radius: 0.75rem;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input[type="file"],
.form-group textarea,
.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.form-group textarea {
    resize: vertical;
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Upload Progress */
.upload-progress {
    margin: 1.5rem 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--background);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
    width: 0%;
}

#upload-status {
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Logs */
.logs-container {
    max-height: 600px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.813rem;
}

.log-entry {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 180px 120px 1fr;
    gap: 1rem;
}

.log-entry:hover {
    background: var(--background);
}

.log-timestamp {
    color: var(--text-secondary);
}

.log-action {
    font-weight: 600;
}

.log-action.version_check {
    color: var(--primary-color);
}

.log-action.firmware_download {
    color: var(--success-color);
}

/* Activity List */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Firmware Info */
.firmware-info {
    padding: 1rem 0;
}

.firmware-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.firmware-label {
    color: var(--text-secondary);
}

.firmware-value {
    font-weight: 600;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.text-small {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

/* Device Configuration */
.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.config-status {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.config-input {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.config-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.command-item {
    padding: 0.75rem;
    background: var(--background);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.command-item code {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 0.813rem;
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.command-method {
    font-size: 0.75rem;
}

.command-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.813rem;
}

#config-device-selector {
    padding: 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    cursor: pointer;
}

#config-device-selector:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: relative;
        height: auto;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
