/* ========================================
   プログラミング学習アプリ - メインスタイル
   ======================================== */

:root {
    --primary:    #5B6EF5;
    --secondary:  #FF6B35;
    --success:    #4CAF50;
    --warning:    #FFC107;
    --danger:     #f44336;
    --scratch:    #FF6B35;
    --minecraft:  #4CAF50;
    --bg:         #F0F4FF;
    --card-bg:    #FFFFFF;
    --text:       #2D2D2D;
    --text-light: #666;
    --radius:     16px;
    --shadow:     0 4px 20px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', 'Yu Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
}

/* ========== ログインページ ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-wrap {
    background: #fff;
    border-radius: 24px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.login-logo h1 {
    font-size: 22px;
    color: var(--primary);
    font-weight: 900;
    line-height: 1.4;
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.8;
}

/* ========== ナビゲーション ========== */
.navbar {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--primary);
    font-size: 18px;
    font-weight: 900;
}

.navbar-brand .brand-icon { font-size: 28px; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-light);
}

.navbar-user strong { color: var(--text); }

/* ========== メインレイアウト ========== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 16px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 900;
    color: var(--text);
}

.page-header p {
    color: var(--text-light);
    margin-top: 4px;
}

/* ========== カード ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.14); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ========== コースカード ========== */
.course-card {
    border-radius: var(--radius);
    padding: 32px 24px;
    color: #fff;
    text-decoration: none;
    display: block;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.course-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.2); }

.course-card.scratch   { background: linear-gradient(135deg, #FF6B35 0%, #FF8E53 100%); }
.course-card.minecraft { background: linear-gradient(135deg, #2E7D32 0%, #43A047 100%); }
.course-card.html      { background: linear-gradient(135deg, #1976D2 0%, #42A5F5 100%); }

.course-card .course-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
}

.course-card h3 { font-size: 22px; font-weight: 900; margin-bottom: 8px; }
.course-card p  { font-size: 14px; opacity: 0.9; }

.course-card .progress-info {
    margin-top: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
}

.progress-bar-wrap {
    background: rgba(255,255,255,0.3);
    border-radius: 999px;
    height: 8px;
    margin-top: 8px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #fff;
    border-radius: 999px;
    transition: width 0.6s ease;
}

/* ========== 課題リスト ========== */
.task-list { list-style: none; }

.task-item {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
    transition: transform 0.15s;
}

.task-item:hover { transform: translateX(4px); }

.task-item a {
    display: flex;
    align-items: center;
    padding: 18px 24px;
    text-decoration: none;
    color: var(--text);
    gap: 16px;
}

.task-num {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 16px;
    flex-shrink: 0;
}

.task-item.completed .task-num {
    background: var(--success);
    color: #fff;
}

.task-item.completed .task-num::after { content: '✓'; }

.task-info { flex: 1; }
.task-title { font-size: 17px; font-weight: 700; }
.task-meta  { font-size: 13px; color: var(--text-light); margin-top: 2px; }

.difficulty {
    display: inline-flex;
    gap: 2px;
    margin-left: 8px;
}

.star { color: #FFC107; font-size: 14px; }
.star.empty { color: #ddd; }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success  { background: #E8F5E9; color: #2E7D32; }
.badge-warning  { background: #FFF8E1; color: #F57F17; }
.badge-primary  { background: #E8EAF6; color: #3949AB; }

/* ========== 課題詳細ページ ========== */
.task-detail-header {
    background: #fff;
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.task-detail-header h2 {
    font-size: 26px;
    font-weight: 900;
    margin-bottom: 12px;
}

.task-description {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    font-size: 17px;
    line-height: 1.8;
}

.code-block {
    background: #1E1E2E;
    color: #CDD6F4;
    border-radius: 12px;
    padding: 24px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.7;
    overflow-x: auto;
    margin: 16px 0;
    position: relative;
}

.code-block .code-label {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 11px;
    color: #888;
    font-family: sans-serif;
}

.hint-box {
    background: #FFF8E1;
    border-left: 4px solid #FFC107;
    border-radius: 0 12px 12px 0;
    padding: 16px 20px;
    margin: 16px 0;
}

.hint-box strong { color: #F57F17; }

.action-bar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.completed-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #E8F5E9;
    color: #2E7D32;
    border-radius: 999px;
    padding: 12px 24px;
    font-weight: 700;
    font-size: 16px;
}

/* ========== ボタン ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-secondary { background: #eee;             color: var(--text); }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-scratch   { background: var(--scratch);   color: #fff; }
.btn-minecraft { background: var(--minecraft); color: #fff; }

.btn-lg   { padding: 16px 32px; font-size: 18px; }
.btn-block { width: 100%; justify-content: center; }

.btn-external {
    background: linear-gradient(135deg, #5B6EF5, #764ba2);
    color: #fff;
}

/* ========== フォーム ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 15px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #E0E0E0;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group textarea { min-height: 120px; resize: vertical; }

/* ========== アラート ========== */
.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
}

.alert-error   { background: #FFEBEE; color: #C62828; border-left: 4px solid #f44336; }
.alert-success { background: #E8F5E9; color: #1B5E20; border-left: 4px solid #4CAF50; }
.alert-info    { background: #E3F2FD; color: #0D47A1; border-left: 4px solid #2196F3; }

/* ========== 管理者テーブル ========== */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid #F0F0F0;
}

th {
    background: var(--bg);
    font-weight: 700;
    font-size: 14px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAFA; }

/* ========== 進捗グリッド ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-num  { font-size: 40px; font-weight: 900; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* ========== 完了アニメーション ========== */
@keyframes celebrate {
    0%   { transform: scale(0.8) rotate(-5deg); opacity: 0; }
    50%  { transform: scale(1.1) rotate(3deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.celebrate { animation: celebrate 0.5s ease forwards; }

/* ========== レスポンシブ ========== */
@media (max-width: 600px) {
    .navbar { padding: 0 12px; }
    .container { padding: 16px 12px; }
    .login-wrap { padding: 32px 20px; margin: 16px; }
    .card-grid { grid-template-columns: 1fr; }
    .task-item a { padding: 14px 16px; }
}
