/* ========== 基本スタイル ========== */
body {
    font-family: 'Poppins', 'Noto Sans JP', sans-serif;
    background: linear-gradient(120deg, #89f7fe 0%, #66a6ff 100%);
    color: #333;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 2rem 1rem;
    box-sizing: border-box;
    background-attachment: fixed;
}

.container {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2rem 2.5rem;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    width: 100%;
    max-width: 1024px;
    transition: all 0.3s ease;
}

h1 { 
    text-align: center; 
    color: #1c1e21; 
    margin-top: 0; 
    margin-bottom: 1.5rem;
    font-weight: 700;
    font-size: 2rem;
}

h2 { 
    color: #2c3e50; 
    border-bottom: 2px solid #66a6ff; 
    padding-bottom: 12px; 
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    font-weight: 600; 
    font-size: 1.5rem;
}

h3 {
    color: #34495e;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

p { line-height: 1.7; }
hr { border: none; border-top: 1px solid rgba(0, 0, 0, 0.1); margin: 2.5rem 0; }

/* ▼▼▼ このセレクタに select を追加し、appearance と background関連のプロパティを追加しました ▼▼▼ */
input[type="email"], input[type="password"], input[type="text"], input[type="time"], input[type="number"], textarea, select {
    width: 100%;
    padding: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}
input:not(:last-child), textarea:not(:last-child) { margin-bottom: 1rem; }
input:disabled, textarea:disabled { background-color: #e9ecef !important; cursor: not-allowed; }
input[type="email"]:focus, input[type="password"]:focus, input[type="text"]:focus, input[type="time"]:focus, textarea:focus {
    outline: none;
    border-color: #66a6ff;
    box-shadow: 0 0 0 3px rgba(102, 166, 255, 0.25);
}
textarea { resize: vertical; }

.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.75rem; font-weight: 500; color: #4b4f56; font-size: 0.95em; }
.form-group small { font-size: 0.85rem; color: #555; display: block; margin-top: 8px; }

.user-info { display: flex; justify-content: space-between; align-items: center; padding: 10px; background-color: rgba(255,255,255,0.5); border-radius: 8px; margin-bottom: 2rem; }
.user-info p { margin: 0; font-weight: 500; }

.button-group { display: flex; justify-content: flex-end; margin-top: 2rem; }

button { padding: 14px 24px; border: none; border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer; transition: all 0.3s ease; letter-spacing: 0.5px; }
button:disabled { background-color: #ccc !important; cursor: not-allowed; transform: none !important; box-shadow: none !important; background-image: none !important; }

.save-btn, #login-btn, #register-btn, .secondary-btn {
    width: 100%;
}

.save-btn, #login-btn, #register-btn { background-image: linear-gradient(to right, #64b5f6, #42a5f5, #2196f3); background-size: 200% auto; color: white; box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.4); }
.save-btn:hover:not(:disabled), #login-btn:hover:not(:disabled), #register-btn:hover:not(:disabled) { background-position: right center; transform: translateY(-2px); box-shadow: 0 6px 20px 0 rgba(65, 132, 234, 0.5); }

#logout-btn { background-color: #6c757d; color: white; padding: 10px 18px; font-size: 0.9rem; width: auto; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
#logout-btn:hover { background-color: #5a6268; transform: translateY(-1px); }

.login-actions { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-top: 1rem; }
.switch-form-link { text-align: center; margin-top: 1.5rem; }
.switch-form-link a, #forgot-password-link { font-size: 0.9em; color: #555; text-decoration: none; transition: color 0.2s; cursor: pointer; }
.switch-form-link a:hover, #forgot-password-link:hover { color: #0056b3; text-decoration: underline; }

#status-message { margin-top: 1.5rem; text-align: center; font-weight: 500; min-height: 1.2em; transition: color 0.3s ease; color: #2c3e50; white-space: pre-wrap; }

/* ========== ダッシュボードレイアウト ========== */
#dashboard-container { display: flex; margin-top: 1rem; gap: 2rem; }
#dashboard-nav { flex: 0 0 180px; }
#dashboard-nav ul { list-style: none; padding: 0; margin: 0; position: sticky; top: 2rem; }
#dashboard-nav li a { display: block; padding: 12px 15px; text-decoration: none; color: #4b4f56; border-radius: 8px; font-weight: 500; transition: background-color 0.2s, color 0.2s; margin-bottom: 5px; }
#dashboard-nav li a:hover { background-color: rgba(102, 166, 255, 0.1); }
#dashboard-nav li a.active { background-color: #66a6ff; color: white; box-shadow: 0 2px 8px rgba(102, 166, 255, 0.4); }
#dashboard-content { flex-grow: 1; min-width: 0; }
.dashboard-panel h2:first-child { margin-top: 0; }

/* ========== トグルスイッチ ========== */
.toggle-container { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 10px; background-color: rgba(255,255,255,0.5); border-radius: 8px; }
.toggle-label { font-weight: 500; color: #4b4f56; margin-bottom: 0; }
.toggle-switch { position: relative; display: inline-block; width: 52px; height: 28px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 28px; transition: background-color 0.3s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; border-radius: 50%; transition: transform 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: #42a5f5; }
input:checked + .slider:before { transform: translateX(24px); }

/* ========== 動的リスト共通スタイル ========== */
.secondary-btn { background-color: #6c757d; color: white; }
.secondary-btn:hover:not(:disabled) { background-color: #5a6268; transform: translateY(-1px); }
.delete-btn { background-color: #e74c3c; color: white; padding: 12px 16px; font-size: 0.9rem; width: auto; font-weight: 500; box-shadow: 0 2px 8px rgba(0,0,0,0.1); flex-shrink: 0; }
.delete-btn:hover:not(:disabled) { background-color: #c0392b; transform: translateY(-1px); }

/* ========== ニックネーム設定UI ========== */
#nicknames-list-container, #admins-list-container, #schedule-items-container { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; }
.nickname-entry, .admin-entry, .schedule-item-entry { display: flex; align-items: center; gap: 10px; }
.nickname-entry input, .admin-entry input, .schedule-item-entry input { margin-bottom: 0 !important; padding: 12px; }
.nickname-entry .nickname-id { flex: 2; }
.nickname-entry .nickname-name { flex: 1; }

/* ========== 管理者設定UI ========== */
#invite-code-generator-section { padding: 15px; background-color: rgba(102, 166, 255, 0.1); border-radius: 8px; border: 1px solid rgba(102, 166, 255, 0.2); }
#invite-code-display { margin-top: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#invite-code-display p { width: 100%; margin: 0 0 5px 0; font-size: 0.9em; }
#new-invite-code { flex-grow: 1; font-weight: bold; font-size: 1.2em; text-align: center; letter-spacing: 2px; background-color: #fff; cursor: text; }
#copy-invite-code-btn { width: auto; font-size: 0.9em; padding: 12px; background-color: #28a745; color:white; }
#copy-invite-code-btn:hover { background-color: #218838; }
.admin-entry { padding: 5px; border-radius: 6px; cursor: grab; transition: background-color 0.2s; }
.admin-entry.dragging { opacity: 0.5; background-color: #cde7ff; }
.admin-entry.super-admin { border-left: 4px solid #ffc107; background-color: #fffbeb; }
.admin-entry .admin-name { flex: 1; }
.admin-entry .admin-email { flex: 2; }
.super-admin-label { font-size: 1.2rem; margin-left: 5px; margin-right: -5px; user-select: none; }

/* ========== スケジュールエディターUI ========== */
.schedule-item-entry .item-type { flex: 1.5; }
.schedule-item-entry .item-task { flex: 3; }
.schedule-item-entry .item-due { flex: 1.5; }
#add-schedule-item-btn { margin-bottom: 1rem; }
#save-schedule-items-btn { background-image: linear-gradient(to right, #ffc107, #ffb300, #ffa000); box-shadow: 0 4px 15px 0 rgba(255, 193, 7, 0.4); }
#save-schedule-items-btn:hover:not(:disabled) { background-position: right center; transform: translateY(-2px); box-shadow: 0 6px 20px 0 rgba(255, 193, 7, 0.5); }


/* ========== レスポンシブ対応 ========== */
@media (max-width: 768px) {
    .container { padding: 1.5rem 1rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    #dashboard-container { flex-direction: column; gap: 1rem; }
    #dashboard-nav { flex-basis: auto; width: 100%; }
    #dashboard-nav ul { display: flex; justify-content: flex-start; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 10px; gap: 5px; }
    #dashboard-nav li { flex-shrink: 0; }
    #dashboard-nav li a { padding: 8px 12px; font-size: 0.9rem; }
    .admin-entry, .nickname-entry, .schedule-item-entry { flex-direction: column; align-items: stretch; padding: 15px; border: 1px solid #ddd; border-radius: 8px; }
    .admin-entry.super-admin { border-left: none; border-top: 4px solid #ffc107; }
    .super-admin-label { text-align: right; margin: -10px 0 5px 0; }
}

/* ▼▼▼ ロード画面のスタイルを追加 ▼▼▼ */
.loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}
.spinner {
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid #fff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
.loader-text {
    color: #fff;
    font-weight: 500;
    font-size: 1.1rem;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== とーか設定パネルの保存ボタン用スタイル ========== */
#save-toka-btn {
    margin-top: 2rem;
    background-image: linear-gradient(to right, #64b5f6, #42a5f5, #2196f3);
    background-size: 200% auto;
    color: white;
    box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.4);
    transition: all 0.3s ease;
}

#save-toka-btn:hover:not(:disabled) {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(65, 132, 234, 0.5);
}

/* パネル内の保存ボタングループのスタイル調整 */
.dashboard-panel .button-group {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 2rem;
    margin-top: 2.5rem;
}

/* 保存ボタンのローディング状態 */
.save-btn:disabled {
    background-image: none;
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ボタングループ内の余白調整 */
.button-group:not(:last-child) {
    margin-bottom: 2rem;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .dashboard-panel .button-group {
        padding-top: 1.5rem;
        margin-top: 2rem;
    }
    
    #save-toka-btn {
        width: 100%;
        margin-top: 1.5rem;
    }
}

/* スケジュール設定パネルの保存ボタン用スタイル */
#save-schedule-settings-btn {
    margin-top: 1.5rem;
    background-image: linear-gradient(to right, #64b5f6, #42a5f5, #2196f3);
    background-size: 200% auto;
    color: white;
    box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.4);
    transition: all 0.3s ease;
}

#save-schedule-settings-btn:hover:not(:disabled) {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(65, 132, 234, 0.5);
}

/* 入力フィールドグループのスタイル */
#panel-schedule .form-group {
    margin-bottom: 1.5rem;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    #save-schedule-settings-btn {
        width: 100%;
    }
}

/* 管理者設定パネルの保存ボタン用スタイル */
#save-admins-btn {
    margin-top: 2rem;
    background-image: linear-gradient(to right, #64b5f6, #42a5f5, #2196f3);
    background-size: 200% auto;
    color: white;
    box-shadow: 0 4px 15px 0 rgba(65, 132, 234, 0.4);
    transition: all 0.3s ease;
}

#save-admins-btn:hover:not(:disabled) {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(65, 132, 234, 0.5);
}

/* パネル内のボタングループのスタイル調整 */
#panel-admins .button-group {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 2rem;
    margin-top: 2.5rem;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    #save-admins-btn {
        width: 100%;
    }
    
    #panel-admins .button-group {
        padding-top: 1.5rem;
        margin-top: 2rem;
    }
}

/* ボタングループのスタイル調整 */
.button-group {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* メインの保存ボタングループ用の特別なスタイル */
.button-group-main {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid rgba(102, 166, 255, 0.3);
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), transparent);
}

/* メインの保存ボタンのスタイル */
#save-all-btn {
    width: 100%;
    max-width: 400px;
    font-size: 1.1rem;
    padding: 1rem 2rem;
    background-image: linear-gradient(to right, #4CAF50, #45a049, #388E3C);
    box-shadow: 0 4px 15px 0 rgba(76, 175, 80, 0.4);
}

#save-all-btn:hover:not(:disabled) {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(76, 175, 80, 0.5);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .button-group-main {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }
    
    #save-all-btn {
        font-size: 1rem;
        padding: 0.875rem 1.5rem;
    }
}

/* プロファイル設定パネルのスタイル */
#panel-profile .form-group {
    margin-bottom: 2rem;
}

#panel-profile input {
    margin-bottom: 0.5rem;
}

#panel-profile small {
    color: #666;
    font-size: 0.85rem;
}

#save-profile-btn {
    background-image: linear-gradient(to right, #4CAF50, #45a049, #388E3C);
}

#save-profile-btn:hover:not(:disabled) {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(76, 175, 80, 0.5);
}