/* CSS luyện viết câu */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #4895ef;
    --success-color: #2ec4b6;
    --warning-color: #ff9f1c;
    --error-color: #e71d36;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --gray-color: #6c757d;
    --border-color: #dee2e6;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 10px; /* Giảm padding cho mobile */
    font-size: 16px; /* Kích thước chữ cơ bản cho mobile */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    padding: 15px; /* Giảm padding cho mobile */
}

header {
    background: linear-gradient(to right, #3498db, #2c3e50);
    color: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Cho phép wrap trên mobile */
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem; /* Giảm kích thước chữ cho mobile */
    font-weight: 700;
}

.logo i {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap; /* Cho phép wrap trên mobile */
    justify-content: center;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 0.8rem;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem; /* Giảm kích thước chữ cho mobile */
}

.nav-links a:hover,
.nav-links a.active {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.subtitle {
    font-size: 0.95rem; /* Giảm kích thước chữ cho mobile */
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Content Styles */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1.5rem 0;
}

@media (min-width: 992px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
}

/* Card Styles */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.card:hover {
    transform: translateY(-5px); /* Giảm hiệu ứng nâng lên cho mobile */
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.15);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 1.25rem;
}

/* API Key Section */
.api-key-section {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.api-key-section h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 1.25rem; /* Giảm kích thước chữ */
}

.api-form {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-direction: column; /* Xếp dọc trên mobile */
}

.api-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    transition: var(--transition);
    background: #f8f9ff;
}

.api-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.btn {
    padding: 10px 25px;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#toggle-api-settings {
    background: var(--accent-color);
    color: white;
    box-shadow: var(--card-shadow);
}

#toggle-api-settings:hover {
    background: #3866e8;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 3px 10px rgba(67, 97, 238, 0.25);
}

.btn-primary:hover {
    background: #3251d4;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(67, 97, 238, 0.35);
}

.btn-success {
    background: var(--success-color);
    color: white;
    box-shadow: 0 3px 10px rgba(46, 196, 182, 0.25);
}

.btn-success:hover {
    background: #27a99d;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(46, 196, 182, 0.35);
}

.xbtn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
    box-shadow: 0 3px 10px rgba(255, 159, 28, 0.25);
}

.btn-warning:hover {
    background: #e68e00;
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(255, 159, 28, 0.35);
}

