/* 基础样式 */
.annotation-box {
    position: absolute;
    border: 2px solid;
    pointer-events: none;
    box-sizing: border-box;
}

.annotation-label {
    position: absolute;
    top: -24px;
    left: -2px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    border-radius: 3px 3px 0 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.transition-all-300 {
    transition: all 0.3s ease;
}

.sidebar {
    scrollbar-width: thin;
    scrollbar-color: #9CA3AF #F3F4F6;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #F3F4F6;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: #9CA3AF;
    border-radius: 4px;
}

.small-row {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

/* 加载指示器 */
#loading-indicator {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    display: none;
}

.loading-spinner {
    animation: spin 1s linear infinite;
    border-radius: 50%;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3B82F6;
    width: 3rem;
    height: 3rem;
}

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

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

.pulse {
    animation: pulse 2s infinite;
}

/* 响应式调整 */
@media (max-width: 1024px) {
    .lg\:flex-row {
        flex-direction: column;
    }
    
    .lg\:w-1\/4, .lg\:w-3\/4 {
        width: 100%;
    }
    
    .annotation-label {
        font-size: 10px;
        top: -20px;
    }
}

@media (max-width: 768px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    #image-container {
        height: 50vh;
    }
}

/* 核心标注预览容器样式 */
#image-container {
    position: relative;
    background-color: #f3f4f6;
    border-radius: 0.5rem;
    overflow: auto;
    height: 70vh;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    width: 100%;
}

/* 图像显示样式 */
.image-display {
    max-width: none;
    max-height: none;
    object-fit: contain;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}

/* 图片包装容器 */
.image-wrapper {
    position: relative;
    display: inline-block;
    text-align: center;
    max-width: 100%;
    max-height: 100%;
}

/* 标注画布容器 */
.annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 空状态提示 */
#empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

/* 错误提示样式 */
.error-message {
    background-color: #fef2f2;
    border-left: 4px solid #ef4444;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0 4px 4px 0;
}

.error-message h3 {
    color: #ef4444;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

/* 模态框样式 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    max-width: 90%;
    width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}
/* 确保hidden类有效 */
.hidden {
    display: none !important;
}

/* 表格样式 */
.annotation-table {
    width: 100%;
    border-collapse: collapse;
}

.annotation-table th {
    background-color: #f9fafb;
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: #6b7280;
}

.annotation-table td {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
}

.annotation-table tr:nth-child(even) {
    background-color: #f9fafb;
}

/* 布局兜底：确保移动端顺序与桌面端两列布局在无 Tailwind 时也生效 */
/* 移动端默认纵向：预览(1) → 侧栏(2) → 详情(3)，侧栏内：类别(1) → 图片(2) */
#layout { display: flex; flex-direction: column; gap: 1.5rem; }
#preview { order: 1; }
#sidebar { order: 2; display: flex; flex-direction: column; gap: 1.5rem; }
#details { order: 3; }
#categories { order: 1; }
#images { order: 2; }

/* 桌面端兜底为两列：左侧侧栏（跨两行），右侧预览在上、详情在下 */
@media (min-width: 1024px) {
  #layout { display: grid; grid-template-columns: 25% 75%; grid-auto-rows: auto; gap: 1.5rem; }
  #sidebar { grid-column: 1; grid-row: 1 / span 2; }
  #preview { grid-column: 2; grid-row: 1; }
  #details { grid-column: 2; grid-row: 2; }
  /* 桌面侧栏内部顺序：图片在上、类别在下 */
  #images { order: 1; }
  #categories { order: 2; }
}
