/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

:root {
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --background: #ffffff;
    --surface: #f8f9fa;
    --surface-hover: #f1f3f4;
    --text: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --border: #dadce0;
    --border-light: #e8eaed;
    --success: #1e8e3e;
    --shadow-sm: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    --shadow-md: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
}

body {
    font-family: 'Google Sans', Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    overflow-x: hidden;
}

main,
.converter-card,
.converter-content,
.popular-section,
.seo-content,
.ad-space,
.input-group,
.input-box,
.select-wrapper,
.result-display {
    max-width: 100%;
}

/* Header */
header {
    text-align: center;
    padding: 48px 20px 32px;
    position: relative;
}

.back-home {
    position: absolute;
    left: 20px;
    top: 48px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-home:hover {
    color: var(--primary-hover);
}

header h1 {
    font-size: 32px;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.emoji {
    display: none;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Ad Spaces */
.ad-space {
    margin: 16px 0;
}

.ad-placeholder {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    max-width: 100%;
    overflow: hidden;
}

.ad-placeholder ins {
    max-width: 100% !important;
    width: 100% !important;
}

.ad-top {
    margin-bottom: 24px;
}

.ad-vertical {
    min-height: 600px;
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 1fr 4fr 1fr;
    gap: 20px;
    margin: 32px 0;
    width: 100%;
    overflow-x: hidden;
}

/* Converter Card */
.converter-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    width: 100%;
    overflow: hidden;
}

/* Category Selector */
.category-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%;
}

.category-selector::-webkit-scrollbar {
    display: none;
}

.category-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-btn .icon {
    display: none;
}

.category-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.category-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Input Group */
.input-group {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
    width: 100%;
}

.input-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.input-box label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-box input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    font-size: 20px;
    font-weight: 400;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    transition: border-color 0.2s ease;
}

.input-box input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

.select-search {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: var(--text);
    transition: border-color 0.2s ease;
}

.select-search:focus {
    outline: none;
    border-color: var(--primary);
}

.unit-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 4px 4px;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s ease;
    max-height: 200px;
}

.unit-select:focus {
    outline: none;
    border-color: var(--primary);
}

.unit-select option {
    background: #ffffff;
    color: var(--text);
    padding: 8px;
}

/* Swap Button */
.swap-btn {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.swap-btn:hover {
    background: var(--surface);
    border-color: var(--text-secondary);
}

.swap-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

/* Result Display */
.result-display {
    background: var(--surface);
    padding: 20px;
    border-radius: 4px;
    text-align: center;
    margin-top: 16px;
    border: 1px solid var(--border-light);
}

.result-text {
    font-size: 16px;
    font-weight: 400;
    color: var(--text);
}

/* Currency Chart */
.currency-chart {
    margin-top: 24px;
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.currency-chart h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 16px;
}

.chart-container {
    position: relative;
    height: 200px;
    margin-bottom: 12px;
}

.chart-note {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
}

/* Popular Section */
.popular-section {
    margin: 48px 0;
}

.popular-section h2 {
    font-size: 20px;
    font-weight: 400;
    margin-bottom: 20px;
    color: var(--text);
}

.popular-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.popular-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.popular-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}

.popular-icon {
    display: none;
}

.popular-card h3 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.popular-card p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* SEO Content */
.seo-content {
    background: #ffffff;
    border-radius: 4px;
    padding: 32px;
    margin: 48px 0;
    border: 1px solid var(--border);
}

.seo-content h2 {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 16px;
    color: var(--text);
}

.seo-content h3 {
    font-size: 18px;
    font-weight: 500;
    margin: 24px 0 12px;
    color: var(--text);
}

.seo-content p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    font-size: 14px;
}

.seo-content ul {
    list-style: none;
    padding-left: 0;
}

.seo-content li {
    padding: 8px 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 14px;
}

.seo-content strong {
    color: var(--text);
    font-weight: 500;
}

/* Footer */
footer {
    text-align: center;
    padding: 32px 20px;
    border-top: 1px solid var(--border-light);
    margin-top: 48px;
    color: var(--text-muted);
    font-size: 13px;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary);
}

