/* Notion風デザインシステム */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Notionカラーパレット */
    --notion-bg: #FFFFFF;
    --notion-bg-secondary: #F7F6F3;
    --notion-text: #37352F;
    --notion-text-secondary: #787774;
    --notion-border: #E9E9E7;
    --notion-hover: #F1F1EF;
    --notion-blue: #2383E2;
    --notion-green: #0F7B6C;
    --notion-red: #E03E3E;
    --notion-purple: #9065B0;
}

body {
    font-family: Metropolis, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 16px;
    line-height: 1.6;
    color: var(--notion-text);
    background: var(--notion-bg-secondary);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--notion-bg);
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 48px;
}

/* ヘッダー */
header {
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--notion-border);
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--notion-text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--notion-text-secondary);
    font-size: 16px;
    font-weight: 400;
}

/* フォーム要素 */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--notion-text);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--notion-border);
    border-radius: 3px;
    font-size: 16px;
    color: var(--notion-text);
    background: var(--notion-bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--notion-blue);
    box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.1);
}

/* アップロードエリア */
.upload-section {
    margin-bottom: 48px;
}

.upload-area {
    border: 2px dashed var(--notion-border);
    border-radius: 3px;
    padding: 48px 24px;
    text-align: center;
    margin: 24px 0;
    transition: all 0.15s;
    cursor: pointer;
    background: var(--notion-bg);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--notion-blue);
    background: rgba(35, 131, 226, 0.03);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.upload-hint {
    color: var(--notion-text-secondary);
    margin: 8px 0;
    font-size: 14px;
}

/* プレビューエリア */
.preview-area {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin: 24px 0;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--notion-border);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(224, 62, 62, 0.9);
    color: white;
    border: none;
    border-radius: 3px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background 0.15s;
}

.preview-item .remove-btn:hover {
    background: rgba(224, 62, 62, 1);
}

/* ボタン */
.btn {
    padding: 10px 16px;
    border: 1px solid var(--notion-border);
    border-radius: 3px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--notion-bg);
    color: var(--notion-text);
}

.btn:hover {
    background: var(--notion-hover);
}

.btn-primary {
    background: var(--notion-blue);
    color: white;
    border-color: var(--notion-blue);
}

.btn-primary:hover {
    background: #1a6bbd;
    border-color: #1a6bbd;
}

.btn-success {
    background: var(--notion-green);
    color: white;
    border-color: var(--notion-green);
}

.btn-success:hover {
    background: #0c6158;
    border-color: #0c6158;
}

.btn-large {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 24px;
}

.btn:disabled {
    background: var(--notion-hover);
    border-color: var(--notion-border);
    color: var(--notion-text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

/* ギャラリーリスト */
.gallery-list {
    display: grid;
    gap: 12px;
}

.gallery-item {
    background: var(--notion-bg);
    padding: 16px;
    border: 1px solid var(--notion-border);
    border-radius: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.gallery-item:hover {
    background: var(--notion-hover);
}

.gallery-info h3 {
    margin-bottom: 6px;
    color: var(--notion-text);
    font-size: 16px;
    font-weight: 600;
}

.gallery-meta {
    color: var(--notion-text-secondary);
    font-size: 14px;
}

.gallery-actions {
    display: flex;
    gap: 8px;
}

.gallery-actions .btn {
    padding: 6px 12px;
    font-size: 13px;
}

.empty-message {
    text-align: center;
    color: var(--notion-text-secondary);
    padding: 48px;
    font-size: 14px;
}

/* お客様画面 */
.client-view {
    min-height: calc(100vh - 40px);
}

.auth-section {
    max-width: 400px;
    margin: 80px auto;
    text-align: center;
}

.auth-section h2 {
    margin-bottom: 24px;
    color: var(--notion-text);
    font-size: 24px;
    font-weight: 700;
}

.auth-section input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--notion-border);
    border-radius: 3px;
    font-size: 16px;
    margin-bottom: 16px;
}

.error-message {
    color: var(--notion-red);
    margin-top: 8px;
    font-size: 14px;
}

/* 固定コントロールバー */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--notion-border);
    z-index: 1000;
    flex-wrap: wrap;
    gap: 12px;
}

.selection-info {
    font-size: 16px;
    font-weight: 500;
    color: var(--notion-text);
    flex: 1;
    min-width: 300px;
}

.control-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 写真グリッド */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding-bottom: 120px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
    border: 1px solid var(--notion-border);
}

.photo-item:hover {
    transform: scale(1.02);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 選択された写真 */
.photo-item.selected::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 123, 108, 0.2);
    z-index: 1;
    pointer-events: none;
}

.photo-item.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--notion-green);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    z-index: 2;
}

.photo-item.selected {
    transform: scale(0.98);
    border-color: var(--notion-green);
}

/* ライトボックス */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    padding: 24px;
}

.lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 40px;
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.lightbox-close:hover {
    color: #ccc;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 3px;
}

.lightbox-controls {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

/* スクロール追従カウンター */
.floating-counter {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--notion-text);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: all 0.15s ease;
}

.floating-counter span {
    font-size: 18px;
    font-weight: 700;
}

/* スクリーンショット防止 */
.client-view {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.client-view img {
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* 透かし */
.photo-item::before {
    content: 'SAMPLE';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 32px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
}

.lightbox::after {
    content: 'SAMPLE PREVIEW';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 48px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.2);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 1001;
    white-space: nowrap;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container {
        padding: 24px;
    }

    header h1 {
        font-size: 24px;
    }

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

    .controls {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 12px;
    }

    .selection-info {
        min-width: 100%;
    }

    .control-buttons {
        width: 100%;
    }

    .control-buttons .btn {
        flex: 1;
        min-width: 120px;
        font-size: 12px;
        padding: 8px;
    }

    .gallery-item {
        flex-direction: column;
        gap: 12px;
    }

    .floating-counter {
        font-size: 12px;
        padding: 8px 12px;
        bottom: 16px;
        right: 16px;
    }
}
