/* Alpine.js x-cloak - 防止未初始化元素闪现 */
[x-cloak] {
    display: none !important;
}

body {
    padding-bottom: 60px;
}

.footer {
    position: relative;
    bottom: 0;
    width: 100%;
    background-color: #f8f9fa;
}

.jumbotron {
    margin-bottom: 0;
}

.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.table td, .table th {
    vertical-align: middle;
}

.badge {
    font-size: 0.9em;
    padding: 0.5em 0.7em;
}

.progress {
    height: 20px;
    font-size: 0.75rem;
}

.navbar-brand {
    font-weight: bold;
}

.card-header h5 {
    margin-bottom: 0;
}

.modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.img-fluid {
    max-width: 100%;
    height: auto;
}

#salesControlTableBody tr:hover {
    cursor: pointer;
}

.btn-group-sm > .btn, .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* ===== 触摸目标工具类 ===== */
.touch-target {
    min-width: 44px;
    min-height: 44px;
}

.touch-target-lg {
    min-width: 48px;
    min-height: 48px;
}

/* ===== 移动端特定工具类 ===== */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

/* ===== 触摸反馈 ===== */
@media (hover: none) {
    button:active,
    a:active,
    [role="button"]:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

.touch-active {
    background-color: rgba(0, 0, 0, 0.05) !important;
    transform: scale(0.98);
    transition: all 0.15s ease;
}

/* ===== 表格触摸滚动优化 ===== */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
}

/* ===== 响应式组件样式 ===== */
.jumbotron {
    padding: 1rem;
}

@media (min-width: 768px) {
    .jumbotron {
        padding: 2rem;
    }
}

@media (min-width: 1024px) {
    .jumbotron {
        padding: 3rem;
    }
}

.table-responsive {
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .table-responsive {
        font-size: 1rem;
    }
}

/* ===== 模态框移动端优化 ===== */
@media (max-width: 768px) {
    .modal-dialog {
        width: 95% !important;
        height: 90vh !important;
        margin: 2.5vh auto !important;
    }
    
    .modal-content {
        height: 100%;
    }
    
    .modal-body {
        max-height: calc(90vh - 120px);
    }
}

/* ===== Flatpickr 日期高亮 ===== */
.flatpickr-day.has-data {
    background: #667eea !important;
    color: white !important;
    border-color: #667eea !important;
    font-weight: bold;
}

.flatpickr-day.has-data:hover {
    background: #764ba2 !important;
    border-color: #764ba2 !important;
}

.flatpickr-day.has-data.selected {
    background: #16a34a !important;
    border-color: #16a34a !important;
}

/* ===== 房间详细信息 Modal ===== */

/* Modal 遮罩层 */
.fixed.inset-0.z-50 {
    backdrop-filter: blur(4px);
}

/* Modal 容器 - 移动端优先 */
.bg-white.rounded-2xl {
    /* 移动端默认全屏 */
    width: 95%;
    max-width: 95%;
    
    /* 移动端高度 */
    max-height: 90vh;
    
    /* 动画优化 */
    will-change: transform, opacity;
}

/* Modal 头部 - 移动端 */
.bg-white.rounded-2xl .px-6.py-4 {
    /* 确保头部固定 */
    flex-shrink: 0;
}

/* Modal 内容 - 移动端滚动优化 */
.bg-white.rounded-2xl .overflow-y-auto {
    /* 平滑滚动 */
    -webkit-overflow-scrolling: touch;
    
    /* 移动端滚动条样式 */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.bg-white.rounded-2xl .overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.bg-white.rounded-2xl .overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

.bg-white.rounded-2xl .overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Modal 底部按钮 - 移动端 */
.bg-white.rounded-2xl .border-t button {
    /* 确保触摸目标足够大 */
    min-height: 48px;
    min-width: 48px;
}

/* ===== 响应式设计 ===== */

/* 平板端 (768px+) */
@media (min-width: 768px) {
    .bg-white.rounded-2xl {
        /* 平板端居中，固定宽度 */
        width: auto;
        max-width: 42rem; /* 672px */
        max-height: 85vh;
    }
    
    /* Modal 底部按钮 - 平板端 */
    .bg-white.rounded-2xl .border-t button {
        min-height: 44px;
        min-width: auto;
    }
}

/* 桌面端 (1024px+) */
@media (min-width: 1024px) {
    .bg-white.rounded-2xl {
        /* 桌面端更大一点 */
        max-width: 48rem; /* 768px */
        max-height: 80vh;
    }
}

/* 大屏 (1280px+) */
@media (min-width: 1280px) {
    .bg-white.rounded-2xl {
        max-width: 56rem; /* 896px */
    }
}

/* ===== Tooltip 样式 ===== */

/* Tooltip 容器 */
.fixed.bg-gray-900.text-white {
    /* 确保 Tooltip 在最上层 */
    pointer-events: none;
    
    /* 文字优化 */
    white-space: nowrap;
    
    /* 阴影增强 */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    
    /* 动画优化 */
    will-change: transform, opacity;
}

/* Tooltip 箭头（可选，使用伪元素） */
.fixed.bg-gray-900.text-white::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #111827;
}

