/* 自定义样式 */

/* 美化滚动条 */
.overflow-x-auto::-webkit-scrollbar {
    height: 8px;
}

.overflow-x-auto::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.overflow-x-auto::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.content-auto {
    content-visibility: auto;
}

.card-shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

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

.nav-btn.active {
    color: #165DFF;
    font-weight: 500;
    position: relative;
}

.nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    background-color: #165DFF;
    border-radius: 1.5px;
}

.input-focus {
    transition: all 0.2s ease;
}

.input-focus:focus {
    outline: none;
    border-color: #165DFF;
    box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.2);
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

/* 按钮尺寸变体 */
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* 按钮禁用状态 */
.btn[disabled],
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary {
    background-color: #165DFF;
    color: white;
}

.btn-primary:hover {
    background-color: rgba(22, 93, 255, 0.9);
}

.btn-primary:active {
    background-color: rgba(22, 93, 255, 0.8);
}

.btn-outline {
    border: 1px solid #d1d5db;
    color: #1D2129;
    background-color: white;
}

.btn-outline:hover {
    background-color: #f9fafb;
}

.btn-outline:active {
    background-color: #f3f4f6;
}

.btn-success {
    background-color: #52C41A;
    color: white;
}

.btn-success:hover {
    background-color: rgba(82, 196, 26, 0.9);
}

.btn-success:active {
    background-color: rgba(82, 196, 26, 0.8);
}

.btn-warning {
    background-color: #FAAD14;
    color: white;
}

.btn-warning:hover {
    background-color: rgba(250, 173, 20, 0.9);
}

.btn-warning:active {
    background-color: rgba(250, 173, 20, 0.8);
}

.btn-danger {
    background-color: #F5222D;
    color: white;
}

.btn-danger:hover {
    background-color: rgba(245, 34, 45, 0.9);
}

.btn-danger:active {
    background-color: rgba(245, 34, 45, 0.8);
}

.table-hover-row {
    transition: background-color 0.2s ease;
}

.table-hover-row:hover {
    background-color: #f9fafb;
}

/* 调整规格和加工类型输入框的宽度，使其完全适应单元格且不超出 */
.item-specification,
.item-processing-type {
    width: 100%;
    box-sizing: border-box;
}

/* 开单页面：当选择“其他”时的自定义输入框样式 */
.invoice-items-container .specification-text,
.invoice-items-container .processing-type-text,
.invoice-items-container .unit-text {
    display: block;
    margin-top: 4px;
}

.invoice-items-container .specification-text.hidden,
.invoice-items-container .processing-type-text.hidden,
.invoice-items-container .unit-text.hidden {
    display: none !important;
}

