/* ============================================
   薬物動態アカデミー - Stylesheet
   Theme: Cyan (#0891b2)
   ============================================ */

:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #06b6d4;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #083344;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0c4a6e;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ---- Reset & Base ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans JP', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Header ---- */
.header {
    position: sticky;
    top: 0;
    height: 56px;
    background: var(--bg-sidebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.15);
}

.logo {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.logo-accent {
    color: var(--primary-light);
    margin-left: 2px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.15);
}

/* ---- Global Progress ---- */
.global-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 200px;
}

.global-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

.global-progress-fill {
    height: 100%;
    background: var(--primary-light);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.global-progress-text {
    color: rgba(255,255,255,0.8);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ---- Main Layout ---- */
.main-layout {
    display: flex;
    height: calc(100vh - 56px);
}

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    overflow-y: auto;
    color: #fff;
    padding-top: 8px;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

.sidebar-section {
    padding: 4px 0;
}

.dashboard-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    margin: 0 8px;
    transition: background 0.2s;
    font-weight: 600;
}

.dashboard-link:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-icon {
    font-size: 1.1rem;
}

.sidebar-level-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.7);
}

.sidebar-level-header:hover {
    background: rgba(255,255,255,0.08);
}

.sidebar-level-header .level-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-level-header .level-icon {
    font-size: 1rem;
}

.chevron {
    font-size: 0.7rem;
    transition: transform 0.3s;
    color: rgba(255,255,255,0.5);
}

.chevron.expanded {
    transform: rotate(90deg);
}

.sidebar-modules {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-modules.expanded {
    max-height: 500px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 28px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.88rem;
    color: rgba(255,255,255,0.8);
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.08);
}

.sidebar-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-item.completed {
    color: rgba(255,255,255,0.5);
}

.sidebar-item.completed::after {
    content: '✓';
    margin-left: auto;
    color: var(--success);
    font-weight: 700;
    opacity: 0.8;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    flex-shrink: 0;
}

.status-dot.completed {
    background: var(--success);
    border-color: var(--success);
}

.status-dot.in-progress {
    border-color: var(--primary-light);
}

/* ---- Content Area ---- */
.content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* ---- Module View ---- */
.module-header {
    margin-bottom: 24px;
}

.module-breadcrumb {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.module-breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.module-breadcrumb a:hover {
    text-decoration: underline;
}

.module-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ---- Module Body (Learning Content) ---- */
.module-body h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 28px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.module-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 8px;
}

.module-body p {
    margin: 10px 0;
    color: var(--text-primary);
    line-height: 1.8;
}

.module-body ul, .module-body ol {
    margin: 10px 0 10px 24px;
    color: var(--text-primary);
}

.module-body li {
    margin: 6px 0;
    line-height: 1.7;
}

.module-body strong {
    color: var(--primary-dark);
    font-weight: 600;
}

[data-theme="dark"] .module-body strong {
    color: var(--primary-light);
}

/* ---- Tables ---- */
.module-body table, table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.module-body th, th {
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.88rem;
}

.module-body td, td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}

.module-body tr:nth-child(even), tr:nth-child(even) {
    background: rgba(8,145,178,0.04);
}

[data-theme="dark"] .module-body tr:nth-child(even),
[data-theme="dark"] tr:nth-child(even) {
    background: rgba(6,182,212,0.06);
}

/* ---- Highlight Box ---- */
.highlight-box {
    border-left: 4px solid var(--primary);
    background: rgba(8,145,178,0.06);
    padding: 16px 20px;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.92rem;
    line-height: 1.7;
}

[data-theme="dark"] .highlight-box {
    background: rgba(6,182,212,0.1);
}

/* ---- Card Grid ---- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 16px 0;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--primary-dark);
}

[data-theme="dark"] .card h3 {
    color: var(--primary-light);
}

.card p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ---- Steps ---- */
.steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
}

.step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.step-num {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.step-content h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.step-content p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ---- Buttons ---- */
.btn {
    padding: 8px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

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

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

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
}

/* ---- Module Navigation ---- */
.module-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ---- Dashboard ---- */
.dashboard-hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 32px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.dashboard-hero h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.dashboard-hero p {
    opacity: 0.9;
    line-height: 1.6;
    font-size: 0.95rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.level-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
}

.level-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.level-card h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.level-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.level-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.level-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.level-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h2 {
    font-size: 1.4rem;
    margin-bottom: 16px;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 700;
    margin: 16px auto;
    border: 4px solid var(--border);
}

.score-circle.pass {
    color: var(--success);
    border-color: var(--success);
    background: rgba(16,185,129,0.08);
}

.score-circle.fail {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239,68,68,0.08);
}

/* ---- Quiz ---- */
.quiz-container {
    max-width: 800px;
}

.quiz-header {
    margin-bottom: 24px;
}

.quiz-header h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.quiz-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    max-width: 200px;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.quiz-question {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.quiz-question-num {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.quiz-question-text {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    line-height: 1.6;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    font-size: 0.92rem;
}

.quiz-option:hover {
    border-color: var(--primary-light);
    background: rgba(8,145,178,0.04);
}

.quiz-option.selected {
    border-color: var(--primary);
    background: rgba(8,145,178,0.08);
}

.quiz-option.correct {
    border-color: var(--success);
    background: rgba(16,185,129,0.1);
}

.quiz-option.incorrect {
    border-color: var(--danger);
    background: rgba(239,68,68,0.1);
}

.quiz-option-marker {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.quiz-option.selected .quiz-option-marker {
    background: var(--primary);
    color: #fff;
}

.quiz-option.correct .quiz-option-marker {
    background: var(--success);
    color: #fff;
}

.quiz-option.incorrect .quiz-option-marker {
    background: var(--danger);
    color: #fff;
}

.quiz-explanation {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    background: rgba(8,145,178,0.04);
    border-radius: 8px;
    margin-top: 8px;
}

.quiz-explanation.show {
    max-height: 200px;
    padding: 12px 16px;
}

.quiz-fill-blank input {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    width: 100%;
    max-width: 300px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.quiz-fill-blank input:focus {
    outline: none;
    border-color: var(--primary);
}

.quiz-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ---- Reference / Glossary ---- */
.reference-search {
    margin-bottom: 20px;
}

.reference-search input {
    width: 100%;
    max-width: 400px;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.reference-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.reference-category {
    margin-bottom: 24px;
}

.reference-category h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.reference-term {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

.reference-term dt {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

[data-theme="dark"] .reference-term dt {
    color: var(--primary-light);
}

.reference-term dd {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---- Fade In Animation ---- */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        z-index: 99;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        padding: 16px;
    }

    .global-progress {
        display: none;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-hero {
        padding: 20px;
    }

    .dashboard-hero h2 {
        font-size: 1.2rem;
    }

    .module-title {
        font-size: 1.3rem;
    }

    .modal {
        padding: 24px;
        width: 95%;
    }
}
