/* 學習資源管理系統 - 共用樣式 */

:root {
    --primary: #4361ee;
    --primary-hover: #3a56d4;
    --success: #4cc9a4;
    --danger: #f72585;
    --warning: #f8961e;
    --info: #4895ef;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --border: #dee2e6;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f7fb;
    color: var(--dark);
    min-height: 100vh;
}

/* 登入頁 */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px 35px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header { text-align: center; margin-bottom: 30px; }

.login-icon {
    width: 70px; height: 70px;
    margin: 0 auto 15px;
    background: linear-gradient(135deg, var(--primary), #764ba2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 32px;
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3);
}

.login-header h1 {
    font-size: 22px; font-weight: 700;
    color: var(--dark); margin-bottom: 5px;
}

.login-header p { color: var(--gray); font-size: 14px; margin: 0; }

.login-card .form-label {
    font-weight: 600; color: var(--dark);
    font-size: 14px; margin-bottom: 8px;
}

.login-card .form-control {
    border: 2px solid var(--border);
    border-radius: 8px; padding: 10px 14px;
    font-size: 15px; transition: var(--transition);
}

.login-card .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.login-card .btn-primary {
    background: linear-gradient(135deg, var(--primary), #764ba2);
    border: none; border-radius: 8px;
    padding: 12px; font-weight: 600;
    font-size: 16px; transition: var(--transition);
}

.login-card .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

.login-card .btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.login-footer {
    text-align: center; margin-top: 25px;
    padding-top: 20px; border-top: 1px solid var(--border);
}

/* 管理頁面共用 */
.admin-navbar {
    background: linear-gradient(135deg, var(--primary), #764ba2);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.admin-navbar .navbar-brand {
    font-weight: 700; color: white !important; font-size: 18px;
}

.admin-navbar .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500; transition: var(--transition);
}

.admin-navbar .nav-link:hover { color: white !important; }

.admin-container {
    padding: 30px 20px; max-width: 1200px; margin: 0 auto;
}

.card {
    border: none; border-radius: 12px;
    box-shadow: var(--shadow); transition: var(--transition);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border);
    font-weight: 600; padding: 15px 20px;
}

.page-title {
    font-size: 26px; font-weight: 700;
    color: var(--dark); margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary);
    display: inline-block;
}

/* 首頁選單卡片 */
.menu-card-link {
    text-decoration: none; color: inherit;
    display: block; height: 100%;
}

.menu-card {
    background: white; border-radius: 12px;
    padding: 30px 20px; text-align: center;
    box-shadow: var(--shadow); transition: var(--transition);
    height: 100%; border-top: 4px solid transparent;
}

.menu-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    border-top-color: var(--primary);
}

.menu-icon {
    width: 70px; height: 70px; margin: 0 auto 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.menu-card h5 {
    color: var(--dark); font-weight: 700;
    margin-bottom: 10px; font-size: 18px;
}

.menu-card p { color: var(--gray); font-size: 13px; margin: 0; }

/* 載入動畫 */
.loading-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none; align-items: center; justify-content: center;
    z-index: 9999;
}

.loading-overlay.active { display: flex; }

/* =====================================================
   側邊欄佈局
   ===================================================== */
body {
    padding-top: 60px;
}

.admin-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: white;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 1020;
    transition: transform 0.3s ease;
}

.sidebar-nav { padding: 20px 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--dark);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background-color: #f0f4ff;
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-link.active {
    background-color: #e8efff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.admin-main {
    margin-left: 240px;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.3s ease;
}

.admin-content {
    padding: 30px;
    max-width: 1400px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1015;
}

.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.show { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 20px 15px; }
}

/* =====================================================
   儀表板統計卡片
   ===================================================== */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.stat-card-large {
    flex-direction: column;
    text-align: center;
    padding: 30px 20px;
}

