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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* 屏幕切换基础样式 */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: block;
}

/* 通用组件样式 */
h1 {
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
    color: #4CAF50;
}

h2 {
    font-size: 20px;
    margin: 15px 0;
    color: #333;
}

input {
    width: 100%;
    padding: 12px;
    margin: 10px 0 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background-color: #fff;
}

button {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background-color: #4CAF50;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #45a049;
}

button:active {
    background-color: #3e8e41;
}

ul {
    list-style-type: none;
}

/* 会话创建界面 */
#session-create {
    background-color: #fff;
}

#session-list {
    margin-top: 30px;
}

#sessions li {
    padding: 15px;
    margin: 10px 0;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#sessions li:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#sessions li span {
    display: block;
}

#sessions li span.session-time {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

#sessions li span.session-count {
    font-size: 14px;
    color: #4CAF50;
    margin-top: 5px;
    font-weight: bold;
}

/* 扫码界面 */
#scanning {
    position: relative;
    background-color: #000;
    color: #fff;
    padding: 0;
}

/* 扫码类型切换按钮 */
.scan-type-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 5px;
    z-index: 5;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 5px;
    border-radius: 8px;
}

.scan-type-toggle button {
    width: auto;
    padding: 6px 12px;
    margin: 0;
    font-size: 14px;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.scan-type-toggle button.active {
    background-color: #4CAF50;
    border-color: #4CAF50;
    color: #fff;
}

.scan-type-toggle button:hover {
    background-color: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

.camera-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    max-width: 400px;
    max-height: 400px;
    border: 2px solid #4CAF50;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
}

.scan-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #4CAF50;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; }
    100% { top: 100%; }
}

#scan-result {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.98);
    color: #333;
    padding: 20px;
    border-radius: 20px 20px 0 0;
    z-index: 10;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
    max-height: 70vh;
    overflow-y: auto;
}

#scan-result.hidden {
    display: none;
}

#result-text {
    margin: 15px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    word-break: break-all;
    font-size: 16px;
}

.scan-actions {
    display: flex;
    gap: 10px;
}

.scan-actions button {
    flex: 1;
    margin: 0;
}

.scan-actions button:nth-child(2) {
    background-color: #f44336;
}

.scan-actions button:nth-child(2):hover {
    background-color: #d32f2f;
}

.end-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: auto;
    padding: 8px 16px;
    background-color: #f44336;
    z-index: 5;
}

/* 会话详情界面 */
#session-detail {
    background-color: #fff;
}

.session-info {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.session-info p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

#scan-records {
    margin-top: 20px;
}

#records-list {
    background-color: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
}

#records-list li {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#records-list li:last-child {
    border-bottom: none;
}

.record-index {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #4CAF50;
    color: #fff;
    border-radius: 50%;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
}

.record-content {
    font-size: 16px;
    word-break: break-all;
    color: #333;
}

.record-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.detail-actions button {
    flex: 1;
    margin: 0;
}

#back-to-sessions {
    background-color: #666;
}

#back-to-sessions:hover {
    background-color: #555;
}

/* 响应式设计 */
@media (min-width: 480px) {
    .screen {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
    
    #scanning {
        max-width: none;
        margin: 0;
    }
}

@media (max-width: 360px) {
    h1 {
        font-size: 22px;
    }
    
    h2 {
        font-size: 18px;
    }
    
    button {
        padding: 10px;
        font-size: 15px;
    }
    
    .scan-overlay {
        width: 85%;
        height: 85%;
    }
    
    #scan-result {
        padding: 15px;
    }
}

/* 自定义模态对话框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-body {
    padding: 20px;
}

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

.modal-error {
    color: #f44336;
    font-size: 14px;
    margin-top: 10px;
    min-height: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-footer button {
    margin: 0;
    padding: 10px 20px;
    width: auto;
}

#modal-cancel {
    background-color: #666;
}

#modal-cancel:hover {
    background-color: #555;
}
/* 会话管理按钮样式 */
.session-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.session-actions button {
    flex: 1;
    padding: 8px;
    margin: 0;
    font-size: 14px;
}

.export-btn {
    background-color: #2196F3;
}

.export-btn:hover {
    background-color: #1976D2;
}

.edit-btn {
    background-color: #FF9800;
}

.edit-btn:hover {
    background-color: #F57C00;
}

.delete-btn {
    background-color: #f44336;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

.pause-btn {
    background-color: #FF9800;
}

.pause-btn:hover {
    background-color: #F57C00;
}

/* 自定义确认对话框 */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.confirm-dialog.show {
    opacity: 1;
    visibility: visible;
}

.confirm-dialog-content {
    background-color: #fff;
    border-radius: 12px;
    padding: 0;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.confirm-dialog.show .confirm-dialog-content {
    transform: scale(1);
}

.confirm-dialog-body {
    padding: 20px;
    text-align: center;
}

.confirm-dialog-body p {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.confirm-dialog-footer {
    padding: 15px 20px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.confirm-dialog-footer button {
    margin: 0;
    flex: 1;
}

.confirm-dialog-footer button#confirm-cancel {
    background-color: #f5f5f5;
    color: #666;
}

.confirm-dialog-footer button#confirm-cancel:hover {
    background-color: #e0e0e0;
}

.confirm-btn {
    background-color: #4CAF50 !important;
}

.confirm-btn:hover {
    background-color: #45a049 !important;
}

/* 自定义Toast通知 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    pointer-events: none;
    max-width: 80%;
    text-align: center;
}

.toast:not(.hidden) {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(100%);
    pointer-events: none;
}

.toast-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
}

#toast-message {
    margin: 0;
    font-size: 16px;
}

#toast-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

#toast-close:hover {
    background: none;
    color: #ddd;
}