/* Material UI 风格的全局样式 */

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

body {
    font-family: 'Roboto', 'Microsoft YaHei', 'Helvetica', 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* CSS 变量 - Material UI 色彩系统 */
:root {
    --primary-main: #1976d2;
    --primary-light: #42a5f5;
    --primary-dark: #1565c0;
    --secondary-main: #dc004e;
    --error-main: #d32f2f;
    --warning-main: #ed6c02;
    --info-main: #0288d1;
    --success-main: #2e7d32;
    --background-default: #f5f5f5;
    --background-paper: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --divider: #e5e5e5;
    --shadow-1: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-2: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-3: 0 8px 16px rgba(0,0,0,0.1);
    --shadow-4: 0 12px 24px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 动画关键帧 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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

/* Material UI 卡片样式 */
.mui-card {
    background: var(--background-paper);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-2);
    overflow: hidden;
    transition: var(--transition);
}

.mui-card:hover {
    box-shadow: var(--shadow-3);
}

.mui-card-content {
    padding: 24px;
}

/* Material UI 按钮样式 */
.mui-button {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    text-transform: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
}

.mui-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mui-button-contained {
    background: var(--primary-main);
    color: white;
    box-shadow: var(--shadow-1);
}

.mui-button-contained:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow-2);
    transform: translateY(-1px);
}

.mui-button-outlined {
    background: transparent;
    color: var(--primary-main);
    border: 2px solid var(--primary-main);
}

.mui-button-outlined:hover:not(:disabled) {
    background: rgba(25, 118, 210, 0.04);
    border-color: var(--primary-dark);
}

.mui-button-large {
    padding: 15px 32px;
    font-size: 16px;
    min-height: 48px;
}

.mui-button-small {
    padding: 8px 16px;
    font-size: 12px;
    min-height: 28px;
}

/* Material UI 输入框样式 */
.mui-textfield {
    position: relative;
    margin-bottom: 16px;
}

.mui-textfield label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    transition: color 0.2s ease;
}

.mui-textfield input,
.mui-textfield select,
.mui-textfield textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--divider);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--background-paper);
}

.mui-textfield input:focus,
.mui-textfield select:focus,
.mui-textfield textarea:focus {
    outline: none;
    border-color: var(--primary-main);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

/* 焦点时标签颜色变化 */
.mui-textfield input:focus + label,
.mui-textfield input:focus ~ label,
.mui-textfield:focus-within label {
    color: var(--primary-main);
}

.mui-textfield .helper-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    transition: color 0.2s ease;
}

.mui-textfield.error input {
    border-color: var(--error-main);
}

.mui-textfield.error .helper-text {
    color: var(--error-main);
}

.mui-textfield.error label {
    color: var(--error-main);
}

/* 输入框包装容器样式 */
.mui-textfield .input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.mui-textfield .input-wrapper input {
    flex: 1;
}

/* 表单网格对齐样式 */
.form-grid-aligned {
    display: grid;
    align-items: end; /* 将所有项目对齐到底部 */
    gap: 16px;
}

.form-grid-aligned .mui-textfield {
    margin-bottom: 0; /* 移除底部边距，使用网格间距 */
}

/* 按钮容器对齐 */
.button-container-aligned {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 30px; /* 与 label + margin-bottom 的高度对齐 */
}

/* 网格中的按钮组 */
.grid-button-group {
    display: flex;
    gap: 8px;
    align-self: end; /* 在网格中对齐到底部 */
}

/* 统计卡片样式 */
.stats-card {
    min-height: 100px;
    height: 100px;
    transition: var(--transition);
    cursor: pointer;
}

/* 统计卡片高度变体 */
.stats-card.compact {
    min-height: 80px;
    height: 80px;
}

.stats-card.normal {
    min-height: 100px;
    height: 100px;
}

.stats-card.large {
    min-height: 120px;
    height: 120px;
}

.stats-card.extra-large {
    min-height: 140px;
    height: 140px;
}

.stats-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.stats-card .mui-card-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px 12px;
}

.stats-card h3 {
    font-size: 28px !important;
    font-weight: 700 !important;
    line-height: 1.2;
}

.stats-card p {
    font-size: 12px !important;
    opacity: 0.9;
    margin-top: 4px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 统计卡片动画 */
.stats-card h3 {
    animation: countUp 0.8s ease-out;
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Material UI 表格样式 */
.mui-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--background-paper);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}

.mui-table th,
.mui-table td {
    padding: 16px 12px;
    text-align: center;
    border-bottom: 1px solid var(--divider);
}

