/* CBT Mental Health App Styles */

:root {
    --primary-color: #6B9BD5;
    --secondary-color: #7ECFBD;
    --warning-color: #FFB84D;
    --danger-color: #E57373;
    --bg-color: #F8F9FB;
    --text-color: #2C3E50;
    --border-color: #E5E8ED;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --soft-blue: #EBF5FA;
    --soft-green: #EDF7F0;
    --accent-purple: #A594F9;
    --accent-pink: #F3C4D3;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

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

/* ヘッダー */
header {
    background-color: white;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 12px;
    list-style: none;
    align-items: center;
}

.nav-links li {
    white-space: nowrap;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.3s;
    font-size: 14px;
    white-space: nowrap;
    display: inline-block;
}

.nav-links a:hover,
.nav-links a.active {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

/* カード */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card-header {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* stats-grid内のカード用の特別なスタイル */
.stats-grid .card {
    min-height: 220px;
    padding: 28px;
    border: 1px solid var(--border-color);
}

.stats-grid .card:hover {
    border-color: var(--primary-color);
}

.stats-grid .card p {
    flex-grow: 1;
    margin-bottom: 20px;
    line-height: 1.7;
    color: #555;
    font-size: 15px;
}

.stats-grid .card .btn {
    margin-top: auto;
    display: inline-block;
    align-self: flex-start;
    width: 100%;
    text-align: center;
}

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.3s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.1);
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

input[type="range"] {
    width: 100%;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

/* ボタン */
.btn {
    padding: 13px 28px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    text-decoration: none;
    display: inline-block;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5A8FCC 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5A8FCC 0%, var(--primary-color) 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #6DBFAF 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #6DBFAF 0%, var(--secondary-color) 100%);
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-outline {
    background-color: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* エントリーリスト */
.entry-list {
    display: grid;
    gap: 16px;
}

.entry-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s;
}

.entry-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

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

.entry-date {
    font-size: 12px;
    color: #666;
}

.entry-content {
    margin-top: 8px;
}

.entry-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

/* AI フィードバック */
.ai-feedback {
    background: #f0f8ff;
    border-left: 4px solid var(--primary-color);
    padding: 16px;
    margin-top: 16px;
    border-radius: 4px;
}

.ai-feedback-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

/* ダッシュボード */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

/* レスポンシブ対応：画面サイズに応じて最適なカラム数を設定 */
@media (min-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 899px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

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

.stat-value {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

/* チャート */
.chart-container {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* 空の状態 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* アラート */
.alert {
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .nav-links {
        flex-direction: column;
        gap: 10px;
    }

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

    .btn-group {
        flex-direction: column;
    }
}

/* 励ましメッセージ */
.encouragement-box {
    background: linear-gradient(135deg, var(--soft-blue) 0%, var(--soft-green) 100%);
    border-left: 5px solid var(--primary-color);
    padding: 24px 28px;
    border-radius: 12px;
    margin-bottom: 28px;
    font-size: 16px;
    line-height: 1.9;
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(107, 155, 213, 0.1);
}

.encouragement-box strong {
    color: var(--primary-color);
    font-size: 17px;
}

/* 簡略化されたフォーム */
.simple-form {
    max-width: 600px;
    margin: 0 auto;
}

.simple-form .form-group {
    margin-bottom: 32px;
}

.simple-form label {
    font-size: 18px;
    margin-bottom: 12px;
    display: block;
}

.simple-form .form-hint {
    font-size: 14px;
    color: #777;
    margin-top: 8px;
    font-style: italic;
}

/* ログアウトリンク */
.logout-link {
    color: var(--danger-color) !important;
}

/* 大きなアクションボタン */
.btn-large {
    padding: 18px 32px;
    font-size: 18px;
    border-radius: 12px;
}

/* 優しいアラート */
.alert {
    border-radius: 8px;
    font-size: 15px;
}

.alert-success {
    background: var(--soft-green);
    border-left: 4px solid var(--secondary-color);
}

.alert-info {
    background: var(--soft-blue);
    border-left: 4px solid var(--primary-color);
}

/* ユーティリティ */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: #666; }
.hidden { display: none; }

/* ========================================
   レスポンシブデザイン（モバイル対応）
   ======================================== */

/* ハンバーガーメニューボタン（デフォルトは非表示） */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.mobile-menu-toggle span {
    width: 30px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 10px;
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

/* タブレット・モバイル（768px以下） */
@media (max-width: 768px) {
    /* ハンバーガーメニューボタンを表示 */
    .mobile-menu-toggle {
        display: flex;
    }

    /* ナビゲーション */
    nav {
        flex-wrap: wrap;
        padding: 15px;
    }

    .nav-links {
        position: fixed;
        right: -100%;
        top: 60px;
        flex-direction: column;
        background-color: white;
        width: 70%;
        max-width: 300px;
        height: calc(100vh - 60px);
        padding: 20px;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease-in-out;
        gap: 0;
        overflow-y: auto;
        z-index: 9;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li {
        width: 100%;
        margin-bottom: 8px;
    }

    .nav-links a {
        display: block;
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
    }

    /* コンテナ */
    .container {
        padding: 15px;
    }

    /* カード */
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    .card-header {
        font-size: 18px;
    }

    /* フォーム */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* iOSのズーム防止 */
        padding: 12px;
    }

    /* ボタン */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
        min-height: 44px; /* タッチターゲット */
    }

    .btn-large {
        padding: 14px 24px;
    }

    /* ボタングループ */
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* 統計グリッド */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* モーダル */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    /* テーブル */
    table {
        font-size: 14px;
    }

    th, td {
        padding: 8px;
    }

    /* チャートコンテナ */
    #mood-chart-container,
    #emotion-chart-container,
    #category-chart-container {
        height: 250px;
    }

    /* ロゴ */
    .logo {
        font-size: 20px;
    }

    /* 励ましボックス */
    .encouragement-box {
        font-size: 14px;
        padding: 12px;
    }
}

/* 小型スマートフォン（480px以下） */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .card {
        padding: 12px;
    }

    .card-header {
        font-size: 16px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    .btn {
        font-size: 14px;
    }

    .modal-content {
        width: 98%;
        margin: 5% auto;
        padding: 15px;
    }

    /* テーブルを横スクロール可能に */
    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 500px;
    }
}
