/* Print styles */
@media print {
    body * {
        visibility: hidden;
    }
    #printable-area, #printable-area * {
        visibility: visible;
    }
    #printable-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
    }
    .no-print {
        display: none !important;
    }
    .print-border {
        border: 1px solid #000 !important;
    }
    /* Hide FAQ section in print */
    #how-to-use-section {
        display: none !important;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Number input styling - remove spinner buttons */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

input[type=number] {
    -moz-appearance: textfield !important;
}

/* Ensure no spinners on any browser */
.note-input, .coin-input, #convert-amount-input {
    -webkit-appearance: none !important;
    -moz-appearance: textfield !important;
    appearance: none !important;
    margin: 0 !important;
}

/* Smooth transitions */
.transition-all {
    transition: all 0.3s ease;
}

/* Mobile button group - Clean layout */
.mobile-btn-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
}

.mobile-calc-btn {
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mobile-calc-btn.decrease-btn {
    background-color: #fee2e2;
    color: #dc2626;
    border-radius: 0.25rem 0 0 0.25rem;
}

.mobile-calc-btn.increase-btn {
    background-color: #d1fae5;
    color: #059669;
    border-radius: 0 0.25rem 0.25rem 0;
}

.mobile-calc-btn:hover {
    opacity: 0.8;
}

.mobile-calc-btn .btn-icon {
    width: 0.75rem;
    height: 0.75rem;
}

.mobile-calc-input {
    width: 2.5rem;
    height: 1.75rem;
    padding: 0;
    text-align: center;
    border: 1px solid #d1d5db;
    border-left: none;
    border-right: none;
    background: white;
    font-size: 0.75rem;
    font-weight: 500;
    color: #1f2937;
    flex-shrink: 0;
}

.mobile-calc-input:focus {
    outline: none;
    border-color: #6366f1;
}

/* Mobile optimizations */
@media (max-width: 640px) {
    /* Prevent any horizontal scroll */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
    }
    
    /* Main container fixes */
    #home-page {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .max-w-7xl {
        max-width: 100% !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Calculator sections */
    .bg-gradient-to-br {
        padding: 0.75rem !important;
        margin: 0 !important;
    }
    
    /* Tables */
    table {
        width: 100% !important;
        table-layout: fixed !important;
    }
    
    thead th {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.75rem !important;
    }
    
    tbody td {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Column widths - simple and clean */
    table tr td:first-child,
    table tr th:first-child {
        width: 35% !important;
    }
    
    table tr td:nth-child(2),
    table tr th:nth-child(2) {
        width: 40% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    table tr td:nth-child(3),
    table tr th:nth-child(3) {
        width: 25% !important;
    }
    
    /* Mobile button adjustments */
    .mobile-calc-btn {
        width: 1.5rem !important;
        height: 1.5rem !important;
        min-width: 1.5rem !important;
    }
    
    .mobile-calc-btn .btn-icon {
        width: 0.65rem !important;
        height: 0.65rem !important;
    }
    
    .mobile-calc-input {
        width: 2rem !important;
        font-size: 0.7rem !important;
    }
}
    /* Fix for saved projects on mobile */
    #saved-projects-list {
        max-height: 200px;
    }
    
    /* COUNTRY SEARCH MOBILE FIXES */
    #country-search {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 12px 40px 12px 12px !important;
        height: 48px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    #country-search-results {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1000;
        max-height: 50vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border: 2px solid #4f46e5;
        border-top: none;
        border-radius: 0 0 8px 8px;
        background: white;
    }
    
    .search-result-item {
        padding: 14px 16px !important;
        font-size: 16px !important;
        min-height: 44px; /* Minimum touch target size for mobile */
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    .search-result-item:active {
        background-color: #f3f4f6 !important;
    }
    
    /* Prevent body scroll when search results are open */
    body.search-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Flag image styling */
.flag-shadow {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Button hover effects */
.btn-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Focus styles for accessibility */
:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* High contrast for better readability */
.high-contrast {
    color: #1f2937;
    background-color: #ffffff;
}

/* Print optimization */
@media print {
    .break-inside-avoid {
        break-inside: avoid;
    }
    
    .print-text-black {
        color: black !important;
    }
}

/* Country search results styling */
#country-search-results {
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #4f46e5;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#country-search-results div {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#country-search-results div:hover {
    background-color: #f3f4f6;
}

#country-search-results div:last-child {
    border-bottom: none;
}

/* FAQ animations */
.faq-answer {
    transition: all 0.3s ease;
}

.faq-question i {
    transition: transform 0.3s ease;
}



/* Fix for the action buttons grid on very small screens */
@media (max-width: 480px) {
    .grid-cols-1 {
        grid-template-columns: 1fr;
    }
    
    .sm\:grid-cols-2 {
        grid-template-columns: 1fr;
    }
    
    /* Make buttons full width on very small screens */
    #save-project-btn,
    #save-as-new-btn,
    #export-csv-btn,
    #print-btn,
    #clear-all-btn {
        width: 100%;
    }
}