.mui-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.mui-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.mui-table tr:hover {
    background: rgba(25, 118, 210, 0.04);
}

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

/* 固定表头表格样式 */
.table-container {
    border: 1px solid var(--divider);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-1);
}

.table-header {
    background: #f8f9fa;
    border-bottom: 1px solid var(--divider);
    position: sticky;
    top: 0;
    z-index: 10;
    overflow-y: scroll; /* 添加滚动条但不显示内容 */
    scrollbar-gutter: stable; /* 现代浏览器：为滚动条预留稳定空间 */
}

.table-header::-webkit-scrollbar {
    width: 8px;
    background: transparent;
}

.table-header table {
    table-layout: fixed; /* 强制固定列宽 */
    width: 100%;
}

.table-body {
    background: var(--background-paper);
    overflow-y: scroll; /* 强制显示滚动条 */
    scrollbar-gutter: stable; /* 现代浏览器：为滚动条预留稳定空间 */
}

.table-body table {
    table-layout: fixed; /* 强制固定列宽 */
    width: 100%;
}

/* 固定列宽 - 确保表头和表体对齐 */
.table-header th:nth-child(1),
.table-body td:nth-child(1) { width: 18%; } /* 时间 */

.table-header th:nth-child(2),
.table-body td:nth-child(2) { width: 15%; } /* 设备ID */

.table-header th:nth-child(3),
.table-body td:nth-child(3) { width: 20%; } /* 用户 */

.table-header th:nth-child(4),
.table-body td:nth-child(4) { width: 10%; } /* 类型 */

.table-header th:nth-child(5),
.table-body td:nth-child(5) { width: 15%; } /* 激活码 */

.table-header th:nth-child(6),
.table-body td:nth-child(6) { width: 12%; } /* IP地址 */

.table-header th:nth-child(7),
.table-body td:nth-child(7) { width: 10%; } /* 操作 */

/* 代码字体样式 */
.code-font {
    font-family: 'Consolas', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    letter-spacing: 0.3px;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

/* 滚动条样式 - 始终显示 */
.table-body::-webkit-scrollbar {
    width: 8px;
    background: #f8f9fa; /* 与表头背景一致 */
}

.table-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
    min-height: 20px; /* 确保滚动条拖拽块最小高度 */
}

.table-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 当内容不足滚动时，滚动条仍然显示但禁用 */
.table-body::-webkit-scrollbar-corner {
    background: #f8f9fa;
}

/* 日期范围选择器模态框样式 */
.date-range-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--background-paper);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

/* 日历样式 - 仿 MUI X 官方效果 */
.calendar-grid {
    user-select: none;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.weekday {
    padding: 8px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.calendar-day:hover {
    background: rgba(25, 118, 210, 0.08);
}

.calendar-day.other-month {
    color: var(--text-secondary);
    opacity: 0.5;
}

.calendar-day.selected {
    background: var(--primary-main) !important;
    color: white !important;
    border-radius: 50% !important;
}

.calendar-day.range-start {
    background: var(--primary-main) !important;
    color: white !important;
    border-radius: 50% 0 0 50% !important;
}

.calendar-day.range-end {
    background: var(--primary-main) !important;
    color: white !important;
    border-radius: 0 50% 50% 0 !important;
}

.calendar-day.in-range {
    background: rgba(25, 118, 210, 0.2) !important;
    border-radius: 0 !important;
    color: var(--primary-main) !important;
}

.calendar-day.today {
    border-color: var(--primary-main);
    font-weight: 600;
}

/* 快捷按钮样式 */
.quick-range-btn {
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: 1px solid var(--divider);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
    text-align: left;
}

.quick-range-btn:hover {
    background: rgba(25, 118, 210, 0.04);
    border-color: var(--primary-main);
    color: var(--primary-main);
}

.quick-range-btn.active {
    background: var(--primary-main);
    color: white;
    border-color: var(--primary-main);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--divider);
    background: #f8f9fa;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--divider);
    background: #f8f9fa;
}

.shortcuts {
    padding: 16px;
    background: rgba(25, 118, 210, 0.02);
    border-radius: var(--border-radius);
    border: 1px solid rgba(25, 118, 210, 0.1);
}

/* 响应式模态框 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
    
    .shortcuts .d-flex {
        flex-direction: column;
        align-items: stretch;
    }
    
    .shortcuts button {
        width: 100%;
    }
}

.table-footer {
    background: #f8f9fa;
    border-top: 1px solid var(--divider);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* 排序表头样式 */
.table-header th[data-sortable]:hover {
    background: rgba(25, 118, 210, 0.08);
}

/* 表格行悬停效果 */
.table-body tr:hover {
    background: rgba(25, 118, 210, 0.04);
}



/* Material UI 芯片样式 */
.mui-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}

