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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* 头部 */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

/* 主内容区 */
main {
    display: grid;
    gap: 20px;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* 等待面板 */
.waiting-panel {
    max-width: 600px;
    margin: 100px auto;
}

.waiting-content {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 30px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.waiting-text {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 20px;
}

.hint-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    text-align: left;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.hint-list li {
    padding: 10px 0;
    padding-left: 30px;
    position: relative;
    color: #555;
}

.hint-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

/* 会话检测显示 */
.session-detect {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.session-status {
    font-size: 1.2em;
    margin-bottom: 10px;
    font-weight: bold;
}

.session-id-display {
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 6px;
    word-break: break-all;
    font-size: 0.9em;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.2em;
    margin-top: 20px;
}

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

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* 状态面板 */
.status-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    transition: background 0.3s;
}

.status-dot.connected {
    background: #4caf50;
    box-shadow: 0 0 8px #4caf50;
    animation: pulse 2s infinite;
}

.status-dot.disconnected {
    background: #f44336;
}

.status-text {
    font-weight: 600;
    color: #333;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 0.9em;
}

.session-info code {
    flex: 1;
    background: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

/* 表单元素 */
.form-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.form-group label {
    font-weight: 600;
    color: #555;
    min-width: 120px;
}

.form-group input[type="number"],
.form-group input[type="text"] {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    min-width: 200px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.hint {
    color: #999;
    font-size: 0.85em;
    margin-top: 10px;
}

/* 按钮 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: #f0f0f0;
    color: #333;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
    color: white;
}

.btn-small {
    padding: 5px 15px;
    font-size: 0.9em;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-area.drag-over {
    border-color: #667eea;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-placeholder {
    color: #999;
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.image-preview {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preview-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.upload-methods {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
}

.btn-secondary:hover {
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.upload-hint {
    margin-top: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    text-align: center;
}

.upload-hint p {
    margin: 0;
    font-size: 1.1em;
    font-weight: 500;
}

.upload-hint.active {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* 队列信息 */
.queue-info {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
}

.info-item label {
    font-weight: 600;
    color: #555;
}

.info-item span {
    color: #667eea;
    font-weight: 600;
}

.control-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* 排队状态显示 */
.queue-display {
    display: grid;
    gap: 20px;
}

.position-indicator {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.position-number {
    font-size: 4em;
    font-weight: bold;
    margin-bottom: 10px;
}

.position-label {
    font-size: 1.1em;
    opacity: 0.9;
}

.queue-details {
    display: grid;
    gap: 10px;
}

/* 队列信息分块显示 */
.queue-info-blocks {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.queue-info-block-row {
    display: flex;
    gap: 15px;
}

.queue-info-block {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
}

.queue-info-block.vertical {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 5px;
}

.queue-info-block .queue-info-label {
    font-size: 1em;
    color: #6c757d;
    font-weight: 500;
}

.queue-info-block .queue-info-value {
    font-size: 1.1em;
    font-weight: bold;
    color: #495057;
}

.queue-info-block.vertical .queue-info-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #667eea;
}

.queue-info-block .status-badge {
    font-size: 1em;
}

/* 状态徽章 */
.status-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.status-badge.waiting {
    background: #fff3cd;
    color: #856404;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
    animation: pulse 2s infinite;
}

/* 图片显示区 */
.image-container {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.no-image {
    text-align: center;
    color: #999;
}

.waiting-icon {
    font-size: 5em;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

.image-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.countdown-timer {
    font-size: 1.2em;
    font-weight: bold;
    color: #ff6b6b;
    padding: 8px 16px;
    background: #fff3cd;
    border-radius: 8px;
    border: 2px solid #ffc107;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.countdown-timer #countdownValue {
    color: #dc3545;
    font-size: 1.3em;
    min-width: 30px;
    text-align: center;
}

/* 日志面板 */
.log-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.log-panel h2 {
    margin-bottom: 15px;
}

.log-container {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 8px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.info {
    color: #4fc3f7;
}

.log-entry.success {
    color: #81c784;
}

.log-entry.warning {
    color: #ffb74d;
}

.log-entry.error {
    color: #e57373;
}

/* 动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .card {
        padding: 15px;
    }
    
    .form-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-group label {
        min-width: auto;
    }
    
    .position-number {
        font-size: 3em;
    }
}

/* 滚动条样式 */
.log-container::-webkit-scrollbar {
    width: 8px;
}

.log-container::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* 会话列表容器 */
.session-list-container {
    text-align: center;
    padding: 20px;
}

.session-list-container .btn-block {
    width: 100%;
    max-width: 300px;
    margin-bottom: 20px;
}

/* 会话列表 */
.session-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
    text-align: left;
}

/* 会话卡片 */
.session-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s ease;
}

.session-card:hover {
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.session-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.session-id-short {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1em;
    color: #495057;
}

.session-status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.session-status-badge.status-has-image {
    background: #d4edda;
    color: #155724;
}

.session-status-badge.status-waiting {
    background: #fff3cd;
    color: #856404;
}

.session-card-body {
    margin-bottom: 12px;
}

.session-info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.9em;
}

.session-info-row .label {
    color: #6c757d;
    font-weight: 500;
}

.session-info-row .value {
    color: #495057;
}

.session-id-full {
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    word-break: break-all;
    max-width: 150px;
}

.session-card .btn {
    width: 100%;
}

/* 空状态 */
.session-empty,
.session-error {
    text-align: center;
    padding: 30px;
    color: #6c757d;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 15px;
}

.session-error {
    color: #dc3545;
    background: #f8d7da;
}

/* 无会话提示 */
.no-session .hint-list {
    margin-top: 20px;
}

/* 弹窗样式 */
.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: 1000;
}

.modal {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.modal-content {
    margin-bottom: 20px;
    font-size: 1.1em;
    color: #333;
}

.modal-content.modal-error {
    color: #dc3545;
}

.modal-content.modal-warning {
    color: #ffc107;
}
