/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

:root {
    --primary-color: #2c5530;
    --secondary-color: #ffd700;
    --accent-color: #d4af37;
    --text-dark: #1a1a1a;
    --text-light: #666;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Prevent translation popups from affecting layout */
body, * {
    translate: no;
}

/* COMPREHENSIVE TRANSLATION PREVENTION */
.notranslate,
.font-preview,
.preview-text,
.text-input,
.logo,
[translate="no"] {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-font-feature-settings: "kern" 1;
    font-feature-settings: "kern" 1;
}

/* Prevent Google Translate from interfering */
.goog-te-banner-frame,
.goog-te-menu-frame,
.goog-te-balloon-frame,
.goog-te-ftab,
.goog-te-menu2,
.goog-te-menu-value,
.goog-te-gadget,
.goog-te-combo,
#google_translate_element,
#goog-gt-tt,
.goog-tooltip,
.goog-text-highlight {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    z-index: -1 !important;
}

/* Hide Microsoft Translator */
#MicrosoftTranslatorWidget,
.microsoft-translator-widget,
.bing-translator {
    display: none !important;
    visibility: hidden !important;
}

/* Hide any other translation widgets */
[class*="translate"],
[id*="translate"],
[class*="translator"],
[id*="translator"] {
    display: none !important;
}

/* Exception for our own elements */
.text-input,
.preview-text,
.font-preview,
.notranslate {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    z-index: auto !important;
}

body.goog-te-banner-frame {
    top: 0 !important;
}

/* Protect Amharic text specifically */
[lang="am"],
.amharic-text,
.font-preview,
.preview-text {
    unicode-bidi: embed;
    direction: ltr;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Ad Container Styles */
.ad-container {
    margin: 1.5rem 0;
    text-align: center;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 0.75rem;
    position: relative;
}

.ad-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.ad-banner-top {
    margin-bottom: 2rem;
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
    padding: 0.5rem;
    max-height: 100px; /* Limit height */
}

.ad-banner-bottom {
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    max-width: 728px;
    margin-left: auto;
    margin-right: auto;
    padding: 0.5rem;
}

.ad-sidebar {
    display: none; /* Hidden by default, shown on desktop */
    max-width: 300px;
    margin: 0;
    position: sticky;
    top: 2rem;
    height: fit-content;
    padding: 0.75rem;
}

.ad-mobile-inline {
    display: block;
    margin: 1.5rem 0;
    padding: 0.5rem;
    max-height: 80px; /* Smaller for mobile */
}

.ad-in-feed {
    margin: 2rem 0;
    max-width: 100%;
    padding: 0.75rem;
}

/* AdSense responsive styles */
.adsbygoogle {
    display: block;
    min-height: 50px;
    max-height: 90px; /* Limit ad height */
    background: #fafafa;
    border-radius: 4px;
    overflow: hidden;
}

/* Content Section for AdSense Approval */
.content-section {
    margin: 4rem 0;
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.content-article h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.content-article h3 {
    color: var(--text-dark);
    font-size: 1.4rem;
    margin: 2rem 0 1rem 0;
}

.content-article p {
    line-height: 1.7;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    font-size: 1.1rem;
}

.content-article ul,
.content-article ol {
    margin: 1rem 0 1.5rem 2rem;
    line-height: 1.6;
}

.content-article li {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.content-article strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Contact info styling */
.contact-info {
    background: #f0f8f0;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
}

.contact-info p {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.contact-info p:last-child {
    margin-bottom: 0;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Focus indicators */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.font-card:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    transform: translateY(-1px);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #1e3a21);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main content */
.main {
    flex: 1;
    padding: 3rem 0;
}

.input-output-container {
    display: grid;
    grid-template-columns: 1fr 300px 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
    align-items: start;
}

.input-section,
.output-section {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.input-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
}

.text-input {
    width: 100%;
    padding: 1.2rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1.2rem;
    font-family: inherit;
    resize: vertical;
    min-height: 200px;
    transition: var(--transition);
    background: var(--bg-white);
    line-height: 1.6;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
}

.text-input::placeholder {
    color: var(--text-light);
    font-style: italic;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
}

.text-input::placeholder {
    color: var(--text-light);
    font-style: italic;
}

/* Output section */
.output-section {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.output-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
}

.copy-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.7rem 1.4rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-btn:hover:not(:disabled) {
    background: #1e3a21;
    transform: translateY(-1px);
}

.copy-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.copy-icon {
    font-size: 1.1rem;
}

.output-preview {
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.2rem;
    min-height: 200px;
    position: relative;
    overflow-y: auto;
}

/* Custom scrollbar for preview */
.output-preview::-webkit-scrollbar {
    width: 6px;
}

.output-preview::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.output-preview::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.output-preview::-webkit-scrollbar-thumb:hover {
    background: #1e3a21;
}

.preview-text {
    font-size: 1.5rem;
    line-height: 1.6;
    color: var(--text-dark);
    word-wrap: break-word;
    white-space: pre-wrap;
    margin: 0;
}

.preview-text.empty {
    color: var(--text-light);
    font-style: italic;
    font-size: 1.1rem;
}

/* Fonts section */
.fonts-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    text-align: center;
}

.font-grid-container {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.font-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), #1e3a21);
    color: white;
    font-size: 0.9rem;
}

.font-count {
    font-weight: 600;
}

.scroll-hint {
    font-size: 0.8rem;
    opacity: 0.8;
}

.font-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 0;
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-white);
}

/* Custom scrollbar for font grid */
.font-grid::-webkit-scrollbar {
    width: 8px;
}

.font-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.font-grid::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.font-grid::-webkit-scrollbar-thumb:hover {
    background: #1e3a21;
}

.font-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.font-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(44, 85, 48, 0.15);
    transform: translateY(-1px);
}

.font-card.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #f0f8f0, var(--bg-white));
    box-shadow: 0 2px 12px rgba(44, 85, 48, 0.2);
}

