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

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

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

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

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    min-width: 320px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a2e;
}

.modal-content {
    color: #555;
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.modal-input:focus {
    outline: none;
    border-color: #4a90d9;
}

.modal-btns {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary {
    background: #4a90d9;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #357abd;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: #d0d0d0;
}

/* 蓝色边框样式 - 悬停填满 */
.btn-outline {
    background: transparent;
    color: #4a90d9;
    border: 2px solid #4a90d9;
}

.btn-outline:hover:not(:disabled) {
    background: #4a90d9;
    color: #fff;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #219a52;
}

/* 控制按钮行 */
.control-buttons-row {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.control-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    position: relative;
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn .btn-text {
    white-space: nowrap;
}

/* 开始/结束按钮 - 绿色主题 */
.control-btn-toggle {
    border-color: #10b981;
    color: #10b981;
    background: #fff;
}

.control-btn-toggle:hover:not(:disabled) {
    background: #10b981;
    color: #fff;
}

/* 结束比赛状态 - 红色主题 */
.control-btn-toggle.ended {
    border-color: #ef4444;
    color: #ef4444;
    background: #fff;
}

.control-btn-toggle.ended:hover:not(:disabled) {
    background: #ef4444;
    color: #fff;
}

/* 暂停/继续按钮 - 黄色主题 */
.control-btn-pause {
    border-color: #f59e0b;
    color: #f59e0b;
    background: #fff;
}

.control-btn-pause:hover:not(:disabled) {
    background: #f59e0b;
    color: #fff;
}

/* 继续比赛状态 - 绿色主题 */
.control-btn-pause.resumed {
    border-color: #10b981;
    color: #10b981;
    background: #fff;
}

.control-btn-pause.resumed:hover:not(:disabled) {
    background: #10b981;
    color: #fff;
}

/* 初始化按钮 - 灰色主题 */
.control-btn-init {
    border-color: #6b7280;
    color: #6b7280;
    background: #fff;
}

.control-btn-init:hover:not(:disabled) {
    background: #6b7280;
    color: #fff;
}

/* 顶部导航 */
.top-nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: rgba(255,255,255,0.1);
}

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

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-time {
    font-size: 14px;
    color: #aaa;
    font-variant-numeric: tabular-nums;
}

.user-menu {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-trigger:hover {
    background: rgba(255,255,255,0.1);
}

.user-name {
    font-weight: 600;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 120px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
}

.user-menu.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 12px 16px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
    margin: 4px;
}

.dropdown-item:hover {
    background: #f5f6fa;
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: #16213e;
    color: #fff;
    transition: width 0.3s;
    overflow: hidden;
    z-index: 999;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-menu {
    padding: 16px 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.05);
}

.sidebar-item.active {
    background: #4a90d9;
}

.sidebar-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-text {
    margin-left: 12px;
    font-size: 14px;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-text {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

/* 侧边栏底部开发者信息 */
.sidebar-footer {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    padding: 10px 16px;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    text-align: center;
    line-height: 1.6;
}

/* 主内容区 */
.main-content {
    margin-left: 220px;
    margin-top: 60px;
    padding: 24px;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.3s;
}

/* 选手端和工作人员端的主内容区 */
.main-content:has(iframe) {
    padding: 0;
    overflow: hidden;
    height: calc(100vh - 60px);
}

.sidebar.collapsed + .main-content {
    margin-left: 60px;
}

/* 创建赛事表单居中 */
#create-form-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* 页面标题 */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a2e;
}

/* 卡片 */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a2e;
}

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

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

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #4a90d9;
}

.form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

/* 标签页 */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    color: #666;
    font-size: 14px;
}

.tab:hover {
    color: #4a90d9;
}

.tab.active {
    color: #4a90d9;
    border-bottom-color: #4a90d9;
    font-weight: 500;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

.data-table th:last-child,
.data-table td:last-child {
    border-right: none;
}

.data-table th {
    font-weight: 600;
    color: #555;
    background: #f8f9fa;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.password-cell {
    cursor: pointer;
    color: #999;
    user-select: none;
}

.password-cell:hover {
    color: #4a90d9;
}

.online-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.online-badge.online {
    background: #d4edda;
    color: #155724;
}

.online-badge.offline {
    background: #f8d7da;
    color: #721c24;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.online-badge.online .status-dot {
    background: #28a745;
}

.online-badge.offline .status-dot {
    background: #dc3545;
}

/* 仅显示圆点的在线状态 */
.status-dot-only {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.status-dot-only.online {
    background: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.2);
}

.status-dot-only.offline {
    background: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

/* 首页样式 */
.home-body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
}

.home-nav {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
}

.home-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 24px 40px;
}

.hero-title {
    font-size: 48px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin-bottom: 60px;
    text-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.section-title {
    font-size: 20px;
    color: rgba(255,255,255,0.8);
    margin-bottom: 24px;
}

.event-list {
    display: grid;
    gap: 16px;
}

.event-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s;
}

.event-card:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.event-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    background: #fff;
}

.event-info {
    flex: 1;
}

.event-name {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.event-enter {
    padding: 12px 28px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.event-enter:hover {
    background: #357abd;
}

/* 管理赛事列表 - 条形样式 */
.manage-event-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.manage-event-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s;
}

.manage-event-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.manage-event-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f0;
}

.manage-event-info {
    flex: 1;
}

.manage-event-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.manage-event-id {
    font-size: 13px;
    color: #888;
}

.manage-event-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.manage-event-status.open {
    background: #d4edda;
    color: #155724;
}

.manage-event-status.closed {
    background: #f8d7da;
    color: #721c24;
}

.manage-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.manage-event-status.open .manage-status-dot {
    background: #28a745;
}

.manage-event-status.closed .manage-status-dot {
    background: #dc3545;
}

.manage-enter-btn {
    padding: 8px 16px;
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 60px;
    color: rgba(255,255,255,0.5);
}

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

.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.login-logo img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    color: #1a1a2e;
}

.login-subtitle {
    text-align: center;
    color: #888;
    font-size: 14px;
    margin-bottom: 24px;
}

/* 上传区域 */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #4a90d9;
    background: #f8f9fa;
}

.upload-area.has-image {
    border-style: solid;
    border-color: #4a90d9;
    padding: 20px;
}

.upload-preview {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* 加载动画 */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 提示消息 */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 10001;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #27ae60;
}

.toast.error {
    background: #e74c3c;
}

/* 响应式 */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar .sidebar-text {
        opacity: 0;
        width: 0;
    }

    .sidebar .sidebar-footer {
        display: none;
    }
    
    .main-content {
        margin-left: 60px;
        padding: 16px;
    }
    
    .hero-title {
        font-size: 32px;
    }
    
    .event-card {
        flex-direction: column;
        text-align: center;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .toolbar .btn {
        width: 100%;
        justify-content: center;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4a90d9;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* 事件列表 */
.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.event-manage-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.3s;
}

.event-manage-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.event-manage-header {
    height: 120px;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-manage-logo {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    background: #fff;
    padding: 4px;
}

.event-manage-body {
    padding: 20px;
}

.event-manage-name {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.event-manage-id {
    font-size: 13px;
    color: #888;
}

.event-manage-status {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
}

.event-manage-status.open {
    background: #d4edda;
    color: #155724;
}

.event-manage-status.closed {
    background: #f8d7da;
    color: #721c24;
}
