/* ========================================
   MIRAI-QUEST AI - Modern Design System
   Reference: React App Design
======================================== */

:root {
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --orange-500: #f97316;
    --red-500: #ef4444;
    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-600: #d97706;
    
    /* グラデーション */
    --student-gradient: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    --teacher-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
}

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

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========== 背景 ========== */
.top-page {
    min-height: 100vh;
    background-color: #0f172a;
    background-image: url('/images/background.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}

.sub-page {
    min-height: 100vh;
    background-color: #0f172a;
    background-image: url('/images/sub_background.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.5) 0%, rgba(30, 41, 59, 0.4) 100%);
    z-index: 1;
    pointer-events: none;
}

/* ========== コンテナ ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 40px;
    position: relative;
    z-index: 2;
}

/* ========== ナビゲーション ========== */
.sub-header {
    padding: 12px 0;
    text-align: center;
    position: relative;
    z-index: 2;
}

.logo-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: transform 0.2s ease;
    padding: 10px 24px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-badge:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.15);
}

.logo-text {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: white;
    text-transform: uppercase;
}

.logo-highlight {
    color: var(--orange-500);
}

/* ========== トップページ ========== */
.top-header {
    padding: 40px 0 24px;
    text-align: center;
    color: white;
}

.main-title {
    font-size: clamp(1.6rem, 5vw, 3.5rem);
    font-weight: 900;
    color: white;
    margin: 20px 0 16px;
    letter-spacing: -0.03em;
    line-height: 1.2;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: rgba(255, 255, 255, 0.85);
    font-weight: 700;
    max-width: 800px;
    margin: 0 auto;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .subtitle {
        white-space: normal;
        max-width: 90%;
    }
}

/* ========== ログインカード ========== */
.top-main {
    padding: 16px 0 40px;
}

.login-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
    max-width: 900px;
    margin: 0 auto;
}

.login-card {
    background: white;
    border-radius: 32px;
    padding: 32px 28px;
    text-align: center;
    border: 2px solid white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 360px;
    position: relative;
    z-index: 2;
}

.login-card:hover {
    transform: scale(1.01);
}

.card-bg-icon {
    display: none;
}

.card-glow {
    display: none;
}

.card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-content h2 {
    font-size: 1.75rem;
    font-weight: 900;
    margin-bottom: 8px;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.card-description {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-bottom: 24px;
    font-weight: 700;
    line-height: 1.7;
}

.card-form-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ========== クラスコード入力 ========== */
.class-code-input {
    display: block;
    width: 100%;
    height: 52px;
    background: var(--gray-50);
    border: 2px solid var(--gray-100);
    border-radius: 14px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 900;
    font-family: 'Inter', sans-serif;
    color: var(--gray-900);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.class-code-input:focus {
    outline: none;
    border-color: var(--emerald-500);
    background: white;
}

.class-code-input::placeholder {
    font-size: 1rem;
    letter-spacing: 0.15em;
    color: var(--gray-200);
    font-weight: 900;
}

/* ========== ボタン ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    width: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
}

.btn:active {
    transform: scale(0.97);
}

.btn-student-gradient {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    color: white;
    box-shadow: 
        0 10px 30px -5px rgba(16, 185, 129, 0.5),
        0 4px 6px -2px rgba(16, 185, 129, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-student-gradient:hover {
    box-shadow: 
        0 15px 40px -5px rgba(16, 185, 129, 0.6),
        0 8px 12px -4px rgba(16, 185, 129, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-teacher-gradient {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
    color: white;
    box-shadow: 
        0 10px 30px -5px rgba(37, 99, 235, 0.5),
        0 4px 6px -2px rgba(37, 99, 235, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-teacher-gradient:hover {
    box-shadow: 
        0 15px 40px -5px rgba(37, 99, 235, 0.6),
        0 8px 12px -4px rgba(37, 99, 235, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-wrapper {
    margin-top: 8px;
}

/* ========== カードリンク ========== */
.card-link {
    display: inline-block;
    margin-top: 20px;
    color: var(--emerald-600);
    font-weight: 800;
    font-size: 0.95rem;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.card-link:hover {
    text-decoration: underline;
    background: rgba(16, 185, 129, 0.08);
}

.link-teacher {
    color: var(--blue-600);
}

.link-teacher:hover {
    background: rgba(37, 99, 235, 0.08);
}

/* ========== フォームコンテナ ========== */
.form-container {
    background: white;
    border-radius: 32px;
    padding: 32px;
    border: 2px solid white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.logo-container {
    text-align: center;
    margin-bottom: 24px;
}

/* ========== フォーム要素 ========== */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 900;
    font-size: 0.85rem;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    display: block;
    width: 100%;
    height: 48px;
    background: var(--gray-50);
    border: 2px solid var(--gray-100);
    border-radius: 12px;
    padding: 0 16px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-900);
    transition: all 0.3s ease;
}

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

.form-group input::placeholder {
    color: var(--gray-300);
    font-weight: 500;
}

/* パスワード入力 */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 56px;
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-300);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: var(--emerald-500);
}

