/*
  nene - Final Unified Stylesheet
  Concept: Minimal, Clean, Monotone with enhanced user interaction.
*/

/* === Base & Variables === */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400&family=Noto+Serif+JP:wght@400&display=swap');

:root {
    /* Colors */
    --bg-main: #f9f9f9;
    --bg-card: #ffffff;
    --bg-input: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #888888;
    --text-on-accent: #ffffff;
    --accent-color: #333333;
    --accent-color-hover: #555555;
    --accent-color-active: #222222; /* For click state */
    --border-color: #e0e0e0;

    /* Typography */
    --font-body: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-heading: 'Noto Serif JP', serif;

    /* Shadows & Radius */
    --shadow-color: rgba(0, 0, 0, 0.05);
    --radius-large: 24px;
    --radius-medium: 8px;

    /* Compatibility with old chat variables */
    --bg-primary: var(--bg-card);
    --bg-secondary: var(--bg-main);
    --bg-tertiary: var(--bg-main);
    --border-primary: var(--border-color);
    --border-secondary: #ccc;
    --button-disabled-bg: #a9a9a9;
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --bg-my-message: #f0f0f0;
    --bg-accent: #e0e0e0;
    --error-bg: #f8d7da;
    --error-border: #f5c6cb;
    --error-text: #721c24;
    --success-bg: #f5f5f5;
    --success-text: #333333;
    --success-border: #e0e0e0;
}

/* === Base Styles === */
html {
    height: 100%;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-weight: 300;
    letter-spacing: 0.05em;
    margin: 0;
    font-size: 14px;
    line-height: 1.8;
}

h1 {
    font-family: var(--font-heading);
    text-align: center;
    font-size: 2em;
    font-weight: 400;
    letter-spacing: 0.08em;
    margin: 0 0 40px 0;
}

/* === Common Components === */

/* --- Main Containers (Card Design) --- */
.auth-container,
.profile-container {
    width: 100%;
    margin: 40px auto;
    background-color: var(--bg-card);
    border-radius: var(--radius-large);
    box-shadow: 0 10px 40px var(--shadow-color);
    padding: 50px;
    box-sizing: border-box;
}
.auth-container { max-width: 420px; }
.profile-container { max-width: 500px; }


/* --- Forms --- */
.form-group {
    margin-bottom: 24px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.9em;
}

/* --- Unified Inputs --- */
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-medium);
    padding: 16px;
    box-sizing: border-box;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1em;
    color: var(--text-primary);
    transition: border-color 0.3s ease;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus {
    outline: none;
    border-bottom-color: var(--text-primary);
}
textarea {
    min-height: 120px;
    resize: vertical;
}

/* --- Unified Buttons with Full Interaction --- */
.auth-button,
.profile-form .form-actions button {
    width: 100%;
    background-color: var(--accent-color);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-medium);
    padding: 16px 24px;
    font-size: 1em;
    font-family: var(--font-body);
    font-weight: 400;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, background-color 0.2s ease-out;
}
.auth-button:hover,
.profile-form .form-actions button:hover {
    background-color: var(--accent-color-hover);
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.12);
}
.auth-button:active,
.profile-form .form-actions button:active {
    background-color: var(--accent-color-active);
    transform: scale(0.98) translateY(0); /* 縮小 + 浮き上がりリセット */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition-duration: 0.1s;
}