/* Practice Section */
.vietnamese-text {
    font-size: 1.25rem; /* Giảm kích thước chữ cho mobile */
    margin-bottom: 1.25rem;
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    border-radius: 10px;
    border-left: 3px solid var(--primary-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.translation-input textarea {
    width: 100%;
    min-height: 140px; /* Giảm chiều cao textarea cho mobile */
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    resize: vertical;
    transition: var(--transition);
    background: #f8f9ff;
}

.translation-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    justify-content: center; /* Căn giữa trên mobile */
}

.action-buttons .btn {
    flex: 1;
    min-width: 120px; /* Giảm chiều rộng tối thiểu */
    padding: 0.75rem; /* Giảm padding */
}

/* Hint Section */
.hint-toggle {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
    cursor: pointer;
}

.hint-toggle .btn-hint {
    background: none;
    border: none;
    color: var(--gray-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    padding: 6px 12px;
    border-radius: 25px;
}

.hint-toggle .btn-hint:hover {
    color: var(--primary-color);
    background: rgba(67, 97, 238, 0.08);
}

.hint-content {
    display: none;
    margin-top: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    border-radius: 10px;
    border-left: 3px solid var(--accent-color);
    flex-wrap: wrap;
    gap: 10px;
}

.hint-word {
    background-color: white;
    padding: 8px 15px;
    border-radius: 25px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: var(--transition);
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 4px;
}

.hint-word:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(67, 97, 238, 0.25);
}

.hint-word .en {
    font-weight: 600;
    font-size: 1rem;
}

.hint-word .vi {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Level & Category Section */
.level-category-section {
    padding: 1.25rem;
}

.selection-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

@media (min-width: 992px) {
    .selection-section {
        gridmarket: grid-template-columns: 1fr 1fr;
    }
}

.selection-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.selection-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.selection-card h2 {
    background: #2c3e50;
    color: white;
    padding: 12px 15px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 1.75rem;
    position: relative;
    padding-bottom: 0.75rem;
}

.section-title:after {
    display: none;
}

.levels {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.level-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem 1.25rem;
    width: 100%;
    max-width: 280px; /* Giảm chiều rộng cho mobile */
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(67, 97, 238, 0.1);
    position: relative;
    overflow: hidden;
}

.level-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
    transform: scaleX(0);
    transform-origin: left;
    transition: var(--transition);
}

.level-card:hover, .level-card.active {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(67, 97, 238, 0.15);
}

.level-card.active {
    background: linear-gradient(135deg, #f8fbff 0%, #f0f7ff 100%);
}

.level-card.active:before {
    transform: scaleX(1);
}

.level-icon {
    font-size: 2.5rem;
    margin-bottom: 1.25rem;
    color: var(--primary-color);
    transition: var(--transition);
}

.level-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.level-desc {
    color: var(--gray-color);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.level-time {
    display: inline-block;
    padding: 6px 15px;
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
}

.categories {
    display: grid;
    grid-template-columns: 1fr; /* Một cột trên mobile */
    gap: 15px;
}

@media (min-width: 768px) {
    .categories {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

.category-group {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid rgba(67, 97, 238, 0.1);
}

.category-group-title {
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
}

.category-list {
    list-style-type: none;
}

.category-item {
    padding: 0.5rem 0;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 6px;
    padding-left: 10px;
}

.category-item:hover {
    background: rgba(67, 97, 238, 0.05);
    color: var(--primary-color);
    transform: translateX(4px);
}

.category-item.active {
    color: var(--primary-color);
    font-weight: 600;
    background: rgba(67, 97, 238, 0.1);
}

.category-item i {
    font-size: 0.85rem;
    color: var(--primary-color);
    opacity: 0.7;
}

.start-practice-container {
    text-align: center;
    margin-top: 2.5rem;
}

.start-practice-btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.start-practice-btn:hover {
    background: linear-gradient(135deg, #3251d4, #2d0990);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.5);
}

/* Feedback Section */
.feedback-content {
    background-color: #f8f9ff;
    border-radius: 12px;
    padding: 1.25rem;
    min-height: 180px;
}

.feedback-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary {
    font-style: italic;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    border-radius: 10px;
    border-left: 3px solid var(--accent-color);
}

.error-list {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 1.25rem;
}

.error-list li {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background-color: #fff4f4;
    border-left: 3px solid var(--error-color);
    border-radius: 6px;
    transition: var(--transition);
}

.error-list li:hover {
    transform: translateX(4px);
}

.error-list li::before {
    content: "•";
    color: var(--error-color);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

.suggestion-text {
    font-size: 1rem;
    line-height: 1.6;
    padding: 1rem;
    background: linear-gradient(135deg, #e8f4fd 0%, #e0f0fa 100%);
    border-radius: 10px;
    border-left: 3px solid var(--success-color);
}

/* Footer */
footer {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.social-links {
    display: flex;
    gap: 1.5rem;
    font-size: 1.5rem;
}

.social-links a {
    color: white;
    transition: var(--transition);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
}

.social-links a:hover {
    color: var(--success-color);
    transform: translateY(-4px);
    background: rgba(255,255,255,0.2);
}

/* Spinner */
.spinner {
    display: none;
    text-align: center;
    padding: 1.5rem;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--primary-color);
    border: 0.3em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
    margin: 0 auto;
}
.spinner-text {
  margin-top: 1rem;
  font-weight: 500;
  color: var(--gray-color);
  text-align: center;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Utility Classes */
.hidden {
    display: none;
}

.mt-2 {
    margin-top: 0.75rem;
}

.mb-2 {
    margin-bottom: 0.75rem;
}

.text-center {
    text-align: center;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .levels {
        flex-direction: column;
        align-items: center;
    }
    
    .level-card {
        width: 100%;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 8px; /* Giảm padding hơn nữa cho mobile nhỏ */
        font-size: 15px; /* Giảm kích thước chữ cho màn hình nhỏ */
    }
    
    .container {
        padding: 12px;
        border-radius: 10px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        flex: 100%;
        padding: 0.7rem;
        font-size: 0.9rem;
    }
    
    .api-form {
        flex-direction: column;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .level-category-section {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .start-practice-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }
    
    .vietnamese-text {
        font-size: 1.1rem;
        padding: 0.8rem;
    }
    
    .translation-input textarea {
        min-height: 120px;
        font-size: 0.95rem;
        padding: 0.8rem;
    }
    
    .hint-content {
        padding: 0.8rem;
        gap: 8px;
    }
    
    .hint-word {
        padding: 6px 12px;
        margin: 3px;
    }
    
    .hint-word .en {
        font-size: 0.95rem;
    }
    
    .hint-word .vi {
        font-size: 0.75rem;
    }
    
    .feedback-content {
        padding: 1rem;
        min-height: 160px;
    }
    
    .feedback-title {
        font-size: 1.1rem;
    }
    
    .summary {
        padding: 0.8rem;
    }
    
    .suggestion-text {
        padding: 0.8rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
        font-size: 14px;
    }
    
    .container {
        padding: 10px;
        border-radius: 8px;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .logo i {
        font-size: 1.5rem;
    }
    
    .nav-links a {
        font-size: 0.85rem;
        padding: 0.4rem 0.7rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .card-header {
        font-size: 1rem;
        padding: 0.8rem 1rem;
    }
    
    .api-key-section h2 {
        font-size: 1.1rem;
    }
    
    .api-form input {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .level-card {
        padding: 1.25rem;
        max-width: 350px;
    }
    
    .level-icon {
        font-size: 2rem;
    }
    
    .level-title {
        font-size: 1.3rem;
    }
    
    .level-desc {
        font-size: 0.9rem;
    }
    
    .category-group {
        padding: 1rem;
    }
    
    .category-group-title {
        font-size: 1.1rem;
    }
    
    .category-item {
        padding: 0.4rem 0;
    }
    
    .start-practice-btn {
        padding: 0.8rem;
        font-size: 0.95rem;
    }
}

.btn-random {
    background-color: #9b59b6;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 0.9rem;
}

.btn-random:hover {
    background-color: #8e44ad;
}