.mui-chip.primary {
    background: rgba(25, 118, 210, 0.1);
    color: var(--primary-main);
}

.mui-chip.default {
    background: #f5f5f5;
    color: var(--text-secondary);
}

/* Material UI 消息提示样式 - 浮动版本 */
.mui-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.4;
    z-index: 9999;
    min-width: 300px;
    max-width: 800px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateX(-50%) translateY(-100px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.mui-alert.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.mui-alert.success {
    background: rgba(232, 245, 232, 0.95);
    color: var(--success-main);
    border-left: 4px solid var(--success-main);
}

.mui-alert.error {
    background: rgba(255, 235, 238, 0.95);
    color: var(--error-main);
    border-left: 4px solid var(--error-main);
}

.mui-alert.warning {
    background: rgba(255, 243, 224, 0.95);
    color: var(--warning-main);
    border-left: 4px solid var(--warning-main);
}

.mui-alert.info {
    background: rgba(227, 242, 253, 0.95);
    color: var(--info-main);
    border-left: 4px solid var(--info-main);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .mui-alert {
        left: 10px;
        right: 10px;
        transform: translateX(0);
        min-width: auto;
        max-width: none;
    }
    
    .mui-alert.show {
        transform: translateX(0) translateY(0);
    }
}

/* 加载动画 */
.mui-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-main);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 容器样式 */
.mui-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.mui-container-sm {
    max-width: 600px;
}

.mui-container-xs {
    max-width: 400px;
}

/* 网格系统 */
.mui-grid {
    display: grid;
    gap: 16px;
}

.mui-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.mui-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.mui-grid-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

/* 等高卡片系统 */
.mui-grid.equal-height {
    align-items: stretch;
}

.mui-grid.equal-height .mui-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.mui-grid.equal-height .mui-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mui-grid.equal-height .card-body {
    flex: 1;
}

.mui-grid.equal-height .card-footer {
    margin-top: auto;
    padding-top: 16px;
}

/* 强制等高样式 - 确保在所有情况下都生效 */
.force-equal-height {
    display: grid !important;
    align-items: stretch !important;
}

.force-equal-height > * {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.force-equal-height .mui-card-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* 卡片内容区域的垂直分布 */
.card-content-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-main-content {
    flex: 1;
}

.card-actions {
    margin-top: auto;
    padding-top: 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mui-grid-2,
    .mui-grid-3,
    .mui-grid-4 {
        grid-template-columns: 1fr;
    }
    
    .mui-container {
        padding: 0 16px;
    }
    
    .mui-card-content {
        padding: 16px;
    }
    
    .mui-button-large {
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* Material Icons 工具类 */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

/* Material Icons 尺寸变体 */
.material-icons.md-18 { font-size: 18px; }
.material-icons.md-20 { font-size: 20px; }
.material-icons.md-24 { font-size: 24px; }
.material-icons.md-36 { font-size: 36px; }
.material-icons.md-48 { font-size: 48px; }

/* Material Icons 颜色变体 */
.material-icons.primary { color: var(--primary-main); }
.material-icons.secondary { color: var(--secondary-main); }
.material-icons.success { color: var(--success-main); }
.material-icons.error { color: var(--error-main); }
.material-icons.warning { color: var(--warning-main); }
.material-icons.info { color: var(--info-main); }

/* Icon 容器样式 */
.icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: var(--shadow-2);
    transition: var(--transition);
}

.icon-container.primary {
    background: linear-gradient(45deg, var(--primary-main), var(--primary-light));
    color: white;
}

.icon-container.secondary {
    background: linear-gradient(45deg, var(--secondary-main), #f06292);
    color: white;
}

.icon-container:hover {
    box-shadow: var(--shadow-3);
    transform: translateY(-2px);
}

/* 工具类 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

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

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

.flex-column {
    flex-direction: column;
}

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.rounded { border-radius: var(--border-radius); }
.rounded-lg { border-radius: var(--border-radius-lg); }
.rounded-full { border-radius: 50%; }

.shadow-1 { box-shadow: var(--shadow-1); }
.shadow-2 { box-shadow: var(--shadow-2); }
.shadow-3 { box-shadow: var(--shadow-3); }

.transition { transition: var(--transition); }

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in {
    animation: slideIn 0.5s ease-out;
}