/* チェックボックス */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--emerald-500);
}

.checkbox-group label {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 600;
    margin-bottom: 0;
    cursor: pointer;
}

/* フッターリンク */
.form-footer-links {
    margin-top: 24px;
    text-align: center;
}

.form-footer-links a {
    color: var(--emerald-600);
    font-weight: 900;
    font-size: 0.85rem;
    text-decoration: none;
}

.form-footer-links a:hover {
    text-decoration: underline;
}

/* メッセージ */
.error-message {
    background: rgba(239, 68, 68, 0.08);
    padding: 16px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid rgba(239, 68, 68, 0.1);
    color: var(--red-500);
    font-weight: 700;
    font-size: 0.9rem;
}

.success-message {
    background: rgba(16, 185, 129, 0.08);
    padding: 16px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid rgba(16, 185, 129, 0.1);
    color: var(--emerald-600);
    font-weight: 700;
    font-size: 0.9rem;
}

/* ========== ダッシュボード ========== */
.page-title {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 900;
    color: white;
    letter-spacing: -0.03em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.nav-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.glass-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--gray-100);
    margin-bottom: 12px;
    position: relative;
    z-index: 2;
}

.glass-card h3 {
    color: var(--blue-600);
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.glass-card p {
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========== テーマグリッド ========== */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.theme-card {
    background: white;
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.theme-card:hover {
    transform: translateY(-3px);
    border-color: var(--blue-500);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.theme-card h3 {
    color: var(--gray-900);
    font-size: 0.85rem;
    margin: 0;
}

.theme-card p {
    color: var(--gray-500);
    font-size: 0.7rem;
    margin-top: 4px;
}

.theme-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.9rem;
    color: white;
    margin: 0 auto 8px;
}

/* ========== アプリグリッド ========== */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 40px;
}

/* ========== ローディング ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(40px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-100);
    border-top: 4px solid var(--emerald-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== フッター ========== */
.top-footer {
    padding: 48px 0;
    text-align: center;
}

.footer-text {
    font-size: 0.7rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

.footer-text a {
    color: inherit;
    text-decoration: none;
}

.footer-text a:hover {
    color: rgba(255, 255, 255, 0.6);
}

.copyright-text {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.3em;
    margin-top: 32px;
}

/* ========== レスポンシブ ========== */
@media (max-width: 768px) {
    .container {
        padding: 0 16px 32px;
    }

    .login-cards {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .login-card {
        padding: 24px 20px;
        border-radius: 24px;
        min-height: auto;
    }

    .form-container {
        padding: 24px 20px;
        border-radius: 24px;
        margin: 0 8px;
    }

    .form-group input,
    .form-group select {
        height: 48px;
        border-radius: 12px;
    }

    .btn {
        height: 48px;
        border-radius: 14px;
        font-size: 0.95rem;
    }

    .class-code-input {
        height: 50px;
        font-size: 1.3rem;
        border-radius: 14px;
    }

    .theme-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .theme-card {
        padding: 12px 8px;
        border-radius: 12px;
    }

    .theme-icon {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .theme-card h3 {
        font-size: 0.75rem;
    }

    .app-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .sub-header {
        padding: 8px 16px;
    }

    .logo-text {
        font-size: 1.1rem;
    }

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

    .glass-card {
        padding: 16px;
        border-radius: 16px;
    }
}

@media (max-width: 480px) {
    .top-header {
        padding: 32px 0 20px;
    }

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

    .card-content h2 {
        font-size: 1.3rem;
    }

    .theme-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .theme-card {
        padding: 10px 6px;
    }

    .page-title {
        font-size: 1.2rem;
    }
}

/* ========== ユーティリティ ========== */
.class-code-input-wrapper {
    padding: 0 16px;
    margin-bottom: 8px;
}

.teacher-login-placeholder {
    display: none;
}
