@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
    --primary-color: #48D1CC;
    /* Mint */
    --secondary-color: #20B2AA;
    /* Light Sea Green */
    --accent-color: #FFD700;
    /* Gold for arcade highlights */
    --bg-gradient-start: #F0FAF9;
    --bg-gradient-end: #E0F2F1;
    --text-dark: #2C3E50;
    --text-light: #7F8C8D;
    --success-color: #52D273;
    --error-color: #FF6B6B;
    --card-bg: #FFFFFF;
    --shadow-sm: 0 4px 12px rgba(72, 209, 204, 0.1);
    --shadow-md: 0 8px 24px rgba(72, 209, 204, 0.15);
    --shadow-lg: 0 12px 48px rgba(72, 209, 204, 0.2);
    --border-radius: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.5;
    font-size: 16px;
    letter-spacing: -0.025em;
    /* Closer to Apple's San Francisco */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 컨테이너 */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* 헤더 */
.header {
    text-align: center;
    padding: 60px 0 40px;
}

.header h1 {
    font-family: 'Pretendard', sans-serif;
    font-size: 3.5rem;
    color: var(--primary-color);
    font-weight: 700;
    text-shadow: 3px 3px 0px rgba(72, 209, 204, 0.1);
    margin-bottom: 12px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    font-weight: 600;
}

/* 카드 스타일 */
.auth-section,
.main-section,
.vocab-detail {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 40px 30px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    border: 1px solid rgba(72, 209, 204, 0.1);
}

.auth-section h2,
.main-section h2,
.vocab-detail h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

/* 폼 스타일 */
.form-group {
    margin-bottom: 20px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #E0F2F1;
    border-radius: 14px;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #FFF;
    color: var(--text-dark);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(72, 209, 204, 0.1);
    transform: translateY(-1px);
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 600;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
}

/* 버튼 스타일 */
.btn {
    padding: 16px 28px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    touch-action: manipulation;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(72, 209, 204, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 209, 204, 0.4);
    filter: brightness(1.05);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #ECF0F1;
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #D5DBDB;
}

.btn-admin {
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
    margin-top: 10px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    width: auto;
    min-height: auto;
}

.btn-back {
    background: transparent;
    color: var(--text-light);
    border: 2px solid #ECF0F1;
    margin-top: 20px;
}

/* 링크 */
.switch-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
}

.switch-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.switch-link a:hover {
    text-decoration: underline;
}

/* 사용자 정보 */
.user-info {
    text-align: center;
    margin-bottom: 30px;
}

.user-info h2 {
    margin-bottom: 15px;
}

/* 단어집 리스트 */
.vocabulary-select h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.vocab-list {
    display: grid;
    gap: 15px;
}

.vocab-card {
    background: white;
    border: 2px solid #E0F2F1;
    border-radius: 20px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.vocab-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
}

.vocab-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, transparent 50%, rgba(72, 209, 204, 0.1) 50%);
}