.font-card.active::before {
    content: '✓';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--primary-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.font-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-preview {
    font-size: 1rem;
    line-height: 1.3;
    color: var(--text-dark);
    word-wrap: break-word;
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 40px;
    overflow: hidden;
}

/* Output section */
.output-section {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.output-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-dark);
}

.copy-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-btn:hover:not(:disabled) {
    background: #1e3a21;
    transform: translateY(-1px);
}

.copy-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
}

.copy-icon {
    font-size: 1.1rem;
}

.output-preview {
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    min-height: 150px;
    position: relative;
}

.preview-text {
    font-size: 1.6rem;
    line-height: 1.5;
    color: var(--text-dark);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.preview-text.empty {
    color: var(--text-light);
    font-style: italic;
    font-size: 1.2rem;
}

/* Footer */
.footer {
    background: var(--text-dark);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    transform: translateX(100%);
    opacity: 0;
    transition: var(--transition);
    z-index: 1000;
    font-weight: 600;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .logo {
        font-size: 2rem;
    }
    
    .tagline {
        font-size: 1rem;
    }
    
    .main {
        padding: 2rem 0;
    }
    
    .input-output-container {
        grid-template-columns: 1fr;
        gap: 2rem;
        margin-bottom: 2rem;
    }
    
    .input-section,
    .output-section {
        padding: 1.5rem;
    }
    
    .text-input {
        min-height: 150px;
        font-size: 1.1rem;
        padding: 1rem;
    }
    
    .output-preview {
        min-height: 150px;
        padding: 1rem;
    }
    
    .preview-text {
        font-size: 1.3rem;
    }
    
    .output-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .copy-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Ad responsive styles */
    .ad-sidebar {
        display: none !important;
    }
    
    .ad-mobile-inline {
        display: block;
        margin: 1rem 0;
        padding: 0.5rem;
        max-height: 60px;
    }
    
    .ad-banner-top,
    .ad-banner-bottom {
        margin: 1rem 0;
        padding: 0.5rem;
        max-height: 70px;
    }
    
    .ad-container {
        margin: 1rem 0;
        padding: 0.5rem;
    }
    
    .ad-label {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
    }
    
    .adsbygoogle {
        max-height: 60px;
        min-height: 40px;
    }
    
    .content-section {
        margin: 2rem 0;
        padding: 1.5rem;
    }
    
    .content-article h2 {
        font-size: 1.5rem;
    }
    
    .content-article h3 {
        font-size: 1.2rem;
    }
    
    .content-article p {
        font-size: 1rem;
    }
    
    .font-grid-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .scroll-hint {
        display: none;
    }
    
    .font-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        max-height: 50vh;
        padding: 0.75rem;
    }
    
    .font-card {
        padding: 0.5rem;
        min-height: 70px;
    }
    
    .font-name {
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    .font-preview {
        font-size: 0.9rem;
        min-height: 35px;
    }
    
    .preview-text {
        font-size: 1.2rem;
    }
    
    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.8rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .input-output-container {
        gap: 1.5rem;
    }
    
    .input-section,
    .output-section {
        padding: 1rem;
    }
    
    .text-input {
        min-height: 120px;
        font-size: 1rem;
        padding: 0.8rem;
    }
    
    .output-preview {
        min-height: 120px;
        padding: 0.8rem;
    }
    
    .preview-text {
        font-size: 1.2rem;
    }
    
    .font-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        max-height: 45vh;
        padding: 0.5rem;
    }
    
    .font-card {
        padding: 0.5rem;
        min-height: 60px;
    }
    
    .font-name {
        font-size: 0.7rem;
    }
    
    .font-preview {
        font-size: 0.85rem;
        min-height: 30px;
    }
}

/* Large screens - 4 columns */
@media (min-width: 1200px) {
    .font-grid {
        grid-template-columns: repeat(4, 1fr);
        max-height: 65vh;
    }
    
    .ad-sidebar {
        display: block;
    }
    
    .ad-mobile-inline {
        display: none;
    }
}

/* Desktop specific ad styles */
@media (min-width: 769px) {
    .ad-sidebar {
        display: block;
    }
    
    .ad-mobile-inline {
        display: none;
    }
}

/* Font loading optimization */
@font-display: swap;

/* Ethiopic/Amharic specific font rendering */
.font-preview,
.preview-text {
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Loading state for fonts */
.font-card.loading .font-preview {
    opacity: 0.6;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Better font fallbacks for Ethiopic script */
.font-preview,
.preview-text {
    font-family: inherit;
    /* Ensure Ethiopic characters are properly displayed */
    unicode-bidi: embed;
    direction: ltr;
}

/* Prevent text selection on UI elements */
.font-card, .copy-btn, .header {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Allow text selection on content areas */
.text-input, .preview-text {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}