/* 表格固定布局 */
.table-fixed {
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

.table-fixed th,
.table-fixed td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 调小序号列宽度 */
.table-fixed th:first-child,
.table-fixed td:first-child {
    min-width: 50px;
    width: 50px;
    text-align: center;
}

.invoice-items-container {
    max-height: 60vh;
    overflow-y: auto;
}

.table-fixed thead,
.table-fixed tfoot {
    position: sticky;
    z-index: 10;
}

.table-fixed thead {
    top: 0;
}

.table-fixed tfoot {
    bottom: 0;
}

/* 优化输入框样式，增加大小和可操作性 */
.invoice-items-container input[type="text"],
.invoice-items-container input[type="number"],
.invoice-items-container select {
    border-radius: 4px;
    transition: all 0.2s ease;
    padding: 10px 12px !important;
    font-size: 14px !important;
    height: 44px !important;
    box-sizing: border-box;
    width: 100% !important;
}

/* 发票明细区域滚动条 */
.invoice-items-container::-webkit-scrollbar {
    width: 8px;
}

.invoice-items-container::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.invoice-items-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.invoice-items-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 调整单元格内边距，让输入框有更多空间 */
.table-fixed td {
    padding: 4px !important;
}

/* 表头保持适当内边距 */
.table-fixed th {
    padding: 10px 6px !important;
}

/* 确保金额列宽度足够显示5位数 */
.table-fixed th:nth-child(11),
.table-fixed td:nth-child(11) {
    min-width: 100px;
    width: 100px;
}

.invoice-items-container input[type="text"]:focus,
.invoice-items-container input[type="number"]:focus,
.invoice-items-container select:focus {
    outline: none;
    border-color: #4A90E2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

/* 登录页面样式 */
.login-page {
    min-height: 100vh;
    background: #f5f6fb;
    font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: #1D2129;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 980px;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(15, 23, 42, 0.08);
    border: 1px solid #eef0f3;
    display: flex;
    overflow: hidden;
}

.login-info {
    flex: 1;
    background-color: #165DFF;
    color: #ffffff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-brand-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.login-brand-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
}

.login-brand-desc {
    margin-top: 0.25rem;
    opacity: 0.85;
}

.login-highlights {
    margin-top: 2rem;
    line-height: 1.75;
    font-size: 0.95rem;
    opacity: 0.95;
}

.login-highlights i {
    margin-right: 0.5rem;
    color: #b0d1ff;
}

.login-version {
    font-size: 0.85rem;
    opacity: 0.8;
}

.login-panel {
    flex: 1;
    padding: 3rem;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-panel-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.login-panel-header p {
    color: #86909C;
    margin-bottom: 1.5rem;
}

.login-form {
    width: 100%;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1D2129;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #165DFF;
    box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
}

/* 登录页面移动端优化 */
@media (max-width: 768px) {
    .login-container {
        padding: 1.5rem;
    }

    .login-card {
        flex-direction: column;
        border-radius: 16px;
    }

    .login-info {
        padding: 2rem 1.75rem;
        text-align: center;
        align-items: center;
    }

    .login-panel {
        padding: 2rem 1.75rem;
    }

    .login-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
}

.login-footer {
    margin-top: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #86909C;
    font-size: 0.9rem;
}

.login-link {
    color: #165DFF;
    text-decoration: none;
    font-weight: 500;
}

.login-link:hover {
    text-decoration: underline;
}

.error-message {
    background-color: #fee;
    color: #c33;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* 响应式 */
@media (max-width: 960px) {
    .login-card {
        flex-direction: column;
    }

    .login-info {
        padding: 2.25rem;
    }

    .login-panel {
        padding: 2.25rem;
    }
}

@media (max-width: 640px) {
    .login-container {
        padding: 1.5rem;
    }

    .login-panel {
        padding: 2rem 1.5rem;
    }

    .login-footer {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* 模态框动画效果 */
#invoice-detail-modal {
    animation: fadeIn 0.2s ease-out;
}

#invoice-detail-modal.hidden {
    animation: fadeOut 0.2s ease-out;
}

#invoice-detail-modal > div {
    animation: slideUp 0.3s ease-out;
}

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

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

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

/* 自定义确认对话框动画 */
@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-scale-in {
    animation: scaleIn 0.2s ease-out;
}

/* 模态框内的表格滚动条美化 */
#invoice-detail-content .overflow-x-auto::-webkit-scrollbar {
    height: 6px;
}

#invoice-detail-content .overflow-x-auto::-webkit-scrollbar-track {
    background: #f8f8f8;
}

#invoice-detail-content .overflow-x-auto::-webkit-scrollbar-thumb {
    background: #165DFF;
    border-radius: 3px;
}

#invoice-detail-content .overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: #0d47a1;
}