/* Ensure input fields are visible on mobile */
input, select, textarea {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Improve touch targets on iOS */
    button, a, .search-result-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Improve touch feedback */
    button:active, .btn-hover:active, .search-result-item:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    /* Larger hit targets for touch devices but limited for very small screens */
    .increase-btn, .decrease-btn {
        min-width: 32px;
        min-height: 32px;
    }
    
    @media (min-width: 400px) {
        .increase-btn, .decrease-btn {
            min-width: 44px;
            min-height: 44px;
        }
    }
    
    .note-input, .coin-input {
        min-height: 32px;
    }
}

/* Prevent pull-to-refresh on mobile when interacting with search */
body.no-pull-to-refresh {
    overscroll-behavior-y: contain;
}
/* Country Dropdown Styles */
#country-dropdown {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

#country-list {
    scrollbar-width: thin;
    scrollbar-color: #c7d2fe #f1f5f9;
}

#country-list::-webkit-scrollbar {
    width: 6px;
}

#country-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#country-list::-webkit-scrollbar-thumb {
    background: #c7d2fe;
    border-radius: 3px;
}

.country-item {
    transition: all 0.2s ease;
}

.country-item:hover {
    background-color: #eef2ff;
    transform: translateX(2px);
}

/* Mobile-specific dropdown fixes */
@media (max-width: 640px) {
    #country-dropdown {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90vw !important;
        max-height: 70vh !important;
        z-index: 9999 !important;
    }
    
    #country-list {
        max-height: 50vh !important;
    }
    
    #country-search {
        font-size: 16px !important; /* Prevents iOS zoom */
    }
}

/* Mobile menu fixes */
#mobile-menu {
    z-index: 100;
}

#mobile-menu-button {
    z-index: 101;
    position: relative;
}

/* Prevent body scroll when dropdown is open */
body.dropdown-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Better touch targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .country-item {
        min-height: 48px;
        padding: 14px 16px !important;
    }
    
    #mobile-menu-button {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
/* FIXED DROPDOWN FOR MOBILE */
#country-dropdown {
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

#country-list {
    scrollbar-width: thin;
    scrollbar-color: #c7d2fe #f1f5f9;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

#country-list::-webkit-scrollbar {
    width: 6px;
}

#country-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#country-list::-webkit-scrollbar-thumb {
    background: #c7d2fe;
    border-radius: 3px;
}

.country-item {
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent; /* Remove blue highlight on tap */
}

.country-item:hover, .country-item:active {
    background-color: #eef2ff;
}

/* MOBILE-SPECIFIC FIXES */
@media (max-width: 640px) {
    /* Fix dropdown positioning for mobile */
    #country-dropdown {
        position: fixed !important;
        left: 5% !important;
        width: 90% !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        max-height: 70vh !important;
        margin-top: 0 !important;
    }
    
    #country-list {
        max-height: 50vh !important;
    }
    
    /* Fix for search input on mobile */
    #country-search {
        font-size: 16px !important; /* Prevents iOS zoom */
        cursor: pointer;
    }
    
    /* Mobile menu fixes */
    #mobile-menu {
        position: fixed !important;
        top: 4rem !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9999 !important;
        max-height: calc(100vh - 4rem);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix menu button for mobile */
    #mobile-menu-button {
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    #mobile-menu-button:active {
        background-color: #f3f4f6;
        border-radius: 0.375rem;
    }
    
    /* Prevent body scroll when dropdown or menu is open */
    body.no-scroll {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* Better touch targets for mobile */
@media (hover: none) and (pointer: coarse) {
    .country-item, 
    #mobile-menu a {
        min-height: 48px;
        padding: 14px 16px !important;
        display: flex;
        align-items: center;
    }
    
    /* Improve button touch targets */
    .increase-btn, .decrease-btn,
    #save-project-btn, #save-as-new-btn,
    #export-csv-btn, #print-btn, #clear-all-btn {
        min-height: 44px;
    }
    
    /* Fix for input fields on mobile */
    .note-input, .coin-input {
        min-height: 44px;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    #country-list {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent text size adjustment */
    html {
        -webkit-text-size-adjust: 100%;
    }
    
    /* Fix for dropdown search on iOS */
    #country-dropdown-search {
        font-size: 16px !important;
    }
}

/* Prevent body scrolling when dropdown is open */
body.dropdown-open {
    overflow: hidden;
}

/* Fix for country dropdown search on mobile */
@media (max-width: 640px) {
    #country-dropdown-search {
        font-size: 16px !important; /* Prevents iOS zoom */
        -webkit-user-select: none;
        user-select: none;
    }
    
    #country-dropdown-search[readonly] {
        cursor: pointer;
        background-color: #f9fafb;
    }
    
    /* Improved dropdown positioning */
    #country-dropdown {
        position: fixed !important;
        left: 5% !important;
        width: 90% !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        max-height: 70vh !important;
        margin-top: 0 !important;
        z-index: 9999 !important;
    }
    
    #country-list {
        max-height: 50vh !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Prevent body scroll when dropdown is open */
    body.dropdown-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* Fix for touch targets on mobile */
@media (hover: none) and (pointer: coarse) {
    .increase-btn, .decrease-btn {
        min-width: 44px !important;
        min-height: 44px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Prevent double-tap zoom on buttons */
    .increase-btn, .decrease-btn, 
    #mobile-menu-button,
    .country-item {
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
    }
}