/* ====================
   カラーパレット & CSS変数
   ==================== */
:root {
    --color-primary: #4F46E5;
    --color-primary-dark: #4338CA;
    --color-primary-light: #818CF8;
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;
    --color-info: #3B82F6;
    --color-current-year: #3B82F6;
    --color-current-year-light: #93C5FD;
    --color-next-year: #8B5CF6;
    --color-next-year-light: #C4B5FD;
    --color-bg: #F9FAFB;
    --color-surface: #FFFFFF;
    --color-text-primary: #1F2937;
    --color-text-secondary: #6B7280;
    --color-border: #E5E7EB;
    --color-border-light: #F3F4F6;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ====================
   リセット & ベース
   ==================== */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
    line-height: 1.7;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    background-attachment: fixed;
    color: var(--color-text-primary);
    min-height: 100vh;
}

/* ====================
   ヘッダー
   ==================== */
.topbar {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
}

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.topbar h1 a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.topbar h1 a:hover {
    color: var(--color-primary-dark);
}

/* ====================
   メインコンテナ
   ==================== */
.wrap {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

main.wrap {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding: 2.5rem;
}

/* ====================
   見出し
   ==================== */
h2 {
    color: var(--color-primary);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--color-primary);
    letter-spacing: -0.025em;
}

h3 {
    color: var(--color-text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

h4 {
    color: var(--color-text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ====================
   セクション
   ==================== */
section {
    margin-bottom: 3rem;
}

/* ====================
   リスト
   ==================== */
.survey-list {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 1.5rem;
}

.survey-list li {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-left: 4px solid var(--color-primary);
}

.survey-list li:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ====================
   ボタン
   ==================== */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: var(--color-surface);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button[type="submit"] {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--color-primary);
    color: var(--color-surface);
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

button[type="submit"]:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ====================
   削除ボタン
   ==================== */
.btn-remove {
    padding: 0.5rem 1rem;
    background: var(--color-danger);
    color: var(--color-surface);
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-remove:hover {
    background: #DC2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ====================
   フォーム
   ==================== */
.q {
    margin-bottom: 1.5rem;
}

.q label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text-primary);
    font-weight: 600;
}

.q input[type="text"],
.q input[type="password"],
.q select,
.q textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--color-text-primary);
}

.q input[type="text"]:focus,
.q input[type="password"]:focus,
.q select:focus,
.q textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.q textarea {
    resize: vertical;
    min-height: 120px;
}

.q input[type="radio"],
.q input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.q > div {
    margin-bottom: 0.5rem;
}

.q > div label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s ease;
}

.q > div label:hover {
    background-color: var(--color-bg);
}

/* ====================
   フラッシュメッセージ
   ==================== */
.flashes {
    list-style: none;
    padding: 0;
    margin-bottom: 1.5rem;
}

.flash {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.flash.success {
    background: #D1FAE5;
    color: #065F46;
    border-left: 4px solid var(--color-success);
}

.flash.error {
    background: #FEE2E2;
    color: #991B1B;
    border-left: 4px solid var(--color-danger);
}

.flash.info {
    background: #DBEAFE;
    color: #1E40AF;
    border-left: 4px solid var(--color-info);
}

/* ====================
   テーブル
   ==================== */
table.responses {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table.responses th {
    background: var(--color-primary);
    color: var(--color-surface);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

table.responses td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-primary);
}

table.responses tr:last-child td {
    border-bottom: none;
}

table.responses tr:hover {
    background-color: var(--color-bg);
}

table.responses a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

table.responses a:hover {
    text-decoration: underline;
}

/* ====================
   フッター
   ==================== */
.small {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    padding: 2rem 0;
    text-align: center;
}

/* ====================
   提案カード
   ==================== */
.proposals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.proposal-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border-left: 4px solid var(--color-primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.proposal-card.unread {
    border-left-color: var(--color-warning);
    background: #FFFBEB;
}

.proposal-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.proposal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.proposal-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-width: 0;
}

.proposal-info strong {
    word-break: break-word;
    overflow-wrap: break-word;
    color: var(--color-text-primary);
}

.badge {
    background: var(--color-primary);
    color: var(--color-surface);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.proposal-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.timestamp {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    word-break: break-all;
}

.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.read {
    background: var(--color-border);
    color: var(--color-text-secondary);
}

.status-badge.unread {
    background: var(--color-warning);
    color: var(--color-surface);
}

.proposal-content {
    margin-bottom: 1rem;
}

.proposal-text {
    margin-top: 1rem;
    padding: 1.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: left;
}

.proposal-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: inline-block;
    white-space: nowrap;
    text-align: center;
    border: none;
    cursor: pointer;
}

.read-btn {
    background: var(--color-primary);
    color: var(--color-surface);
}

.read-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.ban-btn {
    background: var(--color-surface);
    color: var(--color-danger);
    border: 2px solid var(--color-danger);
}

.ban-btn:hover {
    background: var(--color-danger);
    color: var(--color-surface);
    transform: translateY(-1px);
}

.delete-btn {
    background: var(--color-surface);
    color: var(--color-danger);
    border: 2px solid var(--color-danger);
}

.delete-btn:hover {
    background: var(--color-danger);
    color: var(--color-surface);
    transform: translateY(-1px);
}

/* ====================
   レスポンシブデザイン
   ==================== */
@media (max-width: 768px) {
    main.wrap {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: var(--radius-lg);
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    .topbar .wrap {
        padding: 0.75rem 1rem;
    }

    .topbar h1 {
        font-size: 1.2rem;
    }

    table.responses {
        font-size: 0.9rem;
    }

    table.responses th,
    table.responses td {
        padding: 0.75rem 0.5rem;
    }

    .table-container {
        overflow-x: auto;
    }

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

    .proposal-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .proposal-meta {
        align-items: flex-start;
        flex-direction: row;
        gap: 0.5rem;
    }

    .action-btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    main.wrap {
        padding: 1rem;
    }

    .btn {
        display: block;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .survey-list li {
        padding: 1rem;
    }

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

    .proposal-card {
        padding: 1rem;
    }

    .proposal-text {
        padding: 1rem;
        font-size: 0.95rem;
    }

    .action-btn {
        width: 100%;
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }

    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}
