/* Global Resets and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --container-padding: 15px;
    --form-group-margin: 10px;
    --input-padding: 8px 10px;
    --border-radius: 5px;
}

/* Language Selector Styles */
.language-selector {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: auto;
    margin: 0;
    padding: 0;
}

.language-button {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 6px 12px 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: #333e48;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    font-weight: 500;
    height: 36px;
    min-width: 80px;
    justify-content: space-between;
}

.language-button:hover {
    background-color: #f1f3f5;
    border-color: #ced4da;
}

.language-button.active {
    background-color: #e9ecef;
}

.language-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    right: 0;
    left: auto;
    background-color: white;
    min-width: 180px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1001;
    border: 1px solid #e9ecef;
    padding: 8px 0;
    transform-origin: top right;
    font-size: 0.95em;
}

.language-dropdown a {
    color: #333e48;
    padding: 8px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s ease;
    font-size: 0.9em;
    white-space: nowrap;
    background-color: #fff;
}

.language-dropdown a:hover {
    background-color: #f8f9fa;
    color: #1a73e8;
}

.language-dropdown a .language-name {
    color: #6c757d;
    font-size: 0.8em;
    margin-left: auto;
    display: none; /* Ocultar el nombre completo en móviles */
}

.language-dropdown a:hover .language-name {
    color: #1a73e8;
}

.language-dropdown.show {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.flag-icon {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05);
}

.dropdown-arrow {
    font-size: 0.5em;
    margin-left: 2px;
    opacity: 0.7;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.language-button.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Ajustes para móviles */
@media (max-width: 768px) {
    .language-selector {
        top: 10px;
        right: 10px;
    }
    
    .language-button {
        padding: 5px 8px 5px 6px;
        font-size: 0.75em;
    }
    
    .language-dropdown {
        min-width: 140px;
    }
    
    .language-dropdown a {
        padding: 7px 12px;
        font-size: 0.8em;
    }
    
    .flag-icon {
        width: 16px;
        height: 12px;
    }
}

/* Language-specific font families */
:root {
    --font-zh: 'Noto Sans SC', 'Noto Sans TC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-ja: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic Pro', 'Meiryo', sans-serif;
    --font-ko: 'Noto Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    --font-en: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-ru: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

body {
    font-family: var(--font-en);
    line-height: 1.5;
    color: #333e48;
    background-color: #f7f8fc;
    padding: 10px;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Language-specific font overrides */
html[lang="zh-CN"],
html[lang="zh"],
html[lang="zh-Hans"] {
    font-family: var(--font-zh);
}

html[lang="zh-TW"],
html[lang="zh-Hant"] {
    font-family: var(--font-zh);
}

html[lang="ja"] {
    font-family: var(--font-ja);
}

html[lang="ko"] {
    font-family: var(--font-ko);
}

html[lang="ru"] {
    font-family: var(--font-ru);
}

.container {
    background-color: white;
    padding: 40px 20px 15px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 650px;
    margin: 0 auto 15px;
    position: relative;
}

h1 {
    font-family: 'Inter', sans-serif;
    color: #2c3e50;
    text-align: center;
    margin: 0 0 12px;
    font-size: 1.6em;
    font-weight: 700;
    letter-spacing: -0.4px;
    line-height: 1.2;
}

/* Form Styling */
.form-group {
    margin-bottom: var(--form-group-margin);
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
    font-size: 0.9em;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group select {
    width: 100%;
    padding: var(--input-padding);
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 0.9em;
    color: #333;
    transition: all 0.2s ease;
    height: 38px;
}

.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus,
.form-group select:focus {
    border-color: #5e95e1; /* Softer blue focus */
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(94, 149, 225, 0.25);
}

/* Button Styling */
button {
    display: block;
    width: 100%;
    padding: 9px 12px;
    background-color: #5e95e1;
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.2s ease;
    margin: 8px 0 0;
    height: 40px;
}

button:hover {
    background-color: #4a7ac4; /* Darker shade for hover */
}

button:active {
    transform: translateY(1px);
}

/* Citation Result Area */
#citationResult {
    margin-top: 15px;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 0.92em;
    line-height: 1.5;
}

#citationResult h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.25em;
    color: #2c3e50;
    font-weight: 600;
}

#outputAPA {
    font-family: "Times New Roman", Times, serif; /* Standard for APA citations */
    font-size: 1em;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #333e48;
}

#copyButton {
    margin-top: 15px;
    background-color: #4CAF50; /* Green for copy, good contrast */
}

