/* ===== 全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0d0d1a;
    color: #e0e0e0;
    min-height: 100vh;
}

a {
    color: #ffd700;
    text-decoration: none;
}

a:hover {
    color: #ffed4a;
}

/* ===== 侧边栏 ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #16162a 100%);
    border-right: 1px solid #2a2a4a;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2a2a4a;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-menu {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: #a0a0b0;
    transition: all 0.2s ease;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255, 215, 0, 0.08);
    color: #ffd700;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 170, 0, 0.1));
    color: #ffd700;
    font-weight: 600;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #2a2a4a;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    color: #ff6b6b;
    font-size: 14px;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.1);
    color: #ff8080;
}

/* ===== 主内容区 ===== */
.main-content {
    margin-left: 240px;
    min-height: 100vh;
}

.top-bar {
    height: 60px;
    background: #1a1a2e;
    border-bottom: 1px solid #2a2a4a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    font-size: 24px;
}

.username {
    font-size: 14px;
    color: #c0c0d0;
}

.content-wrapper {
    padding: 24px;
}

/* ===== 卡片 ===== */
.card {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a4a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.card-body {
    padding: 20px;
}

.mt-20 {
    margin-top: 20px;
}

/* ===== 统计卡片 ===== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(255, 215, 0, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: #888;
    margin-top: 4px;
}

/* ===== 仪表盘网格 ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== 图表 ===== */
.chart-container {
    width: 100%;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
}

/* ===== 设备列表迷你版 ===== */
.device-list-mini {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.device-item-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #16162a;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.device-item-mini:hover {
    background: #1e1e3a;
}

.device-avatar {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a4a;
    border-radius: 8px;
}

.device-info-mini {
    flex: 1;
    min-width: 0;
}

.device-name {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-id {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
    font-family: monospace;
}

.device-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.device-status.verified {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
}

.device-status.unverified {
    background: rgba(255, 170, 0, 0.1);
    color: #ffaa00;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ffed4a, #ffbb33);
    color: #1a1a2e;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: #1a1a2e;
}

.btn-success:hover {
    background: linear-gradient(135deg, #33ffaa, #00dd77);
    color: #1a1a2e;
}

.btn-warning {
    background: linear-gradient(135deg, #ffaa00, #ff8800);
    color: #1a1a2e;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #ffbb33, #ff9922);
    color: #1a1a2e;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: #ffffff;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ff8080, #ff6666);
    color: #ffffff;
}

.btn-info {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #ffffff;
}

.btn-info:hover {
    background: linear-gradient(135deg, #7b8eee, #8b5bb2);
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-block {
    width: 100%;
}

.btn-link {
    background: none;
    color: #ffd700;
    padding: 4px 8px;
    font-size: 13px;
}

.btn-link:hover {
    background: rgba(255, 215, 0, 0.1);
    color: #ffed4a;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #c0c0d0;
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: #16162a;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 6px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.col-half {
    flex: 1;
}

.col-full {
    width: 100%;
}

.form-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #2a2a4a;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-sm {
    padding: 4px 8px;
    font-size: 12px;
    background: #16162a;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #ffffff;
    width: 100px;
}

.input-number {
    width: 70px;
}

.search-form {
    display: flex;
    gap: 8px;
}

.search-form input {
    padding: 6px 12px;
    background: #16162a;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #ffffff;
    font-size: 13px;
    width: 200px;
}

.search-form input:focus {
    outline: none;
    border-color: #ffd700;
}

/* ===== 表格 ===== */
.table-responsive {
    overflow-x: auto;
}

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

.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: #16162a;
    color: #a0a0b0;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid #2a2a4a;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #2a2a4a;
    font-size: 13px;
    color: #d0d0e0;
}

.data-table tr:hover td {
    background: rgba(255, 215, 0, 0.03);
}

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

.device-id-cell {
    font-family: monospace;
    font-size: 12px;
    color: #888;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.count-text {
    color: #ffd700;
    font-weight: 600;
}

.empty-cell {
    text-align: center;
    padding: 40px !important;
    color: #666;
}

.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ===== 徽章 ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
}

.badge-warning {
    background: rgba(255, 170, 0, 0.1);
    color: #ffaa00;
}

.badge-danger {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
}

/* ===== 登录页 ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d0d1a 0%, #1a1a2e 50%, #0d0d1a 100%);
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon-large {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: #666;
}

.login-form {
    margin-bottom: 24px;
}

.login-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #2a2a4a;
}

.login-footer p {
    font-size: 12px;
    color: #555;
}

/* ===== 提示框 ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.alert-success {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: #00ff88;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ===== 对话记录 ===== */
.chat-records {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-record-item {
    background: #16162a;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #2a2a4a;
}

.chat-record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #2a2a4a;
}

.chat-device-id {
    font-size: 13px;
    color: #ffd700;
    font-family: monospace;
}

.chat-time {
    font-size: 12px;
    color: #666;
}

.chat-bubble {
    margin-bottom: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
}

.chat-bubble:last-child {
    margin-bottom: 0;
}

.chat-label {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
    opacity: 0.7;
}

.chat-content {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.user-bubble {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
    margin-left: auto;
}

.user-bubble .chat-label {
    color: #ffd700;
}

.ai-bubble {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.ai-bubble .chat-label {
    color: #667eea;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #2a2a4a;
}

.page-info {
    font-size: 13px;
    color: #888;
}

/* ===== 信息列表 ===== */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.info-label {
    color: #888;
}

.info-value {
    color: #ffffff;
    font-weight: 500;
}

.text-success {
    color: #00ff88;
}

.text-warning {
    color: #ffaa00;
}

.text-danger {
    color: #ff6b6b;
}

/* ===== 筛选信息 ===== */
.filter-info {
    padding: 10px 14px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    font-size: 13px;
    color: #ffd700;
    margin-bottom: 16px;
}

/* ===== 头部操作区 ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .logo-text,
    .nav-item span:not(.nav-icon),
    .logout-btn span:not(:first-child) {
        display: none;
    }
    
    .main-content {
        margin-left: 60px;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