/* Responsive Design */
@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .ad-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .category-selector {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .category-selector::-webkit-scrollbar {
        display: none;
    }
    
    .input-group {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .swap-btn {
        transform: rotate(90deg);
        margin: 8px auto;
        order: 2;
    }
    
    .input-box:first-child {
        order: 1;
    }
    
    .input-box:last-child {
        order: 3;
    }
    
    .popular-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .converter-card {
        padding: 16px;
        border-radius: 8px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .input-box input[type="number"] {
        font-size: 18px;
        padding: 10px 12px;
    }
    
    .seo-content {
        padding: 20px;
    }
    
    .chart-container {
        height: 180px;
    }
}

@media (max-width: 640px) {
    .category-selector {
        flex-wrap: wrap;
        justify-content: flex-start;
        overflow-x: visible;
    }

    .category-btn {
        flex: 1 1 calc(50% - 8px);
        text-align: center;
        border-bottom-width: 0;
        border-radius: 6px;
        background: var(--surface);
    }

    .category-btn.active {
        background: var(--primary);
        color: #ffffff;
    }

    .input-group {
        width: 100%;
    }
}

@media (max-width: 480px) {
    * {
        box-sizing: border-box;
    }
    
    html {
        overflow-x: hidden;
        width: 100%;
    }
    
    body {
        padding: 0;
        margin: 0;
        width: 100%;
        overflow-x: hidden;
        position: relative;
    }
    
    header {
        padding: 16px;
        width: 100%;
        box-sizing: border-box;
    }
    
    header h1 {
        font-size: 20px;
        word-wrap: break-word;
    }
    
    .subtitle {
        font-size: 13px;
    }
    
    .back-home {
        font-size: 12px;
        left: 16px;
        top: 16px;
    }
    
    .container {
        padding: 0;
        max-width: 100%;
        width: 100%;
        overflow-x: hidden;
    }
    
    main {
        padding: 0;
        width: 100%;
    }
    
    .converter-card {
        padding: 0;
        margin: 0;
        width: 100%;
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--border-light);
        box-shadow: none;
    }
    
    .category-selector {
        margin: 0;
        padding: 12px 16px;
        gap: 8px;
        border-bottom: 1px solid var(--border-light);
        background: white;
        position: sticky;
        top: 0;
        z-index: 10;
        flex-wrap: wrap;
        overflow-x: visible;
    }
    
    .category-btn {
        padding: 8px 12px;
        font-size: 11px;
        white-space: normal;
        flex: 1 1 calc(50% - 8px);
        border-radius: 6px;
        text-align: center;
    }
    
    .category-btn.active {
        background: var(--primary);
        color: #fff;
        border-bottom: none;
    }
    
    .converter-content {
        padding: 16px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .input-group {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }
    
    .input-box {
        padding: 0;
        width: 100%;
    }
    
    .input-box label {
        font-size: 12px;
        margin-bottom: 6px;
        display: block;
        font-weight: 500;
    }
    
    .input-box input[type="number"] {
        font-size: 18px;
        padding: 12px;
        width: 100%;
        border: 1px solid var(--border);
        border-radius: 8px;
    }
    
    .select-wrapper {
        margin-top: 8px;
        width: 100%;
    }
    
    .select-search {
        font-size: 13px;
        padding: 8px 12px;
        width: 100%;
        border: 1px solid var(--border-light);
        border-radius: 6px;
        margin-bottom: 6px;
    }
    
    .unit-select {
        font-size: 14px;
        padding: 10px 12px;
        width: 100%;
        border: 1px solid var(--border);
        border-radius: 8px;
    }
    
    .swap-btn {
        align-self: center;
        padding: 10px;
        font-size: 20px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        order: 1;
    }
    
    .input-box:first-child {
        order: 0;
    }
    
    .input-box:last-child {
        order: 2;
    }
    
    .result-display {
        padding: 14px;
        margin-top: 16px;
        border-radius: 8px;
    }
    
    .result-text {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .popular-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0 16px;
    }
    
    .popular-card {
        padding: 14px;
    }
    
    .popular-card h3 {
        font-size: 15px;
    }
    
    .popular-card p {
        font-size: 12px;
    }
    
    .currency-chart {
        padding: 16px;
        margin-top: 20px;
    }
    
    .currency-chart h3 {
        font-size: 15px;
        margin-bottom: 12px;
    }
    
    .chart-container {
        height: 200px;
        margin-top: 12px;
    }
    
    .seo-content {
        padding: 20px 16px;
    }
    
    .seo-content h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .seo-content h3 {
        font-size: 16px;
        margin-top: 16px;
        margin-bottom: 8px;
    }
    
    .seo-content p,
    .seo-content li {
        font-size: 14px;
        line-height: 1.6;
    }
    
    .ad-space {
        margin: 16px 0;
        padding: 0 16px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }
    
    .ad-placeholder {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    
    .ad-placeholder ins,
    .ad-placeholder ins.adsbygoogle {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
    }
    
    .ad-sidebar {
        display: none;
    }
    
    .popular-section {
        width: 100%;
        padding: 0 16px;
        box-sizing: border-box;
    }
    
    .popular-section h2 {
        margin: 24px 0 16px;
        padding: 0;
    }
}

/* Loading State */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Subtle hover effect */
.input-box input:hover {
    border-color: var(--text-secondary);
}

.unit-select:hover {
    border-color: var(--text-secondary);
}