.stat-card-large .stat-icon {
    margin: 0 auto;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card-large .stat-icon {
    width: 70px;
    height: 70px;
    font-size: 32px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    color: var(--gray);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-card-large .stat-value {
    font-size: 36px;
    margin-top: 8px;
}

/* 最近更新列表 */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.recent-item:hover {
    background-color: #f8f9fa;
    border-left-color: var(--primary);
}

.recent-item-title {
    font-weight: 500;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.recent-item-date {
    font-size: 12px;
    color: var(--gray);
    font-family: 'Courier New', monospace;
    white-space: nowrap;
}

/* 五個統計卡片一行排列 */
.stat-card {
    padding: 15px;
    gap: 12px;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

.stat-card .stat-label {
    font-size: 12px;
}

.stat-card .stat-value {
    font-size: 22px;
}

/* 響應式：小螢幕時改為兩排或一排 */
@media (max-width: 1199.98px) {
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    .stat-card .stat-value {
        font-size: 18px;
    }
    .stat-card .stat-label {
        font-size: 11px;
    }
}

@media (max-width: 767.98px) {
    .row.g-3 > .col {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* 內容項目 */
.content-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.content-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.content-item-body {
    padding-left: 5px;
}

/* 排序模式 */
.sortable-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sortable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: move;
    transition: var(--transition);
    font-weight: 500;
}

.sortable-item:hover {
    border-color: var(--primary);
    background: #f0f4ff;
}

.sortable-item .bi-grip-vertical {
    color: var(--gray);
    font-size: 18px;
}

.sortable-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 13px;
    flex-shrink: 0;
}

.sortable-ghost {
    opacity: 0.4;
    background: #e8efff;
}

/* 文章詳情表格 */
#sentencesContainer .table td,
#wordsContainer .table td {
    vertical-align: top;
    font-size: 14px;
}

#sentencesContainer .table td:nth-child(2) {
    font-family: 'Courier New', monospace;
}

/* =====================================================
   句子卡片
   ===================================================== */
.section-block {
    margin-bottom: 25px;
}

.section-title {
    color: var(--primary);
    font-weight: 700;
    padding-bottom: 8px;
    border-bottom: 2px solid #e8efff;
    margin-bottom: 15px;
}

.sentence-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: var(--transition);
    overflow: hidden;
}

.sentence-card.has-grammar {
    cursor: pointer;
}

.sentence-card.has-grammar:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
}

.sentence-card.expanded {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(67, 97, 238, 0.15);
}

.sentence-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 15px;
}

.sentence-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #4361ee, #764ba2);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sentence-content {
    flex: 1;
    min-width: 0;
}

.sentence-en {
    font-family: 'Courier New', monospace;
    font-size: 15px;
    color: var(--dark);
    line-height: 1.6;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.sentence-zh {
    font-size: 14px;
    color: var(--gray);
    line-height: 1.5;
}

.btn-toggle-grammar {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--gray);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    margin-top: 2px;
}

.sentence-card.has-grammar:hover .btn-toggle-grammar {
    border-color: var(--primary);
    color: var(--primary);
    background: #e8efff;
}

.sentence-card.expanded .btn-toggle-grammar {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.grammar-panel {
    padding: 15px 20px;
    background: linear-gradient(135deg, #fffbf0 0%, #fff8e6 100%);
    border-top: 1px solid #fce5a8;
    display: flex;
    gap: 12px;
    animation: slideDown 0.3s ease;
}

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

.grammar-icon {
    color: #f6b93b;
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.grammar-text {
    flex: 1;
    font-size: 14px;
    color: #6b5b2a;
    line-height: 1.6;
}

.grammar-text strong {
    display: block;
    margin-bottom: 4px;
    color: #d35400;
}

/* =====================================================
   單字片語 - 例句展開
   ===================================================== */
.detail-row td {
    background-color: #fafbfc;
    padding: 15px 20px;
}

.sentence-block {
    margin-bottom: 15px;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    border-left: 3px solid #4361ee;
}

.sentence-block:last-child {
    margin-bottom: 0;
}

.sentence-block:nth-child(2) {
    border-left-color: #4cc9a4;
}

.sentence-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 6px;
}

.sentence-en {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--dark);
    line-height: 1.6;
    margin-bottom: 4px;
}

.sentence-zh {
    font-size: 13px;
    color: var(--gray);
    line-height: 1.5;
}

.btn-toggle-detail {
    width: 32px;
}

/* =====================================================
   考題卡片
   ===================================================== */
.question-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.question-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.question-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
}

.question-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #4361ee, #764ba2);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.question-text {
    flex: 1;
    font-size: 15px;
    color: var(--dark);
    line-height: 1.5;
    word-wrap: break-word;
}

.question-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.question-options {
    padding: 12px 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.question-options > div {
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.question-options > div.correct {
    background: #e6f7ee;
    border-left-color: #4cc9a4;
    font-weight: 600;
}

.question-explain {
    padding: 10px 15px;
    background: #fffbf0;
    border-top: 1px solid #fce5a8;
    font-size: 13px;
    color: #6b5b2a;
}

@media (max-width: 767.98px) {
    .question-options {
        grid-template-columns: 1fr;
    }
}
