/* 
 * Reusable Design System - Main Styles
 * Mobile-first responsive vanilla CSS
 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-main: #111827;
    --text-muted: #4b5563;
    --bg-main: #ffffff;
    --bg-alt: #f9fafb;
    --border-color: #e5e7eb;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --container-max-width: 1200px;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 4rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Reset and Base Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; transition: color 0.2s ease; }
ul { list-style: none; }

/* Layout Utilities */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Header & Navigation */
.header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 0;
    background-color: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-container { display: flex; justify-content: space-between; align-items: center; }
.logo a { font-size: 1.5rem; font-weight: 800; color: var(--text-main); letter-spacing: -0.025em; }
.main-nav ul { display: flex; gap: 1.5rem; align-items: center; }
.main-nav a { font-weight: 500; color: var(--text-muted); font-size: 0.95rem; }
.main-nav a:hover { color: var(--primary-color); }

/* Language Selector Styles */
.lang-selector-li {
    display: flex;
    align-items: center;
}

.lang-selector-container {
    position: relative;
    display: inline-block;
}

.lang-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: none;
    padding: 0.375rem 0.625rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.lang-selector-btn:hover {
    color: var(--primary-color);
    background-color: var(--bg-alt);
}

.lang-selector-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.lang-current-flag {
    font-size: 1rem;
    line-height: 1;
}

.lang-current-code {
    text-transform: uppercase;
}

.lang-arrow {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.7;
}

.lang-selector-container.active .lang-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.lang-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    min-width: 170px;
    max-height: 280px; /* Limit height to trigger scrollbar */
    overflow-y: auto;  /* Enable vertical scrolling */
    padding: 0.375rem;
    z-index: 100;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Lightweight modern scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Custom Scrollbar Styles for Webkit Browsers */
.lang-dropdown::-webkit-scrollbar {
    width: 6px;
}

.lang-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.lang-dropdown::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
    border: 1px solid transparent;
}

.lang-dropdown::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

.lang-selector-container.active .lang-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    text-align: left;
}

.lang-option:hover {
    color: var(--primary-color);
    background-color: var(--bg-alt);
}

.lang-option.active {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.08);
}

.lang-flag {
    font-size: 1rem;
    line-height: 1;
}

/* Mobile Optimization for Multilingual Dropdown */
@media (max-width: 768px) {
    .lang-dropdown {
        right: 0;
        min-width: 180px;
        max-width: calc(100vw - 32px); /* Prevent screen overflow on very narrow devices */
        max-height: 220px; /* Highly compact height for small mobile screens */
        -webkit-overflow-scrolling: touch; /* Smooth inertial scrolling on iOS */
        scroll-behavior: smooth;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05); /* Enhanced depth separation */
    }

    .lang-option {
        padding: 0.625rem 0.875rem; /* Large touch-friendly target size for mobile fingers */
        font-size: 0.95rem; /* Enhanced readability for smaller screens */
    }
    
    .lang-dropdown::-webkit-scrollbar {
        width: 5px; /* Extremely thin sleek scrollbar on mobile */
    }
}

/* RTL (Arabic) Layout Support */
html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] body {
    text-align: right;
}

/* Dynamic dropdown positioning in RTL */
html[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

/* Flip chevron arrow alignment in RTL */
html[dir="rtl"] .lang-selector-btn svg {
    margin-left: 0;
    margin-right: 0.375rem;
}

/* Flip text alignment inside dropdown list options */
html[dir="rtl"] .lang-option {
    text-align: right;
}

/* Main Content */
.main-content { flex: 1; }

/* Sections */
.hero { padding: var(--spacing-lg) 0; text-align: center; }
.hero h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.15; margin-bottom: 1.25rem; letter-spacing: -0.025em; }
.hero .subtitle { font-size: 1.125rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 2.5rem auto; }