/* --- Unified Switch Links --- */
.switch-link {
    text-align: center;
    margin-top: 30px;
}
.switch-link a {
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2px;
    font-weight: 300;
    font-size: 0.9em;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.switch-link a:hover {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

/* --- Other Shared Components --- */
.success-message {
    background-color: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
    border-radius: var(--radius-medium);
    padding: 15px 20px;
    margin-bottom: 30px;
    text-align: center;
    font-size: 0.95em;
}
.error-message {
    color: var(--error-text);
    background-color: var(--error-bg);
    border: 1px solid var(--error-border);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}

/* === Chat Styles (Retained for compatibility) === */
body:not(.chat-page) { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; box-sizing: border-box; }
body.profile-page, body.auth-page { align-items: flex-start; }
body.chat-page { height: 100vh; overflow: hidden; }
body.chat-page .app-container { display: grid; grid-template-columns: 260px 1fr; width: 100%; height: 100%; background-color: var(--bg-primary); }
.sidebar { background-color: var(--bg-secondary); border-right: 1px solid var(--border-primary); display: flex; flex-direction: column; height: 100%; }
.sidebar-header { padding: 15px; border-bottom: 1px solid var(--border-primary); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.chat-list { list-style: none; padding: 0; margin: 0; flex-grow: 1; overflow-y: auto; }
.chat-list li { padding: 15px; border-bottom: 1px solid var(--border-primary); cursor: pointer; transition: background-color 0.2s; }
.chat-list li:hover { background-color: var(--bg-primary); }
.chat-list li.active { background-color: var(--bg-accent); }
.chat-area { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.chat-header { display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--border-primary); flex-shrink: 0; height: 60px; }
.chat-info h1 { font-size: 16px; margin: 0; font-weight: bold; text-align: left; }
.user-menu { display: flex; align-items: center; gap: 15px; }
.user-menu .settings-btn { margin-left: auto; }
.messages-area { flex-grow: 1; overflow-y: auto; padding: 20px; }
.message-item { display: flex; margin-bottom: 20px; max-width: 80%; align-items: flex-start; }
.message-text { background-color: var(--bg-secondary); padding: 10px 15px; border-radius: 8px; white-space: pre-wrap; word-wrap: break-word; }
.my-message { margin-left: auto; }
.my-message .message-text { background-color: var(--bg-my-message); }
.chat-footer { padding: 15px 20px; border-top: 1px solid var(--border-primary); background-color: var(--bg-secondary); flex-shrink: 0; }
.message-form {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.message-form textarea {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-secondary);
    border-radius: 20px;
    resize: none;
    background-color: var(--bg-primary);
    min-height: 40px;
}

.message-form button {
    padding: 10px 30px;
    border: none;
    background-color: var(--accent-color);
    color: var(--text-on-accent);
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    writing-mode: horizontal-tb;
}

.message-form button:disabled {
    background-color: var(--button-disabled-bg);
    cursor: not-allowed;
}

/* === Responsive === */
@media (max-width: 600px) {
    .auth-container,
    .profile-container {
        margin: 0;
        padding: 40px 24px;
        border-radius: 0;
        box-shadow: none;
        min-height: 100vh;
    }
    body.chat-page .app-container { grid-template-columns: 1fr; }
    .sidebar { position: fixed; z-index: 1010; transform: translateX(-100%); transition: transform 0.3s ease-in-out; }
    body.sidebar-open .sidebar { transform: translateX(0); }
}


/* === Registration Page Specific Styles === */

/* ページ全体に明るいグラデーション背景を適用 */
body.register-page {
    background: linear-gradient(135deg, #e0f7fa 0%, #e8f5e9 100%);
    /* background: linear-gradient(135deg, #c8e6c9 0%, #b3e5fc 100%); */
}

/* フォームのコンテナ */
.register-container {
    max-width: 420px;
    margin: 40px auto;
    padding: 50px;
    background-color: #ffffff;
    border-radius: 24px; /* 角を丸く */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.register-container h1 {
    font-family: 'Noto Serif JP', serif;
    font-weight: 500;
    color: #333;
    margin-bottom: 35px;
}

/* 入力フィールド */
.register-input {
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #4CAF50; /* 明るい緑のボーダー */
    border-radius: 8px;
    padding: 16px;
    box-sizing: border-box;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 1em;
    color: #333;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.register-input::placeholder {
    color: #aaa;
}

/* 入力フィールドのフォーカス時 */
.register-input:focus {
    outline: none;
    border-color: #2196F3; /* 明るい青 */
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
}

/* 登録ボタン */
.register-button {
    width: 100%;
    background-color: #4CAF50; /* 明るい緑 */
    color: white;
    border: none;
    border-radius: 8px;
    padding: 16px 24px;
    font-size: 1.1em;
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
    transform: translateY(0);
    transition: all 0.2s ease-out;
}

.register-button:hover {
    background-color: #45a049; /* 少し濃い緑 */
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(76, 175, 80, 0.25);
}

.register-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* ログインへのリンク */
.register-link {
    text-align: center;
    margin-top: 30px;
}

.register-link a {
    color: #007bff; /* 目立つ青色 */
    text-decoration: none;
    font-size: 1.05em; /* 少し大きく */
    font-weight: 400;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

.register-link a:hover {
    color: #0056b3;
    text-decoration: underline; /* ホバーで下線 */
}
