/* Main Application Styles */

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: #F3F4F6;
    -webkit-tap-highlight-color: transparent;
}

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.modal-enter {
    animation: modalFadeIn 0.2s ease-out;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

.btn-press:active {
    transform: scale(0.95);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Swipe to delete styles */
.swipe-container {
    position: relative;
    overflow: hidden;
}

.swipe-content {
    transition: transform 0.3s ease;
}

.swipe-content.swiping {
    transition: none;
}

.swipe-delete-bg {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: #EF4444;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border-radius: 1rem;
    opacity: 0;
    pointer-events: none;
}

.swipe-container:active .swipe-delete-bg {
    opacity: 1;
}

/* Swipe to clear styles */
.swipe-clear-bg {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: #10B981;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border-radius: 0.75rem;
}

.swipe-unclear-bg {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: #F59E0B;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border-radius: 0.75rem;
}

.swipe-unclear-bg-left {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100px;
    background: #F59E0B;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    border-radius: 0.75rem;
}

.cleared-item {
    opacity: 0.7;
    background: linear-gradient(90deg, #D1FAE5 0%, #ECFDF5 100%) !important;
}

.cleared-badge {
    background: #10B981;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* Dark Mode Styles */
.dark {
    background-color: #000000 !important;
    color: #F9FAFB !important;
}

.dark .bg-white {
    background-color: #1a1a1a !important;
}

.dark .bg-gray-50 {
    background-color: #2a2a2a !important;
}

.dark .bg-gray-100 {
    background-color: #1a1a1a !important;
}

.dark .bg-green-50 {
    background-color: #064e3b !important;
}

.dark .bg-red-50 {
    background-color: #7f1d1d !important;
}

.dark .bg-blue-50 {
    background-color: #1e3a5f !important;
}

.dark .bg-purple-50 {
    background-color: #4c1d95 !important;
}

.dark .bg-purple-100 {
    background-color: #6B21A8 !important;
}

.dark .text-purple-600 {
    color: #E9D5FF !important;
}

.dark .text-gray-800,
.dark .text-gray-700,
.dark .text-gray-600 {
    color: #F9FAFB !important;
}

.dark .text-gray-500,
.dark .text-gray-400 {
    color: #9CA3AF !important;
}

.dark .text-black {
    color: #F9FAFB !important;
}

.dark .text-green-600,
.dark .text-green-700 {
    color: #4ADE80 !important;
}

.dark .text-red-500,
.dark .text-red-600 {
    color: #F87171 !important;
}

.dark .text-blue-600,
.dark .text-blue-700 {
    color: #60A5FA !important;
}

.dark .text-orange-600 {
    color: #FB923C !important;
}

.dark .border-gray-200,
.dark .border-gray-100 {
    border-color: #374151 !important;
}

.dark .border-black {
    border-color: #60A5FA !important;
}

.dark .shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.5) !important;
}

.dark input,
.dark select {
    background-color: #2a2a2a !important;
    color: #F9FAFB !important;
    border-color: #374151 !important;
}

.dark .font-bold {
    color: inherit;
}

.dark .slide-in-left {
    background-color: #1a1a1a !important;
}

.dark .border-t {
    border-color: #374151 !important;
}

.dark .hover\:bg-gray-100:hover {
    background-color: #374151 !important;
}

.dark .hover\:bg-gray-200:hover {
    background-color: #4B5563 !important;
}

.dark .border-2.border-black {
    border-color: #60A5FA !important;
}

.dark .border-2.border-gray-100 {
    border-color: #374151 !important;
}

.dark .border-transparent {
    border-color: transparent !important;
}

.dark span {
    color: inherit;
}

.dark button span {
    color: inherit;
}

.dark .rounded-xl span {
    color: inherit;
}

.dark .p-3 span:not(.text-2xl):not(.text-3xl) {
    color: #F9FAFB;
}

/* Dark mode button overrides */
.dark .settle-btn {
    background-color: #6B7280 !important;
    color: #F9FAFB !important;
}

.dark .fab-btn {
    background-color: #F5F5DC !important;
    color: #1a1a1a !important;
}

.dark .custom-total-amount {
    color: #9333EA !important;
}

.dark .filter-header-bar {
    background-color: #1E3A5F !important;
}

.dark .text-purple-800 {
    color: #A855F7 !important;
}

.dark .text-purple-700 {
    color: #A855F7 !important;
}

.dark .bg-green-100 {
    background-color: #065F46 !important;
}

.dark .bg-red-100 {
    background-color: #991B1B !important;
}

.dark .bg-blue-100 {
    background-color: #1E40AF !important;
}

.dark .border-green-500 {
    border-color: #10B981 !important;
}

.dark .border-purple-500 {
    border-color: #8B5CF6 !important;
}

.dark .border-purple-200 {
    border-color: #7C3AED !important;
}

.dark .bg-green-50.text-green-700 span {
    color: #4ADE80 !important;
}

.dark .border-gray-50 {
    border-color: #374151 !important;
}

.dark .bg-indigo-50 {
    background-color: #312E81 !important;
}

.dark .text-indigo-600 {
    color: #A5B4FC !important;
}

.dark .border-2.border-black .text-gray-800 {
    color: #1a1a1a !important;
}

.dark .ring-2.ring-black {
    --tw-ring-color: #60A5FA !important;
}

.dark .selected-book {
    background-color: #F9FAFB !important;
    border-color: #F9FAFB !important;
}

.dark .selected-book-text {
    color: #1a1a1a !important;
}

.dark .selected-book-subtext {
    color: #4B5563 !important;
}

/* 深色模式下共同帳本明細的日期和項目改為深灰色 */
.debt-detail-date {
    color: #374151;
}

.debt-detail-desc {
    color: #4B5563;
}

.dark .debt-detail-date {
    color: #9CA3AF !important;
}

.dark .debt-detail-desc {
    color: #9CA3AF !important;
}

.dark .cleared-item {
    background: linear-gradient(90deg, #064e3b 0%, #065F46 100%) !important;
}

/* Bottom Navigation Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-around;
    padding: 12px 0 max(env(safe-area-inset-bottom, 16px), 16px);
    z-index: 40;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.dark .bottom-nav {
    background: #1a1a1a;
    border-top-color: #374151;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.bottom-nav-item.active {
    color: #000000;
}

.bottom-nav-item:not(.active) {
    color: #9CA3AF;
}

.dark .bottom-nav-item.active {
    color: #FFFFFF;
}

.bottom-nav-label {
    font-size: 10px;
    font-weight: 700;
    margin-top: 2px;
}

/* Sticky Date Headers */
.sticky-date-header {
    position: sticky;
    top: 0;
    z-index: 15;
    background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
    padding: 8px 16px;
    margin: 16px -16px 8px -16px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

.dark .sticky-date-header {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

/* Quick Filter Pills */
.quick-filter-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
}

.quick-filter-pill {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    background: white;
    border: 2px solid #E5E7EB;
    color: #6B7280;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.quick-filter-pill.active {
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.dark .quick-filter-pill {
    background: #2a2a2a;
    border-color: #374151;
    color: #9CA3AF;
}

/* Pie Chart Container */
.pie-chart-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.pie-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--pie-colors));
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.pie-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dark .pie-chart-center {
    background: #1a1a1a;
}

/* Swipe Tutorial Overlay */
.swipe-tutorial {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.swipe-tutorial-hand {
    font-size: 48px;
    animation: swipeLeft 1.5s ease-in-out infinite;
}

@keyframes swipeLeft {

    0%,
    100% {
        transform: translateX(30px);
    }

    50% {
        transform: translateX(-30px);
    }
}

/* Animated Number */
.animated-number {
    display: inline-block;
    transition: all 0.3s ease;
}

/* Statistics View */
.stats-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.dark .stats-card {
    background: #1a1a1a;
}

.stats-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #F3F4F6;
}

.dark .stats-legend-item {
    border-bottom-color: #374151;
}

.stats-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Tab View Content */
.tab-content {
    min-height: calc(100vh - 200px);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: #1F2937;
    color: white;
    padding: 14px 24px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

.toast.error {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
}

.toast.warning {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Long Press Context Menu */
.context-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    animation: fadeIn 0.2s ease;
}

.context-menu {
    position: fixed;
    left: 50%;
    bottom: 100px;
    transform: translateX(-50%);
    background: white;
    border-radius: 20px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 91;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dark .context-menu {
    background: #1a1a1a;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.context-menu-item:hover {
    background: #F3F4F6;
}

.dark .context-menu-item:hover {
    background: #2a2a2a;
}

.context-menu-item.danger {
    color: #EF4444;
}

/* Quick Amount Buttons */
.quick-amount-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.quick-amount-btn {
    flex: 1;
    min-width: 60px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.quick-amount-btn:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    color: white;
}

/* Animated Number */
@keyframes countUp {
    from {
        opacity: 0.5;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.amount-animated {
    animation: countUp 0.3s ease-out;
}

/* Improved Card Styles */
.card-premium {
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.2s;
}

.card-premium:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.dark .card-premium {
    background: linear-gradient(145deg, #1a1a1a 0%, #222222 100%);
    border-color: rgba(255, 255, 255, 0.05);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 30px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.empty-state-title {
    font-size: 20px;
    font-weight: 900;
    color: #374151;
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 14px;
    color: #9CA3AF;
    margin-bottom: 24px;
}

.empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    color: white;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
    transition: all 0.2s;
}

.empty-state-btn:active {
    transform: scale(0.95);
}

/* Delete Confirmation Modal */
.confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.confirm-modal-content {
    background: white;
    border-radius: 24px;
    padding: 28px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    animation: fadeInScale 0.2s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.dark .confirm-modal-content {
    background: #1a1a1a;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Larger Touch Targets */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Loading Animation Keyframes */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(350%);
    }
}

/* Full Screen Modal Overrides - for member manager and transaction form */
.fullscreen-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 70;
    background: #F3F4F6 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
}

.fullscreen-modal>div {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.fullscreen-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
    border-bottom: 1px solid #E5E7EB;
    padding: 16px 24px;
    flex-shrink: 0;
}

.fullscreen-modal .modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

.dark .fullscreen-modal {
    background: #1a1a1a !important;
}

.dark .fullscreen-modal .modal-header {
    background: #1a1a1a;
    border-bottom-color: #374151;
}

/* Google AdSense Ad Container */
.ad-container {
    margin: 8px 0;
    min-height: 50px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark .ad-container {
    background: linear-gradient(135deg, #1e1e1e 0%, #2a2a2a 100%);
}

.ad-container .adsbygoogle {
    margin: 0 auto;
}

/* Hide empty ad container when ad fails to load */
.ad-container:empty {
    display: none;
}

/* Safe Area Bottom for Bottom Navigation */
.safe-area-bottom {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 0px);
}

/* Dark mode for bottom navigation bar */
.dark .bg-white.border-t.border-gray-200.shadow-lg {
    background-color: #1a1a1a !important;
    border-color: #374151 !important;
}