/* ===== 动画优化 ===== */

/* Modal 和 Tooltip 的过渡动画 */
[x-cloak] {
    display: none !important;
}

/* 过渡动画性能优化 */
[x-transition\:enter],
[x-transition\:leave] {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ===== 移动端特殊处理 ===== */

/* 移动端禁用 Tooltip（通过 CSS 进一步确保） */
@media (hover: none) and (pointer: coarse) {
    .fixed.bg-gray-900.text-white {
        display: none !important;
    }
}

/* 移动端 Modal 优化 */
@media (max-width: 767px) {
    /* Modal 距离边缘更近 */
    .fixed.inset-0.z-50 {
        padding: 0.5rem;
    }
    
    /* Modal 圆角在移动端更小 */
    .bg-white.rounded-2xl {
        border-radius: 1rem;
    }
    
    /* Modal 内容 padding 调整 */
    .bg-white.rounded-2xl .p-6 {
        padding: 1rem;
    }
    
    /* Modal 头部 padding 调整 */
    .bg-white.rounded-2xl .px-6.py-4 {
        padding: 1rem;
    }
    
    /* Modal 底部 padding 调整 */
    .bg-white.rounded-2xl .px-6.py-4.border-t {
        padding: 1rem;
    }
    
    /* 信息卡片 grid 调整 */
    .bg-white.rounded-2xl .grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* ===== 触摸反馈增强 ===== */

/* Modal 按钮触摸反馈 */
.bg-white.rounded-2xl button:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* 关闭按钮触摸反馈 */
.bg-white.rounded-2xl .rounded-full:active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* ===== 无障碍优化 ===== */

/* Modal 焦点管理 */
.bg-white.rounded-2xl:focus {
    outline: none;
}

.bg-white.rounded-2xl button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ===== 性能优化 ===== */

/* 减少动画（用户偏好） */
@media (prefers-reduced-motion: reduce) {
    [x-transition\:enter],
    [-transition\:leave] {
        transition: none !important;
    }
    
    .fixed.bg-gray-900.text-white {
        transition: none !important;
    }
}

/* ===== 打印样式 ===== */

@media print {
    .fixed.inset-0.z-50 {
        display: none !important;
    }
    
    .fixed.bg-gray-900.text-white {
        display: none !important;
    }
}

/* ===== 确认框样式 ===== */

/* 桌面端确认框 - Tooltip 风格 */
.confirm-tooltip {
    position: fixed;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 70;
    min-width: 280px;
    max-width: 360px;
    padding: 1rem;
    will-change: transform, opacity;
}

/* 箭头在底部（确认框在按钮上方） */
.confirm-tooltip.arrow-bottom::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

/* 箭头在顶部（确认框在按钮下方） */
.confirm-tooltip.arrow-top::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

/* 确认框内容 */
.confirm-content {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.5;
    margin-bottom: 1rem;
    white-space: pre-line;
}

/* 确认框按钮容器 */
.confirm-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* 确认框按钮基础样式 */
.confirm-btn {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 44px;
    min-width: 44px;
    border: none;
}

/* 取消按钮 */
.confirm-btn-cancel {
    background-color: #f3f4f6;
    color: #6b7280;
}

.confirm-btn-cancel:hover {
    background-color: #e5e7eb;
}

.confirm-btn-cancel:active {
    transform: scale(0.98);
}

/* 确认按钮 */
.confirm-btn-confirm {
    background-color: #ef4444;
    color: white;
}

.confirm-btn-confirm:hover {
    background-color: #dc2626;
}

.confirm-btn-confirm:active {
    transform: scale(0.98);
}

/* 移动端确认框 - 底部弹出 */
@media (max-width: 767px) {
    .confirm-tooltip {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        transform: none;
        min-width: auto;
        max-width: none;
        width: 100%;
        border-radius: 1.25rem 1.25rem 0 0;
        padding: 1.25rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }
    
    .confirm-tooltip::after {
        display: none;
    }
    
    .confirm-content {
        text-align: center;
        font-size: 1rem;
        padding: 0.5rem 0;
    }
    
    .confirm-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .confirm-btn {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
    }
}

/* 触摸反馈 */
@media (hover: none) {
    .confirm-btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    .confirm-tooltip {
        transition: none !important;
    }
}
