/* ================================================================
   easyarchive_book v2.0 — 全局自定义样式
   配色与 v1.1 tkinter 版本保持一致
   ================================================================ */

:root {
    --welcome-bg:      #F5F7FA;
    --card-bg:         #FFFFFF;
    --card-border:     #DCE3EA;
    --card-hover:      #3B6CB4;
    --title-color:     #1A2332;
    --subtitle-color:  #5A6978;
    --accent-blue:     #2C5F9E;
    --accent-green:    #1B7E4B;
    --back-btn-bg:     #E8ECF0;
    --back-btn-hover:  #D0D7E0;
    --status-bg:       #E8EEF4;
    --status-text:     #1A365D;
    --section-color:   #1A365D;
    --danger-red:      #DC2626;
    --warning-amber:   #D97706;
    --font-family:     "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--welcome-bg);
    margin: 0;
    min-height: 100vh;
}

/* Alpine.js x-cloak — 隐藏未初始化的元素 */
[x-cloak] { display: none !important; }

/* 卡片悬停效果 */
.card-hover:hover {
    border-color: var(--card-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 108, 180, 0.15);
    transition: all 0.2s ease;
}

/* 状态栏 */
.status-bar {
    background-color: var(--status-bg);
    color: var(--status-text);
    font-weight: bold;
    font-size: 14px;
}

/* 表单分区标题 */
.section-title {
    color: var(--section-color);
    font-weight: bold;
    font-size: 14px;
}

/* ================================================================
   录入表单 Grid — 桌面式双字段行：标签|控件|标签|控件
   字号偏小、标签列略宽，避免长标签挤出/遮挡控件
   ================================================================ */
.form-grid {
    display: grid;
    grid-template-columns: 96px minmax(0, 1.15fr) 96px minmax(0, 1fr);
    gap: 6px 10px;
    align-items: center;
}

.form-grid label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    text-align: right;
    padding: 0 4px 0 0;
    line-height: 1.25;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    font-size: 12px;
    padding: 4px 8px;
    min-height: 28px;
    box-sizing: border-box;
    max-width: 100%;
}

/* 题名等整行跨两列：标签 + 跨 3 格的控件区 */
.form-grid .span-fields {
    grid-column: 2 / -1;
}
.form-grid .span-full {
    grid-column: 1 / -1;
}
.form-grid .span-label-wide {
    grid-column: 1 / 2;
}
.form-grid .col-span-2 {
    grid-column: 1 / -1;
}

/* 管理端编辑弹窗 */
.modal-overlay .form-grid {
    grid-template-columns: 96px minmax(0, 1fr) 96px minmax(0, 1fr);
    gap: 6px 10px;
}
.modal-overlay .form-grid input,
.modal-overlay .form-grid select,
.modal-overlay .form-grid textarea {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 12px;
}

/* 录入端分区 */
.entry-section {
    background: #fff;
    border: 1px solid #DCE3EA;
    border-radius: 6px;
    padding: 6px 10px;
    overflow: hidden;
}
.entry-section-title {
    color: var(--section-color);
    font-weight: bold;
    font-size: 12px;
    margin: 0 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #E8EEF4;
    flex-shrink: 0;
}

/* 录入页：占满视口、底栏固定 */
.entry-page {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}
.entry-page-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 30%);
    gap: 8px;
    padding: 8px 12px;
    overflow: hidden;
}
.entry-page-form {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
}
/* 分区随内容增高，空间够时均分；过挤时顶部对齐并允许整区滚动，避免裁切遮挡 */
.entry-page-form > .entry-section {
    flex: 1 1 auto;
    min-height: min-content;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
.entry-page-side {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.entry-page-footer {
    flex-shrink: 0;
    border-top: 1px solid #DCE3EA;
    background: #F8FAFC;
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}
.entry-page-footer .footer-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #1A2332;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.entry-page-footer .footer-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #2C5F9E;
}
.entry-page-footer .footer-btn {
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 6px;
}
.entry-page-footer .footer-btn-primary {
    font-size: 13px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 6px;
}
.entry-scan-bar {
    flex-shrink: 0;
    padding: 6px 10px;
    background: #F8FAFC;
    border-bottom: 1px solid #E5E7EB;
}
.entry-scan-bar .scan-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 10px;
}
.entry-scan-bar label {
    font-size: 12px !important;
}
.entry-scan-bar input[type="text"] {
    font-size: 13px !important;
    min-height: 30px;
    padding: 4px 8px;
}
.entry-scan-bar button,
.entry-scan-bar select {
    font-size: 12px !important;
    min-height: 30px;
}
.entry-cover-box {
    flex: 1;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6B7280;
    border: 1px dashed #D1D5DB;
    border-radius: 4px;
    background: #F9FAFB;
    overflow: hidden;
    font-size: 12px;
}