.vocab-card h4 {
    color: var(--text-dark);
    font-family: 'Pretendard', sans-serif;
    font-size: 1.4rem;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.vocab-card:hover h4 {
    color: var(--primary-color);
}

.vocab-card p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* 레벨 정보 */
.level-info {
    background: linear-gradient(135deg, #F0FAF9 0%, #E0F2F1 100%);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid rgba(72, 209, 204, 0.2);
}

.level-info p {
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 500;
}

.level-info p:last-child {
    margin-bottom: 0;
}

.level-info strong {
    color: var(--secondary-color);
    font-size: 1.4rem;
    font-weight: 800;
}

/* 프로그레스 바 */
.progress-bar {
    width: 100%;
    height: 14px;
    background: #E0F2F1;
    border-radius: 7px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 7px;
    transition: width 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.progress-text {
    text-align: center;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 24px;
}

/* 모드 선택 */
.mode-select {
    margin: 30px 0;
}

.mode-select h4 {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-family: 'Gowun Batang', serif;
    font-weight: 700;
}

.btn-mode {
    margin-bottom: 16px;
    text-align: left;
    padding: 24px;
    background: white;
    color: var(--text-dark);
    border: 2px solid #E0F2F1;
    border-radius: 20px;
    display: block;
}

.btn-mode:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.btn-normal {
    border-left: 6px solid #52D273;
}

.btn-timed {
    border-left: 6px solid #FF6B6B;
}

.mode-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.mode-desc {
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 400;
}

/* 설정 */
.settings {
    background: #F8F9FA;
    border-radius: 12px;
    padding: 15px;
    margin-top: 20px;
}

.settings label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
}

.settings input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* 관리자 페이지 */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    background: var(--card-bg);
    padding: 24px 32px;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(72, 209, 204, 0.1);
}

.admin-title {
    color: var(--secondary-color);
    font-weight: 800;
    font-size: 1.8rem;
    white-space: nowrap;
    margin-right: 20px;
    /* Ensure spacing from button */
}

.btn-back-main {
    padding: 8px 16px;
    font-size: 0.85rem;
    height: auto;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    box-shadow: none;
    font-weight: 600;
}

.btn-back-main:hover {
    background: #f1f5f9;
    color: var(--secondary-color);
    transform: translateY(-1px);
}

.admin-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 30px;
}

@media (max-width: 900px) {
    .admin-sections {
        grid-template-columns: 1fr;
    }
}

.admin-section {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 35px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(72, 209, 204, 0.05);
}

.admin-section h2 {
    color: var(--secondary-color);
    margin-bottom: 25px;
    font-size: 1.4rem;
    font-weight: 800;
    border-left: 5px solid var(--primary-color);
    padding-left: 15px;
}

.admin-form-group {
    margin-bottom: 24px;
}

.admin-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.select-with-btn {
    display: flex;
    gap: 10px;
    align-items: center;
}

.select-with-btn select {
    flex: 1;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-upload {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    margin-top: 10px;
}

/* User List Table-like */
.user-search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.user-search-box input {
    flex: 1;
    padding: 14px 20px;
    font-size: 1rem;
    border: 2px solid #E0F2F1;
    border-radius: 14px;
    transition: all 0.2s ease;
    background: #F8F9FA;
    font-family: 'Pretendard', sans-serif;
    color: var(--text-dark);
}

.user-search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(72, 209, 204, 0.1);
}

.user-search-box .btn {
    padding: 0 24px;
    border-radius: 14px;
    font-weight: 700;
}

.user-list-container {
    margin-top: 20px;
    border: 1px solid #E0F2F1;
    border-radius: 16px;
    overflow: hidden;
}

.user-list-header {
    display: grid;
    grid-template-columns: 1fr 100px 150px;
    background: #F0FAF9;
    padding: 15px 20px;
    font-weight: 800;
    font-size: 0.75rem;
    color: var(--secondary-color);
    letter-spacing: 1px;
}

.user-list-body {
    max-height: 500px;
    overflow-y: auto;
}

.user-item {
    display: grid;
    grid-template-columns: 1fr 100px 150px;
    padding: 18px 20px;
    align-items: center;
    border-bottom: 1px solid #F0FAF9;
    transition: background 0.2s;
}

.user-item:last-child {
    border-bottom: none;
}

.user-item:hover {
    background: #F8FDFF;
}

.u-username {
    font-weight: 700;
    color: var(--text-dark);
}

.u-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 6px;
    margin-left: 8px;
    font-weight: 800;
}

.u-badge.admin {
    background: rgba(72, 209, 204, 0.1);
    color: var(--primary-color);
}

.u-badge.user {
    background: #f1f5f9;
    color: #64748b;
}

.u-level-box {
    text-align: center;
}

.u-level-val {
    font-weight: 800;
    color: var(--secondary-color);
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
}