/* Cards & Grid */
.features-section { padding: 3rem 0 5rem 0; background-color: var(--bg-main); }
.features-section-alt { background-color: var(--bg-alt); }
.section-header { text-align: center; margin-bottom: 3rem; max-width: 700px; margin: 0 auto; }
.section-header h2 { font-size: 2rem; font-weight: 700; margin-bottom: 1rem; letter-spacing: -0.025em; }
.section-header p { color: var(--text-muted); font-size: 1.125rem; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-icon {
    width: 48px; height: 48px; background-color: var(--bg-alt); border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; margin-bottom: 1.25rem; color: var(--primary-color);
}
.card h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.card-desc { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.25rem; flex: 1; }
.card-use {
    font-size: 0.875rem; background-color: var(--bg-alt); padding: 0.75rem;
    border-radius: var(--radius-md); border-left: 3px solid var(--primary-color);
}
.card-link { font-size: 0.875rem; font-weight: 600; color: var(--primary-color); margin-top: auto; display: inline-flex; align-items: center; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 0.875rem 1.75rem;
    font-size: 1rem; font-weight: 600; border-radius: var(--radius-md); cursor: pointer;
    transition: all 0.2s ease; border: none; box-shadow: var(--shadow-sm);
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-secondary { background-color: var(--text-main); color: white; }
.btn-outline { background-color: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn:active { transform: translateY(1px); }

/* Tool Interface */
.tool-wrapper { padding: 2rem 0 4rem 0; }
.tool-container {
    background-color: var(--bg-main); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    display: grid; grid-template-columns: 1fr 1fr; overflow: hidden;
}
.tool-controls { padding: 2rem; border-right: 1px solid var(--border-color); }
.tool-preview { padding: 2rem; background-color: var(--bg-alt); display: flex; flex-direction: column; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; }
.form-control {
    width: 100%; padding: 0.625rem 0.75rem; font-size: 0.95rem; font-family: var(--font-family);
    border: 1px solid var(--border-color); border-radius: var(--radius-md); transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.form-control-range { width: 100%; cursor: pointer; }
.form-control-color { width: 100%; height: 42px; padding: 0.25rem; cursor: pointer; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.checkbox-group { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; }

/* Preview */
.preview-area {
    flex: 1; display: flex; align-items: center; justify-content: center;
    background-color: var(--bg-main); border: 1px dashed #cbd5e1; border-radius: var(--radius-lg);
    padding: 2rem; min-height: 250px; margin-bottom: 1.5rem; overflow: hidden;
}
.barcode-svg-container { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; }
.barcode-svg-container svg { max-width: 100%; height: auto; }

/* FAQ Accordion */
.faq-section { padding: 4rem 0 6rem 0; background-color: var(--bg-alt); border-top: 1px solid var(--border-color); }
.accordion { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.accordion-item { background-color: var(--bg-main); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
.accordion-button {
    width: 100%; display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.5rem; background: none; border: none; cursor: pointer;
    font-family: var(--font-family); font-size: 1.05rem; font-weight: 600; text-align: left;
}
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.accordion-content p { padding: 1.25rem 1.5rem; color: var(--text-muted); margin: 0; }

/* SEO Content */
.seo-content-section { padding: 4rem 0; background-color: var(--bg-main); border-top: 1px solid var(--border-color); }
.article-container { max-width: 800px; margin: 0 auto; }
.article-content { font-size: 1.05rem; line-height: 1.7; }
.article-content h3 { font-size: 1.5rem; font-weight: 700; margin: 2rem 0 1rem 0; }
.article-content p { margin-bottom: 1.5rem; color: var(--text-muted); }

/* Footer */
.footer { border-top: 1px solid var(--border-color); padding: 2.5rem 0; background-color: var(--bg-alt); margin-top: auto; }
.footer-container { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.footer-links { display: flex; gap: 2rem; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }
.copyright { color: #9ca3af; font-size: 0.875rem; }

/* How It Works Section */
.how-it-works-section {
    padding: 4rem 0 5rem 0;
    background-color: var(--bg-alt);
    border-top: 1px solid var(--border-color);
}
.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 2.5rem;
}
.step-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.step-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.step-number {
    width: 42px;
    height: 42px;
    background-color: var(--primary-color);
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.25);
}
.step-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}
.step-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
    .header-container { flex-direction: column; gap: 1rem; }
    .hero h1 { font-size: 2rem; }
    .tool-container { grid-template-columns: 1fr; }
    .tool-controls { border-right: none; border-bottom: 1px solid var(--border-color); }
    .form-row { grid-template-columns: 1fr; gap: 0; }
}