#copyButton:hover {
    background-color: #45a049;
}

/* ======================
   RESPONSIVE ADJUSTMENTS
   ====================== */

/* Tablets (768px and down) */
@media (max-width: 768px) {
    :root {
        --container-padding: 12px;
        --form-group-margin: 8px;
        --input-padding: 7px 10px;
    }
    
    .container {
        padding: 35px 12px 10px;
        margin: 0 auto 10px;
    }
    
    .language-selector {
        top: 10px;
        right: 10px;
    }
    body {
        padding: 12px;
        font-size: 15px;
    }
    
    .container {
        padding: 20px 15px;
        margin: 10px auto;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.8em;
        margin: 10px 0 20px;
        line-height: 1.3;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-group label {
        font-size: 0.9em;
        margin-bottom: 6px;
    }
    
    .form-group input[type="text"],
    .form-group input[type="url"],
    .form-group select,
    button {
        padding: 12px 14px;
        font-size: 0.95em;
        border-radius: 5px;
    }
    
    /* Language Selector Adjustments */
    .language-selector {
        top: 8px;
        right: 8px;
    }
    
    .language-button {
        height: 34px;
        padding: 5px 10px;
        font-size: 0.85em;
        min-width: 70px;
    }
    
    .flag-icon {
        width: 18px;
        height: 14px;
    }
    
    .language-dropdown {
        min-width: 160px;
    }
    
    button {
        padding: 12px;
        font-size: 1em;
    }
    
    #citationResult {
        padding: 15px;
        margin-top: 20px;
    }
}

/* Mobile Phones (480px and down) */
@media (max-width: 480px) {
    :root {
        --container-padding: 10px;
        --form-group-margin: 6px;
        --input-padding: 6px 10px;
    }
    
    body {
        padding: 6px;
    }
    
    .container {
        padding: 32px 8px 8px;
        margin: 0 auto 8px;
    }
    
    h1 {
        font-size: 1.4em;
        margin: 0 0 8px;
    }
    
    .language-selector {
        top: 8px;
        right: 8px;
    }
    
    .language-button {
        padding: 4px 8px;
        font-size: 0.8em;
        height: 30px;
    }
    
    .language-dropdown {
        right: 0;
        left: auto;
        transform: none;
    }
    body {
        padding: 8px;
        font-size: 14px;
    }
    
    .container {
        padding: 15px 12px;
        margin: 5px auto;
        border-radius: 8px;
    }
    
    h1 {
        font-size: 1.6em;
        margin: 5px 0 15px;
        padding: 0 10px;
    }
    
    .form-group {
        margin-bottom: 14px;
    }
    
    .form-group label {
        font-size: 0.88em;
        margin-bottom: 5px;
    }
    
    .form-group input[type="text"],
    .form-group input[type="url"],
    .form-group select,
    button {
        padding: 11px 12px;
        font-size: 0.92em;
    }
    
    /* Language Selector Adjustments */
    .language-selector {
        top: 6px;
        right: 6px;
    }
    
    .language-button {
        height: 32px;
        padding: 4px 8px;
        font-size: 0.8em;
        min-width: 65px;
    }
    
    .flag-icon {
        width: 16px;
        height: 12px;
    }
    
    .language-dropdown {
        min-width: 150px;
        font-size: 0.9em;
    }
    
    button {
        padding: 11px;
        font-size: 0.95em;
    }
    
    #citationResult {
        padding: 12px;
        margin-top: 18px;
    }
    
    #outputAPA {
        font-size: 0.95em;
        line-height: 1.6;
    }
}

/* Small Mobile Phones (360px and down) */
@media (max-width: 360px) {
    h1 {
        font-size: 1.5em;
    }
    
    .form-group input[type="text"],
    .form-group input[type="url"],
    .form-group select,
    button {
        padding: 10px 12px;
        font-size: 0.9em;
    }
    
    .language-button {
        height: 30px;
        padding: 3px 6px;
        min-width: 60px;
    }
    
    .flag-icon {
        width: 14px;
        height: 11px;
    }
    
    .language-dropdown a {
        padding: 6px 12px;
        gap: 8px;
    }
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
