/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+Javanese:wght@400;500;700&display=swap');

/* Tailwind Custom Config Setup */
:root {
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --bg-primary: #f9fafb;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
}

/* Dark Mode Variables */
.dark {
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --bg-primary: #111827;
    --bg-card: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --border-color: #374151;
}

body {
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Overrides */
.dark body,
body.dark {
    background-color: #111827;
}

.dark .bg-white,
.dark .bg-gray-50 {
    background-color: var(--bg-card) !important;
}

.dark .bg-gray-100 {
    background-color: #374151 !important;
}

.dark .text-gray-800,
.dark .text-gray-700 {
    color: #f9fafb !important;
}

.dark .text-gray-600,
.dark .text-gray-500 {
    color: #9ca3af !important;
}

.dark .text-gray-400 {
    color: #6b7280 !important;
}

.dark .border-gray-200,
.dark .border-gray-100 {
    border-color: #374151 !important;
}

.dark .shadow-lg,
.dark .shadow-sm {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}

.dark textarea,
.dark #aksara-output {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
}

.dark .mode-btn {
    background-color: #374151;
    color: #9ca3af;
}

.dark .mode-btn.active {
    background-color: var(--primary);
    color: white;
}

.dark .vkey {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #f9fafb !important;
}

.dark .vkey:hover {
    background-color: #4b5563 !important;
}

.dark .bg-blue-50,
.dark .bg-green-50,
.dark .bg-yellow-50,
.dark .bg-purple-50,
.dark .bg-orange-50,
.dark .bg-red-50 {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

.dark .border-t,
.dark .border-b {
    border-color: #374151 !important;
}

.dark details {
    border-color: #374151 !important;
}

.dark details summary {
    background-color: #1f2937 !important;
}

.dark details summary:hover {
    background-color: #374151 !important;
}

.dark table {
    color: #f9fafb;
}

.dark table tr {
    border-color: #374151 !important;
}

.dark .prose {
    color: #d1d5db !important;
}

.javanese-text {
    font-family: 'Noto Sans Javanese', serif;
}

/* Translator Output Font Size */
@media(max-width:640px) {
    .aksara-output {
        font-size: 1.5rem;
    }
}

/* Fade In Animation */
.fade-in {
    animation: fadeIn .3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* FAQ Accordion */
details summary::-webkit-details-marker {
    display: none;
}

details[open] summary .chevron {
    transform: rotate(180deg);
}

.chevron {
    transition: transform .2s ease;
}

/* Mode Toggle Buttons */
.mode-btn {
    background: #f3f4f6;
    color: #6b7280;
    border: 2px solid transparent;
}

.mode-btn:hover {
    background: #e5e7eb;
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Virtual Keyboard */
.vkey {
    min-width: 40px;
    font-family: 'Noto Sans Javanese', serif;
}

.vkey:hover span.text-gray-500 {
    color: white !important;
}

/* Murda Toggle Checkbox */
#murda-toggle:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* =========================================
   MOBILE RESPONSIVE FIXES (NUCLEAR OPTION)
   ========================================= */

@media (max-width: 768px) {

    /* 1. Global Constraints - CRITICAL */
    html,
    body {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 2. Reset all containers */
    *,
    *::before,
    *::after {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 3. Main Container Fixes */
    main {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* 4. Section containers */
    section {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* 5. Card Container Fixes */
    .bg-white,
    .bg-white.rounded-2xl,
    section.bg-white {
        padding: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 0.75rem !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* 6. Grid Reset - Force single column */
    .grid,
    .grid.md\:grid-cols-2,
    div[class*="grid"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    /* 7. Translator Boxes - CRITICAL FIX */
    textarea,
    #latin-input,
    #aksara-output,
    .aksara-output {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        padding: 0.75rem !important;
        margin: 0 !important;
        border-radius: 0.75rem !important;
        overflow-x: hidden !important;
        word-wrap: break-word !important;
        white-space: pre-wrap !important;
    }

    /* 8. Space-y fixes for vertical spacing */
    .space-y-3>*+*,
    .space-y-4>*+*,
    .space-y-6>*+* {
        margin-top: 0.75rem !important;
    }

    /* 9. Button Container Fixes */
    .action-buttons,
    .flex.items-center.justify-end.gap-3,
    div.flex.items-center.justify-end,
    .flex.flex-wrap.gap-2 {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 10. Buttons Full Width */
    button,
    .action-buttons button,
    .flex.items-center.justify-end button {
        width: 100% !important;
        justify-content: center !important;
        margin: 0 !important;
        padding: 0.75rem 1rem !important;
        box-sizing: border-box !important;
    }

    /* 11. Example buttons wrapper */
    .flex.flex-wrap.gap-2 {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .example-btn {
        width: auto !important;
        flex: 0 0 auto !important;
    }

    /* 12. Character count and clear button container */
    .flex.items-center.justify-between {
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* 13. Table Horizontal Scroll Fix */
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    /* 14. Typography fixes */
    h1 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        word-wrap: break-word !important;
    }

    h2 {
        font-size: 1.25rem !important;
        word-wrap: break-word !important;
    }

    /* 15. Prose content */
    .prose,
    .prose.max-w-none {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* 16. Lists fix */
    ul,
    ol {
        padding-left: 1.25rem !important;
        width: 100% !important;
    }

    /* 17. Padding utilities override */
    .px-4,
    .px-6,
    .px-8,
    .px-10 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* 18. Remove negative margins */
    * {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 19. Footer fix */
    footer {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    footer .grid {
        grid-template-columns: 1fr !important;
    }

    /* 20. Header/Navigation fix */
    header {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* 21. Max width utilities override */
    .max-w-4xl,
    .max-w-5xl,
    .max-w-lg {
        max-width: 100% !important;
    }

    /* 22. Flex containers that might cause overflow */
    .flex {
        flex-wrap: wrap !important;
    }

    /* 23. Toast notification */
    #toast {
        max-width: calc(100vw - 2rem) !important;
        left: 1rem !important;
        transform: none !important;
    }

    /* 24. Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* 25. Hidden overflow on all containers */
    section>* {
        overflow-x: hidden !important;
    }
}

/* Extra small devices (portrait phones, less than 375px) */
@media (max-width: 374px) {
    body {
        font-size: 14px !important;
    }

    .bg-white {
        padding: 0.5rem !important;
    }

    textarea,
    #aksara-output {
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }

    button {
        padding: 0.625rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
}


/* Virtual Keyboard Grid - Explicit fix for mobile */
.virtual-keyboard-grid {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .virtual-keyboard-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr)) !important;
    }
}