/* ===================================================
   home/css/base.css  ―  グローバルベーススタイル
   全ページで読み込まれる共通スタイル。
   ページ固有の上書きは各ページのCSSで行う。
   =================================================== */


/* ===================================================
   デザイントークン（CSS変数）
   全ページのCSSから var(--xxx) で参照できる
   =================================================== */
:root {
    /* ブランドカラー */
    --clr-primary:        #5d8a75;
    --clr-primary-light:  #aed4c3;
    --clr-primary-pale:   #eaf5f0;
    --clr-primary-dark:   #3f6652;

    /* テキスト */
    --clr-text:           #303030;
    --clr-text-muted:     #6b7280;
    --clr-text-light:     #9ca3af;

    /* ボーダー・背景 */
    --clr-border:         #d1d5db;
    --clr-bg:             #f7f9f8;
    --clr-bg-card:        #ffffff;
    --clr-bg-error:       #ffe7e7;
    --clr-bg-warning:     #fff1da;

    /* セマンティックカラー */
    --clr-danger:         #c0392b;
    --clr-danger-pale:    #fff0ef;
    --clr-success:        #27ae60;
    --clr-warning:        #f39c12;
    --clr-info:           #2980b9;

    /* ボタンデフォルト */
    --clr-btn:            #5d8a75;
    --clr-btn-hover:      #aed4c3;

    /* ボーダー半径 */
    --radius-sm:          4px;
    --radius-md:          8px;
    --radius-lg:          16px;
    --radius-full:        9999px;

    /* シャドウ */
    --shadow-xs:          0 1px 2px rgba(0,0,0,0.06);
    --shadow-sm:          0 1px 4px rgba(0,0,0,0.09);
    --shadow-md:          0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:          0 8px 24px rgba(0,0,0,0.12);

    /* トランジション */
    --transition:         0.18s ease;
}


/* ===================================================
   リセット・ベース
   =================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-flow: column;
    background-color: var(--clr-bg);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    position: relative;
    color: var(--clr-text);
    font-size: 16px;
}

h1 {
    text-align: center;
    padding: 6px 60px;
    border: solid var(--clr-primary);
    border-width: 3px 0;
}
h2, h3 {
    text-align: center;
    padding: 6px 60px;
    border: solid var(--clr-primary-light);
    border-width: 3px 0;
}
h2.red, h3.red {
    border-color: #c8a0a0;
}

p, span {
    color: var(--clr-text);
    margin: 6px;
}

a {
    color: var(--clr-text);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    text-decoration: underline;
}

.highlight {
    font-size: 24px;
    font-weight: bold;
    margin: 0 6px;
}

.hrLine {
    width: 60%;
    border: solid 1px var(--clr-border);
    border-width: 1px 0 0;
    margin: 30px 0;
}


/* ===================================================
   フォーム要素（デフォルト）
   ページ固有CSSでクラスセレクタを使えば上書き可能
   =================================================== */
input, button, textarea, select {
    border: var(--clr-border) solid 1px;
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    font-size: 16px;
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:placeholder-shown {
    background-color: #efefef;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(93, 138, 117, 0.15);
}

button {
    width: 100%;
    max-width: 600px;
    padding: 9px 30px;
    cursor: pointer;
    margin: 9px 0;
    background-color: var(--clr-btn);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 16px;
    transition: background-color var(--transition), box-shadow var(--transition);
}
button:hover {
    background-color: var(--clr-btn-hover);
}
button.red {
    background-color: var(--clr-danger);
}
button.red:hover {
    background-color: #e74c3c;
}
form button {
    height: 100%;
}
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #a6c4e3;
}

/* フォーム共通レイアウトのみ定義（サイズ・スタイルは .pageForm に委ねる） */
form {
    display: flex;
    flex-flow: column;
    align-items: center;
    width: 100%;
}
form label {
    width: 100%;
    color: var(--clr-text-muted);
}
form .helptext {
    color: var(--clr-text-muted);
    font-size: 0.85rem;
}
form input[type=checkbox] {
    width: 30px;
    height: 30px;
    box-shadow: none;
}