/* 打印样式 */
@media print {
    /* 隐藏侧边栏、模态框和打印预览工具栏 */
    #contact-sidebar,
    #global-wechat-qr-modal,
    #print-preview-modal {
        display: none !important;
    }

    /* 隐藏导航栏 */
    header {
        display: none !important;
    }

    /* 移除主内容区域的左边距，恢复全宽 */
    main, header {
        margin-left: 0 !important;
        left: 0 !important;
        width: 100% !important;
    }

    /* 隐藏所有按钮和不需要打印的元素 */
    .no-print,
    button,
    .btn {
        display: none !important;
    }

    /* 默认：隐藏所有页面 */
    #home-section,
    #query-section,
    #invoice-section,
    #admin-section {
        display: none !important;
    }

    /* 默认：隐藏打印容器 */
    #print-content {
        display: none !important;
    }

    /* 当打印查询结果时：只显示打印容器 */
    body.printing-query-results #print-content {
        display: block !important;
        margin: 0;
        padding: 20px;
    }

    body.printing-query-results #home-section,
    body.printing-query-results #query-section,
    body.printing-query-results #invoice-section,
    body.printing-query-results #admin-section {
        display: none !important;
    }

    /* 当打印发票表单时：只显示打印容器 */
    body.printing-invoice-form #print-content {
        display: block !important;
        margin: 0;
        padding: 20px;
    }

    body.printing-invoice-form #home-section,
    body.printing-invoice-form #query-section,
    body.printing-invoice-form #invoice-section,
    body.printing-invoice-form #admin-section {
        display: none !important;
    }

    /* 当打印详情发票时：只显示打印容器 */
    body.printing-detail-invoice #print-content {
        display: block !important;
        margin: 0;
        padding: 20px;
    }

    body.printing-detail-invoice #home-section,
    body.printing-detail-invoice #query-section,
    body.printing-detail-invoice #invoice-section,
    body.printing-detail-invoice #admin-section {
        display: none !important;
    }

    /* 其他情况：不打印任何内容（兼容旧逻辑） */
    body:not(.printing-query-results):not(.printing-invoice-form):not(.printing-detail-invoice) #print-content {
        display: none !important;
    }

    /* 打印容器样式 */
    .print-invoices-container,
    .print-invoice-container,
    .print-detail-invoice-container {
        width: 100%;
        max-width: 100%;
    }

    .print-invoices-container h1,
    .print-invoice-container h1,
    .print-detail-invoice-container h1 {
        font-size: 24px;
        margin-bottom: 20px;
        text-align: center;
    }

    .print-invoices-container table,
    .print-invoice-container table,
    .print-detail-invoice-container table {
        font-size: 11px;
        width: 100%;
    }

    .print-invoice-container .invoice-header,
    .print-detail-invoice-container .invoice-header {
        margin-bottom: 20px;
        padding: 10px;
        background: #f9f9f9;
        border-radius: 4px;
    }

    .print-invoice-container h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    /* 移除卡片背景和阴影 */
    .card-shadow,
    .bg-white {
        box-shadow: none !important;
    }

    /* 优化表格打印 */
    table {
        page-break-inside: auto;
        border-collapse: collapse;
        width: 100%;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    thead {
        display: table-header-group;
    }

    tfoot {
        display: table-footer-group;
    }

    /* 表格边框 */
    .invoice-items-container table {
        border: 1px solid #000 !important;
        width: 100%;
    }

    .invoice-items-container th,
    .invoice-items-container td {
        border: 1px solid #000 !important;
        padding: 8px !important;
    }

    /* 输入框在打印时显示为文本 */
    input[type="text"],
    input[type="number"],
    input[type="date"] {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        font-weight: normal !important;
    }

    select {
        border: none !important;
        background: transparent !important;
        appearance: none !important;
        -webkit-appearance: none !important;
    }

    /* 总金额突出显示 */
    #invoice-total-amount {
        font-size: 20px !important;
        font-weight: bold !important;
    }

    /* 确保工厂标题红色显示 */
    .text-red-600 {
        color: #dc2626 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* 隐藏表格的tfoot（因为已经有总金额显示区域了）*/
    .invoice-items-container tfoot {
        display: none !important;
    }

    /* 页面设置 */
    @page {
        margin: 1cm;
        size: A4;
    }

    body {
        margin: 0;
        padding: 0;
    }
}