.u-actions-box {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-tiny {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
    width: auto;
    min-width: 50px;
}

.btn-danger {
    background: #FF6B6B;
    border: none;
    color: white;
}

.btn-danger:hover {
    background: #ff4d4d;
}

/* 확장된 사용자 아이템 (단어집별 통계) */
.user-item-expanded {
    padding: 15px 20px;
    border-bottom: 1px solid #F0FAF9;
    transition: background 0.2s;
}

.user-item-expanded:last-child {
    border-bottom: none;
}

.user-item-expanded:hover {
    background: #F8FDFF;
}

.user-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.user-vocab-stats {
    margin-left: 10px;
    padding: 10px 15px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.vocab-stat-row {
    display: grid;
    grid-template-columns: 1fr 80px 80px;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.85rem;
    border-bottom: 1px dashed #e2e8f0;
}

.vocab-stat-row:last-child {
    border-bottom: none;
}

.vocab-name {
    color: var(--text-dark);
    font-weight: 600;
}

.vocab-level {
    text-align: center;
    color: var(--secondary-color);
    font-weight: 700;
}

.vocab-attempts {
    text-align: right;
    color: var(--text-light);
    font-weight: 500;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table th,
.admin-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #E0F2F1;
}

.admin-table th {
    background: #F0FAF9;
    color: var(--secondary-color);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.admin-table tr:hover td {
    background: #F8FDFF;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

/* 로딩 & 상태 메시지 */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.status-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.status-message.success {
    background: #D4EDDA;
    color: #155724;
}

.status-message.error {
    background: #F8D7DA;
    color: #721C24;
}

/* 단어 관리 섹션 */
#wordManagementSection {
    grid-column: 1 / -1;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin-bottom: 0;
}

.word-management-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.word-search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 200px;
    align-items: stretch;
}

.word-search-box input {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.95rem;
    border: 2px solid #E0F2F1;
    border-radius: 12px;
    transition: all 0.2s ease;
    background: #F8F9FA;
}

.word-search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(72, 209, 204, 0.1);
}

.word-search-box .btn {
    padding: 0 20px;
    border-radius: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    box-sizing: border-box;
}

.word-search-box input {
    height: 48px;
    box-sizing: border-box;
    padding: 0 16px;
    /* Vertical padding handled by height/box-sizing */
}

#addWordBtn {
    white-space: nowrap;
    padding: 12px 20px;
    border-radius: 12px;
}

.word-list-container {
    border: 1px solid #E0F2F1;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
}

.word-table {
    table-layout: fixed;
}

.word-table .col-order {
    width: 60px;
    text-align: center;
}

.word-table .col-english {
    width: 25%;
}

.word-table .col-korean {
    width: 25%;
}

.word-table .col-desc {
    width: auto;
}

.word-table .col-actions {
    width: 140px;
    text-align: center;
}

.word-table td {
    vertical-align: middle;
    word-break: break-word;
}

.word-table td.col-order {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
}

.word-table td.col-actions {
    text-align: center;
    white-space: nowrap;
}

.admin-table td:last-child {
    white-space: nowrap;
    text-align: center;
}

.word-table td.col-actions .btn,
.admin-table td:last-child .btn {
    display: inline-flex;
    margin: 0 2px;
}

/* 페이지네이션 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid #E0F2F1;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    padding: 8px 12px;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* 단어집 테이블 클릭 가능 표시 */
.vocab-row-clickable {
    cursor: pointer;
    transition: background 0.2s ease;
}

.vocab-row-clickable:hover {
    background: #F0FAF9 !important;
}

.vocab-row-clickable.selected {
    background: #E0F7F5 !important;
    border-left: 3px solid var(--primary-color);
}

/* 반응형 */
@media (max-width: 768px) {
    .word-management-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .word-search-box {
        width: 100%;
    }

    #addWordBtn {
        width: 100%;
    }

    .word-table .col-desc {
        display: none;
    }

    .word-table .col-actions {
        width: 100px;
    }
}