/* 必須項目マーク */
label:has(+ input:required)::after,
label:has(+ textarea:required)::after,
label:has(+ select:required)::after {
    content: " *";
    color: var(--clr-danger);
    margin-left: 4px;
    font-weight: bold;
}

/* ===================================================
   .pageForm — 標準的なログイン・登録・編集フォーム用
   <form class="pageForm"> に付与して使う
   =================================================== */
.pageForm {
    width: 600px;
}
.pageForm div {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-flow: column;
    align-items: flex-start;
    margin: 6px 0;
    position: relative;
}
.pageForm input:not([type=checkbox]),
.pageForm select,
.pageForm textarea {
    width: 100%;
}


/* ===================================================
   レイアウト
   =================================================== */
.con {
    padding: 6px 120px;
    width: 100%;
    display: flex;
    flex-flow: column;
    align-items: center;
    margin-bottom: 60px;
}
.con ul {
    margin: 6px;
    padding: 0;
}

/* メインコンテンツカード */
.bord, .tools {
    margin: 15px 0;
    width: 100%;
    max-width: 900px;
    padding: 30px;
    padding-top: 6px;
    background-color: #ececec;
    border-radius: var(--radius-sm);
}
.bord .messagelist {
    background-color: var(--clr-bg);
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}
.tools .toolButtons {
    display: flex;
    width: 100%;
}
.tools .toolButtons div {
    border: solid 1px gray;
    border-radius: var(--radius-sm);
    margin: 6px;
    font-size: 18px;
    cursor: pointer;
    background: rgb(212,233,230);
    background: linear-gradient(0deg, rgba(212,233,230,1) 0%, rgba(179,214,208,1) 100%);
}
.tools .toolButtons div:hover {
    opacity: 0.6;
}
.tools a {
    display: flex;
    padding: 15px;
    width: 100%;
    text-decoration: none;
}


/* ===================================================
   ヘッダー
   =================================================== */
.header {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0 20px;
    height: 54px;
    align-items: center;
    gap: 2px;
    /* 左端にブランド、右側にナビを自然に寄せる */
    justify-content: flex-start;
    /* グラデーション＋下影で立体感 */
    background: linear-gradient(135deg, var(--clr-primary-dark) 0%, var(--clr-primary) 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* 全 li 共通 — 固定幅をやめてコンテンツサイズに */
.header li {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    height: 38px;
    padding: 0 2px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition);
    width: auto;
}

/* ブランド（TOP）を左端に固定し、残りを右寄せ */
.header > li:first-child {
    margin-right: auto;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.08em;
    padding: 0 6px 0 2px;
}

/* ホバー：フルハイト塗りつぶし → 半透明ピル */
.header > li:hover {
    background-color: rgba(255, 255, 255, 0.14);
}

.header li a {
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 100%;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.header li a:hover {
    text-decoration: none;
}

/* ログアウトボタン */
.logoutbutton button {
    background: none;
    color: white;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: none;
    width: auto;
    max-width: initial;
    margin: 0;
    padding: 0 14px;
    height: 38px;
    letter-spacing: 0.02em;
}

/* ドロップダウン */
.header .dropdown {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
}
.dropdown p {
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0 14px;
    margin: 0;
    white-space: nowrap;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.header .dropdown-toggle {
    cursor: pointer;
}
.header .dropdown:hover .dropdown-toggle i {
    transform: rotate(180deg);
}

/* ドロップダウンメニュー — カード型 */
.header .dropdown-menu {
    display: none;
    flex-flow: column;
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background-color: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    z-index: 1000;
    min-width: 200px;
    list-style: none;
    padding: 6px;
    margin: 0;
    opacity: 0;
}
/* ブリッジ：メニューとトリガーの隙間をホバー領域でつなぐ */
.header .dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}
.header .dropdown-menu li {
    width: 100%;
    border-bottom: none;
    border-radius: var(--radius-sm);
    height: auto;
    padding: 0;
}
.header .dropdown-menu a {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--clr-text);
    border-radius: var(--radius-sm);
    letter-spacing: 0;
    height: auto;
    transition: background-color var(--transition), color var(--transition);
}
.header .dropdown-menu a:hover {
    background-color: var(--clr-primary-pale);
    color: var(--clr-primary-dark);
    text-decoration: none;
}
.header .dropdown:hover .dropdown-menu {
    display: flex;
    animation: dropdown-fadein 0.2s ease forwards;
}
@keyframes dropdown-fadein {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}


/* ===================================================
   メッセージ（Django messages framework）
   =================================================== */
.messages {
    margin: 10px 0;
}
.messages button {
    box-shadow: none;
}
.alert {
    padding: 12px 24px;
    margin: 8px 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.alert-error {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}
.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}
.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}
.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}
.messages #close-top-message {
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    width: inherit;
    max-width: initial;
    padding: 0;
    margin: 0;
    box-shadow: none;
}
#close-top-message:hover {
    opacity: 1;
}

