/* === リセットと基本設定 === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-bg: #E1EAF1;
    --color-sidebar: #9BA6BA;
    --color-main: #E1EAF1;
    --color-accent: #4EACC8;
    --color-text: #2c3e50;
    --color-text-muted: #5a6a7a;
    --color-link: #3a8fa8;
    --color-card: #ffffff;
    --color-card-shadow: rgba(0, 0, 0, 0.08);
    --color-success: #3a9d6a;
    --color-error: #d94452;
    --sidebar-width: 260px;

    /* サイドバー用 */
    --sidebar-text: #f0f3f7;
    --sidebar-text-muted: #d0d6e0;
    --sidebar-hover: rgba(255, 255, 255, 0.15);
}

body {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

a {
    color: var(--color-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* === 2ペインレイアウト === */
.layout {
    display: flex;
    min-height: 100vh;
}

/* --- サイドバー --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-sidebar);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.sidebar-header h1 a {
    color: var(--sidebar-text);
}

.sidebar-header h1 a:hover {
    text-decoration: none;
    color: #9F4E54;
}

.sidebar-subtitle {
    color: var(--sidebar-text-muted);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

.sns-links h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-text-muted);
    margin-bottom: 0.8rem;
}

.sns-links ul {
    list-style: none;
}

.sns-links li {
    margin-bottom: 0.5rem;
}

.sns-links a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    transition: background-color 0.2s;
    color: var(--sidebar-text);
}

.sns-links a:hover {
    background-color: var(--sidebar-hover);
    text-decoration: none;
}

.sns-icon {
    font-size: 1.2rem;
    width: 1.5rem;
    text-align: center;
}

.sidebar-nav {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav a {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--sidebar-text-muted);
}

.sidebar-nav a:hover {
    background-color: var(--sidebar-hover);
    text-decoration: none;
    color: var(--sidebar-text);
}

/* --- メインコンテンツ --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem 2.5rem;
    background-color: var(--color-main);
    border-left: 10px solid #9F4E54;
}

/* === フラッシュメッセージ === */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background-color: rgba(58, 157, 106, 0.1);
    border: 1px solid var(--color-success);
    color: var(--color-success);
}

.flash-error {
    background-color: rgba(217, 68, 82, 0.1);
    border: 1px solid var(--color-error);
    color: var(--color-error);
}

/* === ギャラリー === */
.gallery-header h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
    font-weight: 600;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.2rem;
}

.gallery-item {
    display: block;
    background-color: var(--color-card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--color-card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    text-decoration: none;
}

.gallery-item img {
    width: 100%;
    display: block;
}

.gallery-item-title {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.empty-gallery {
    text-align: center;
    padding: 4rem 0;
    color: var(--color-text-muted);
    font-size: 1.1rem;
}

/* === 画像詳細 === */
.detail-page {
    max-width: 900px;
}

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--color-text);
}

.detail-image img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 2px 12px var(--color-card-shadow);
}

.detail-info {
    margin-top: 1.5rem;
}

.detail-info h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.detail-description {
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.detail-date {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* === ログインページ === */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-form-container {
    background-color: var(--color-card);
    padding: 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 12px var(--color-card-shadow);
}

.login-form-container h2 {
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.2rem;
    color: var(--color-text);
}

/* === フォーム共通 === */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid #c8d2dc;
    border-radius: 8px;
    background-color: #f7f9fb;
    color: var(--color-text);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(78, 172, 200, 0.2);
}

.form-group input[type="file"] {
    padding: 0.5rem;
}

.btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background-color: var(--color-accent);
    color: #fff;
}

.btn-danger {
    background-color: #d94452;
    color: #fff;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* === 管理画面 === */
.admin-page h2 {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    color: var(--color-text);
}

.upload-form {
    background-color: var(--color-card);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px var(--color-card-shadow);
}

.admin-page hr {
    border: none;
    border-top: 1px solid #c8d2dc;
    margin: 2rem 0;
}

.admin-image-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.admin-image-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--color-card);
    padding: 0.8rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--color-card-shadow);
}

.admin-image-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.admin-image-info {
    flex: 1;
}

.admin-image-title {
    font-size: 0.95rem;
    color: var(--color-text);
}

.admin-image-date {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.delete-form {
    flex-shrink: 0;
}

/* === カテゴリナビゲーション === */
.category-nav {
    margin-bottom: -0.5rem;
}

.category-nav ul {
    list-style: none;
}

.category-nav li {
    margin-bottom: 0.2rem;
}

.category-nav a {
    display: block;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-size: 1rem;
    transition: background-color 0.2s;
}

.category-nav a:hover {
    background-color: var(--sidebar-hover);
    text-decoration: none;
}

.category-nav li.active a {
    background-color: rgba(255, 255, 255, 0.22);
    font-weight: 600;
}

/* === 管理画面タブ === */
.admin-tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #c8d2dc;
}

.admin-tab {
    padding: 0.7rem 1.4rem;
    border-radius: 8px 8px 0 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    transition: background-color 0.2s;
}

.admin-tab:hover {
    background-color: rgba(0, 0, 0, 0.04);
    text-decoration: none;
}

.admin-tab.active {
    background-color: var(--color-card);
    color: var(--color-text);
    font-weight: 600;
    border: 2px solid #c8d2dc;
    border-bottom: 2px solid var(--color-card);
    margin-bottom: -2px;
}

/* === プロフィールページ === */
.profile-page {
    max-width: 700px;
}

.profile-image {
    margin-bottom: 1.5rem;
}

.profile-image img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 2px 12px var(--color-card-shadow);
}

.profile-page h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--color-text);
}

.profile-bio {
    white-space: pre-wrap;
    color: var(--color-text-muted);
    line-height: 1.8;
}

/* === 作品 (Works) ページ === */
.works-page h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--color-text);
    font-weight: 600;
}

.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.work-card {
    background-color: var(--color-card);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--color-card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.work-card img {
    width: 100%;
    display: block;
}

.work-info {
    padding: 1rem;
}

.work-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.work-info p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.work-link {
    display: inline-block;
    margin-top: 0.6rem;
    font-size: 0.9rem;
    color: var(--color-accent);
}

/* === 管理画面追加スタイル === */
.admin-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.btn-edit {
    background-color: var(--color-accent);
    color: #fff;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.btn-cancel {
    background-color: #8a9bb0;
    color: #fff;
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    margin-left: 0.5rem;
}

.current-profile-image {
    margin-bottom: 0.8rem;
}

.current-profile-image img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
}

.current-profile-image p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.3rem;
}

.admin-image-placeholder {
    width: 80px;
    height: 80px;
    background-color: #e0e5ec;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* === レスポンシブ（モバイル） === */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        padding: 1.2rem;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 1rem;
    }

    .sidebar-header {
        flex: 1;
    }

    .sidebar-subtitle {
        display: none;
    }

    .sns-links {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .sns-links h2 {
        display: none;
    }

    .sns-links ul {
        display: flex;
        gap: 0.3rem;
    }

    .sns-links a {
        padding: 0.4rem;
    }

    .sns-links a span:not(.sns-icon) {
        display: none;
    }

    .category-nav ul {
        display: flex;
        gap: 0.3rem;
    }

    .category-nav a {
        padding: 0.4rem 0.7rem;
        font-size: 0.9rem;
    }

    .sidebar-nav {
        flex-direction: row;
        margin-top: 0;
    }

    .admin-tabs {
        flex-wrap: wrap;
    }

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

    .main-content {
        margin-left: 0;
        padding: 1.2rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.8rem;
    }
}