/* 数据表格 */
.data-table th {
    background-color: #1A365D;
    color: white;
    font-weight: bold;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.data-table td {
    font-size: 14px;
    vertical-align: middle;
}
.data-table tr:hover td {
    background-color: #EBF5FB;
}

/* ================================================================
   快速操作栏
   ================================================================ */
.quick-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.quick-bar label {
    font-size: 13px;
    font-weight: 600;
    color: #4B5563;
}

.quick-bar .divider {
    width: 1px;
    height: 20px;
    background: #D1D5DB;
    margin: 0 0.25rem;
}

/* ================================================================
   弹窗 (Modal)
   ================================================================ */
.modal-overlay {
    background-color: rgba(0, 0, 0, 0.45);
    animation: fadeIn 0.15s ease;
}

.modal-overlay > .bg-white {
    animation: slideUp 0.2s ease;
}

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

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

/* ================================================================
   加载 spinner
   ================================================================ */
.spinner {
    border: 3px solid #E5E7EB;
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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

/* ================================================================
   通知动画
   ================================================================ */
.notification-enter {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ================================================================
   最近录入列表
   ================================================================ */
.recent-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.recent-table thead th {
    background: #F3F4F6;
    color: #6B7280;
    font-weight: 600;
    text-align: left;
    padding: 6px 12px;
    white-space: nowrap;
    border-bottom: 1px solid #E5E7EB;
}

.recent-table tbody td {
    padding: 4px 12px;
    border-bottom: 1px solid #F3F4F6;
}

.recent-table tbody tr:hover td {
    background-color: #EFF6FF;
}

/* ================================================================
   按钮预设
   ================================================================ */
.btn-primary {
    background-color: var(--accent-blue);
    color: white;
    font-weight: bold;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.15s;
}
.btn-primary:hover:not(:disabled) {
    background-color: #1E4478;
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #E5E7EB;
    color: #374151;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.15s;
}
.btn-secondary:hover {
    background-color: #D1D5DB;
}

.btn-danger {
    color: var(--danger-red);
    font-size: 12px;
    transition: color 0.15s;
}
.btn-danger:hover {
    color: #991B1B;
}

.btn-success {
    background-color: var(--accent-green);
    color: white;
    font-weight: bold;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-size: 14px;
    transition: background-color 0.15s;
}
.btn-success:hover {
    background-color: #145C34;
}

/* ================================================================
   输入框焦点环
   ================================================================ */
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    ring: 2px solid var(--accent-blue);
}

/* ================================================================
   只读字段样式
   ================================================================ */
input[readonly],
input[data-readonly] {
    background-color: #F3F4F6;
    cursor: default;
}

/* ================================================================
   分页控件
   ================================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 13px;
}
.pagination button {
    padding: 4px 12px;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: all 0.15s;
}
.pagination button:hover:not(:disabled) {
    background: #F3F4F6;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.pagination button.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* ================================================================
   响应式：小屏单列
   ================================================================ */
@media (max-width: 1100px) {
    .entry-page-body {
        grid-template-columns: minmax(0, 1fr) minmax(260px, 32%);
    }
}
@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 88px minmax(0, 1fr);
    }
    .entry-page-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .entry-page-side {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .entry-page-side .entry-section {
        flex: 1;
        min-width: 200px;
    }
}
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-grid label {
        text-align: left;
        padding-top: 0;
    }
    .entry-page {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .quick-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-table {
        font-size: 12px;
    }
    .data-table th,
    .data-table td {
        padding: 4px 6px;
    }
}

/* ================================================================
   滚动条美化 (Webkit)
   ================================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #F3F4F6;
}
::-webkit-scrollbar-thumb {
    background: #C4C4C4;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #A0A0A0;
}