p.red, .errorlist li {
    color: var(--clr-danger);
    font-weight: bold;
}


/* ===================================================
   AI ボタン（グラデーション）
   =================================================== */
.ai-button {
    background-image: linear-gradient(90deg, #d55a6f, #616acf, #874fb8, #d55a6f);
    background-size: 200% 200%;
    background-repeat: repeat;
    border: none;
    color: white;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 15px 0;
    cursor: pointer;
    border-radius: var(--radius-lg);
    box-shadow: 0 0 9px rgb(133, 85, 143);
}
.ai-button.generating {
    animation: rainbow 1s linear infinite;
}
@keyframes rainbow {
    0%   { background-position: 0% 100%; }
    100% { background-position: 200% 100%; }
}


/* ===================================================
   ローディング
   =================================================== */
#loading {
    display: flex;
    flex-flow: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background-color: rgba(0, 0, 0, 0.5);
}
#loading .spinner-border {
    display: flex;
    gap: 18px;
    flex-flow: column;
    align-items: center;
    justify-content: center;
}
#loading p, #loading i {
    color: white;
}
#loading i {
    font-size: 75px;
}


/* ===================================================
   お知らせウィンドウ
   =================================================== */
.infoWindow {
    background-color: var(--clr-primary-pale);
    width: 100%;
    padding: 15px;
    border: solid 0.5px var(--clr-success);
    border-radius: var(--radius-lg);
    display: flex;
    flex-flow: column;
    align-items: center;
    margin: 30px 0;
}
.infoWindow hr {
    width: 60%;
}
.infoWindow ul {
    padding: 25px;
}


/* ===================================================
   ページネーション
   =================================================== */
.pagination {
    width: 100%;
    display: flex;
    list-style: none;
    flex-wrap: wrap;
    padding: 0;
    margin: 0;
}
.pagination .page-item {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 45px;
    height: 45px;
    background-color: white;
    border: solid 1px var(--clr-primary-light);
    border-collapse: collapse;
}
.pagination .page-item.active {
    background-color: gray;
}
.pagination .page-item a {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    color: var(--clr-btn);
}
.pagination li:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.pagination li:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}


/* ===================================================
   フッター
   =================================================== */
.footer {
    width: 100%;
    padding: 6px;
    font-size: 12px;
    display: flex;
    position: absolute;
    background-color: gray;
    bottom: 0;
}
.footer p {
    margin: 0;
    color: var(--clr-text);
}


/* ===================================================
   レスポンシブ
   =================================================== */
@media screen and (max-width: 600px) {
    .con {
        padding: 6px 15px;
    }
    .header {
        height: 48px;
        padding: 0 12px;
        gap: 0;
    }
    .header li a,
    .logoutbutton button,
    .dropdown p {
        padding: 0 8px;
        font-size: 0.78rem;
    }
    .header > li:first-child {
        font-size: 0.875rem;
    }
}
