/**
 * 主样式文件 - 渐变扁平风
 */

:root {
    /* 主色渐变 */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-danger: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    --gradient-warning: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);

    /* 基础色 */
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --success: #11998e;
    --danger: #eb3349;
    --warning: #f093fb;
    --info: #4facfe;

    /* 背景色 */
    --bg-primary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-dark: #2c3e50;
    --bg-sidebar: #1a1a2e;

    /* 文字色 */
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-white: #ffffff;

    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

    /* 侧边栏 */
    --sidebar-width: 260px;
}

/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* 布局 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-white);
    padding: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 30px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo h1 {
    font-size: 20px;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.nav-section {
    padding: 0 15px;
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 15px;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin: 2px 0;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.nav-item.active {
    background: var(--gradient-primary);
    color: var(--text-white);
}

.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 主内容区 */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.main-header {
    background: var(--bg-card);
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.main-body {
    padding: 30px;
}

/* 卡片 */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* 统计卡片 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.primary { background: var(--gradient-primary); color: white; }
.stat-icon.success { background: var(--gradient-success); color: white; }
.stat-icon.danger { background: var(--gradient-danger); color: white; }
.stat-icon.warning { background: var(--gradient-warning); color: white; }

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

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

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

/* 设备卡片 */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.device-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all 0.3s ease;
}

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

.device-card-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.device-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.device-info {
    flex: 1;
}

.device-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.device-id {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.device-remark {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.device-card-body {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.device-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.device-tag.online {
    background: rgba(17, 153, 142, 0.1);
    color: var(--success);
}

.device-tag.offline {
    background: rgba(153, 153, 153, 0.1);
    color: var(--text-muted);
}

.device-tag.logging {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
}

.device-card-footer {
    padding: 16px 20px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #e0e0e0;
}

.modal-footer {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* 抽屉 */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: var(--bg-card);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.drawer.active {
    transform: translateX(0);
}

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

.drawer-title {
    font-size: 18px;
    font-weight: 600;
}

.drawer-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
}

.drawer-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.drawer-footer {
    padding: 20px;
    border-top: 1px solid #eee;
}

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

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

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.table td {
    font-size: 14px;
}

/* 分页 */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 30px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.pagination a {
    background: #f0f0f0;
    color: var(--text-secondary);
}

.pagination a:hover {
    background: var(--primary);
    color: white;
}

.pagination .active {
    background: var(--gradient-primary);
    color: white;
}

/* 标签 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(17, 153, 142, 0.1);
    color: var(--success);
}

.badge-danger {
    background: rgba(235, 51, 73, 0.1);
    color: var(--danger);
}

.badge-warning {
    background: rgba(240, 147, 251, 0.1);
    color: #d946ef;
}

/* 警告框 */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-info {
    background: rgba(79, 172, 254, 0.1);
    color: var(--info);
    border: 1px solid rgba(79, 172, 254, 0.2);
}

.alert-success {
    background: rgba(17, 153, 142, 0.1);
    color: var(--success);
    border: 1px solid rgba(17, 153, 142, 0.2);
}

.alert-danger {
    background: rgba(235, 51, 73, 0.1);
    color: var(--danger);
    border: 1px solid rgba(235, 51, 73, 0.2);
}

.alert-warning {
    background: rgba(240, 147, 251, 0.1);
    color: #d946ef;
    border: 1px solid rgba(240, 147, 251, 0.2);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-desc {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Toast提示 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
    max-width: 350px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--info);
}

/* 响应式 */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-header {
        display: flex;
    }
}

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

    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }

    .drawer {
        width: 100%;
    }

    .main-header {
        padding: 15px 20px;
    }

    .main-body {
        padding: 20px;
    }

    .modal {
        padding: 20px;
    }

    .table {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 8px 10px;
    }
}

/* 汉堡菜单按钮 */
.hamburger {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: #f0f0f0;
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
}

@media (max-width: 1024px) {
    .hamburger {
        display: flex;
    }
}

/* 用户信息区 */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* 续费页面 */
.renew-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.renew-option {
    border: 2px solid #eee;
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.renew-option:hover {
    border-color: var(--primary);
}

.renew-option.selected {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.renew-option .days {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.renew-option .unit {
    font-size: 14px;
    color: var(--text-secondary);
}

.renew-option .price {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 8px;
}

/* 二维码区域 */
.qrcode-container {
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: var(--radius-lg);
    margin: 20px 0;
}

.qrcode-image {
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    background: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qrcode-status {
    font-size: 14px;
    color: var(--text-secondary);
}

.qrcode-status.scanning {
    color: var(--info);
}

.qrcode-status.success {
    color: var(--success);
}

/* 支付模拟页面 */
.pay-qrcode {
    text-align: center;
    padding: 40px;
    background: #f8f9fa;
    border-radius: var(--radius-lg);
    margin: 20px 0;
}

.pay-amount {
    font-size: 36px;
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 20px;
}
