/* css/style.css - 修正版 */

/* === グローバルスタイル === */
:root {
    --color-primary: #a8b5a0;
    --color-secondary: #8b9d83;
    --color-like: #c8a8a8;
    --color-favorite: #d4b5a0;
    --color-report: #cc0000;
    
    --bg-primary: #f5f5f0;
    --card-bg: #fafaf8;
    --text-primary: #5a6651;
    --text-secondary: #8b9d83;
    --border-light: #d4c5b0;
    --border-dark: #8b9d83;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    padding-bottom: 80px;
}

h2.section-title {
    text-align: center;
    color: var(--text-primary);
    margin: 20px 0;
    font-size: 1.5em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.view-container {
    padding: 20px 0;
    max-width: 600px;
    margin: 0 auto;
}

.empty-message {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    margin: 20px;
}

/* === ピクセルグリッド === */
.pixel-grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    border: 3px solid var(--border-dark);
    background: var(--border-dark);
    padding: 3px;
    border-radius: 8px;
    width: fit-content;
    margin: 0 auto;
}

.grid-cell {
    background: #f5f5f0;
    border: 1px solid var(--border-light);
    aspect-ratio: 1 / 1;
}

/* === 作成ビュー === */
.create-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(139,157,131,0.2);
    margin: 0 20px;
}

.create-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.author-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.author-info span {
    font-weight: bold;
    color: var(--text-primary);
}

.menu-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
}

.grid-editor-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.grid-editor-wrapper .pixel-grid-container {
    max-width: 280px;
    width: 100%;
}

.grid-editor-wrapper .grid-cell {
    cursor: pointer;
}

/* --- カラーピッカー --- */
.color-picker-section {
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.picker-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.tab-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: bold;
    margin-right: 8px;
}

.tab-btn {
    padding: 8px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--color-primary);
    color: white;
    font-weight: bold;
}

/* パレット */
.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.palette-cell {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    box-sizing: border-box;
    transition: transform 0.1s;
}

.palette-cell:active {
    transform: scale(0.95);
}

/* RGB & Gradient スライダー */
.rgb-slider-group, .hue-slider-group {
    margin-bottom: 16px;
}

.rgb-label-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.rgb-label-group label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: bold;
}

.rgb-label-group span {
    font-size: 12px;
    color: var(--text-secondary);
}

.rgb-slider-track, .hue-slider-track {
    height: 32px;
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    border: 2px solid var(--border-light);
    user-select: none;
}

.hue-slider-track {
    background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    margin-bottom: 16px;
}

.slider-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid var(--text-primary);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* 2D Gradient */
.saturation-label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: bold;
    display: block;
    margin-bottom: 8px;
}

.gradient-picker-area {
    width: 100%;
    height: 200px;
    background-blend-mode: multiply;
    border-radius: 8px;
    cursor: crosshair;
    position: relative;
    border: 2px solid var(--border-light);
}

.gradient-thumb {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid var(--text-primary);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    pointer-events: none;
}

.selected-color-preview {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.color-box {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid var(--border-dark);
    box-shadow: 0 2px 4px rgba(139,157,131,0.2);
}

/* 投稿フォーム */
.title-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    box-sizing: border-box;
    background: var(--card-bg);
}

.submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--color-like);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(200, 168, 168, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.1s;
}

.submit-btn:active {
    transform: scale(0.98);
}

/* === 作品カード === */
.work-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(139,157,131,0.15);
    position: relative;
    text-align: center;
}

.work-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-report);
    color: white;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    transition: transform 0.1s;
}

.work-delete-btn:hover {
    transform: scale(1.1);
}

.work-content-area {
    cursor: pointer;
    text-align: center;
}

.work-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.work-author {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.work-grid-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.work-actions {
    display: flex;
    justify-content: space-around;
    gap: 4px;
}

.action-btn {
    background: var(--bg-primary);
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn.liked {
    background: var(--color-like);
    color: white;
}

.action-btn.favorited {
    background: var(--color-favorite);
    color: white;
}

/* === ランダムビュー === */
.works-grid-random {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    padding: 0 20px;
}

.random-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    margin-bottom: 10px;
}

.refresh-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    margin-left: 12px;
    padding: 8px;
    transition: transform 0.2s;
}

.refresh-btn:active {
    transform: rotate(90deg);
}

/* === ランキングビュー === */
.ranking-view {
    padding: 20px;
}

.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.works-grid-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.ranking-card {
    padding-top: 28px;
}

.rank-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.rank-top {
    background: var(--color-favorite);
}

.rank-normal {
    background: var(--color-secondary);
}

/* === フッターナビゲーション === */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    box-shadow: 0 -2px 8px rgba(139, 157, 131, 0.15);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 10px 0 8px;
    z-index: 998;
    height: 70px;
}

.nav-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    transition: color 0.2s;
    padding: 5px 10px;
}

.nav-btn.active {
    color: var(--color-primary);
}

.nav-btn span {
    font-size: 10px;
}

.create-btn {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(168,181,160,0.4);
    position: relative;
    top: -20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white !important;
    padding: 0;
}

/* === サイドメニュー === */
#side-menu-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

#side-menu-container.open {
    pointer-events: all;
    opacity: 1;
}

.side-menu {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 80%;
    height: 100%;
    background: var(--card-bg);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s;
    padding: 20px;
    box-sizing: border-box;
}

#side-menu-container.open .side-menu {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.menu-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
}

.menu-author-id {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 15px;
}

.menu-author-id span {
    font-weight: bold;
    color: var(--text-primary);
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-list li {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.2s;
}

.menu-list li:hover {
    background: var(--border-light);
}

/* === モーダル === */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

#modal-container.open {
    pointer-events: all;
    opacity: 1;
}

.modal-backdrop {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px 20px 20px;
    width: 100%;
    max-width: 400px;
    position: relative;
    text-align: center;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-title {
    margin-top: 0;
    color: var(--text-primary);
    font-size: 1.3em;
}

.modal-author {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.modal-grid-area {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.modal-actions-large {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.action-btn-lg {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    transition: transform 0.1s;
}

.action-btn-lg:active {
    transform: scale(0.95);
}

.action-btn-lg.liked {
    background: var(--color-like);
    color: white;
}

.action-btn-lg.favorited {
    background: var(--color-favorite);
    color: white;
}

.modal-actions-small {
    display: flex;
    justify-content: space-around;
    gap: 8px;
    border-top: 1px solid var(--border-light);
    padding-top: 15px;
}

.action-btn-sm {
    background: var(--bg-primary);
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.action-trash {
    color: var(--color-report);
    background: #ffeaea;
}

/* === 通知 === */
#notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transition: opacity 0.3s, visibility 0.3s;
    opacity: 1;
    visibility: visible;
    white-space: nowrap;
}

#notification.hidden {
    opacity: 0;
    visibility: hidden;
}

/* === ユーティリティ === */
.hidden {
    display: none !important;
}