/* css/style.css - メインスタイルシート */

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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --danger-color: #dc2626;
    --success-color: #16a34a;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

/* ヘッダー */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ログインページ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
}

.login-box h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    text-align: center;
}

.login-box h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-light);
}

/* フォーム */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-light);
    font-size: 0.875rem;
}

/* ボタン */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
}

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

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button[type="submit"] {
    width: 100%;
}

/* エラーメッセージ */
.error-message,
.success-message {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.success-message {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.demo-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f1f5f9;
    border-radius: 6px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* コンテナ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* アクションバー */
.action-bar {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* プロジェクトグリッド */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.project-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.project-card p {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.project-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.project-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.project-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* モーダル - 大きいサイズ */
.modal-large {
    max-width: 1200px;
    width: 90%;
}

/* 画像設定コンテナ */
.image-settings-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

/* プレビューセクション */
.preview-section h3,
.settings-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.panorama-preview {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.panorama-viewport {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}

.panorama-viewport:active {
    cursor: grabbing;
}

.panorama-viewport img {
    position: absolute;
    height: 100%;
    width: auto;
    max-width: none;   /* 幅制限を外す（パノラマ画像は横長）*/
    left: 0;
    top: 0;
    transform-origin: top left;
    pointer-events: none;
    /* transition は使わない（ドラッグ中は即時反映が必要）*/
}

/* ビューポート中央の開始位置マーカー */
.viewport-frame {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 10;
    border: 3px solid rgba(37,99,235,0.7);
    border-radius: 4px;
}
.viewport-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(37,99,235,0.8);
    color: white;
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.start-marker {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #16a34a;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
}

.start-marker::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid #16a34a;
}

.start-marker::after {
    content: attr(data-text);
    position: absolute;
    left: 50%;
    top: 20px;
    transform: translateX(-50%);
    background: #16a34a;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.help-text {
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
    margin: 0.5rem 0 0 0;
    padding: 0.5rem;
}

/* ラジオグループ */
.radio-group {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-label:hover {
    border-color: var(--primary-color);
    background: #f0f9ff;
}

.radio-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--primary-color);
}

.radio-label span {
    font-size: 1rem;
}

/* 画像カードに設定アイコンを追加 */
.image-item {
    position: relative;
}

.image-settings-icon {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s;
}

.image-settings-icon:hover {
    background: var(--primary-color);
    transform: scale(1.1);
}

.image-item.configured .image-settings-icon {
    background: #16a34a;
}

.image-item.configured::after {
    content: '✓';
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    background: #16a34a;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: bold;
    z-index: 5;
}

@media (max-width: 768px) {
    .image-settings-container {
        grid-template-columns: 1fr;
    }
    
    .panorama-viewport {
        height: 250px;
    }
}
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-large {
    max-width: 1200px;
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

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

/* タブ */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-light);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    padding: 2rem 0;
}

.tab-content.active {
    display: block;
}

/* アップロードエリア */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s;
    background: var(--background);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.upload-placeholder svg {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.upload-placeholder p {
    margin: 0.5rem 0;
    color: var(--text-light);
}

.upload-note {
    font-size: 0.875rem;
    margin-top: 1rem !important;
}

/* 画像グリッド */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.image-item {
    position: relative;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
    background: var(--background);
    cursor: pointer;
}

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

.image-item.selected {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.3);
    transform: scale(0.98);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-item:hover .image-overlay {
    opacity: 1;
}

.image-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.image-order {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: var(--primary-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 1;
}

.selection-order {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #16a34a; /* 緑色 */
    color: white;
    min-width: 32px;
    height: 32px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    padding: 0 10px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    border: 2px solid white;
    z-index: 2;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% {
        transform: scale(0);
    }
    60% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* プログレスバー */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
    width: 0%;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

/* ビデオリスト */
.videos-list {
    display: grid;
    gap: 1.5rem;
}

.video-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.video-player {
    width: 100%;
    max-height: 400px;
    background: #000;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.video-info {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.video-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.share-url {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.share-url input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }

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

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    .images-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* ===== 追加スタイル ===== */

/* 設定ボタン（⚙） */
.image-settings-btn {
    position: absolute;
    bottom: 0.4rem;
    right: 0.4rem;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
    padding: 0;
}
.image-settings-btn:hover {
    background: #2563eb;
}

/* 設定済みバッジ */
.config-badge {
    position: absolute;
    bottom: 0.4rem;
    left: 0.4rem;
    background: #16a34a;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* パノラマビューポート枠 */
.viewport-frame {
    position: absolute;
    inset: 0;
    border: 3px solid rgba(37,99,235,0.7);
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
}
.viewport-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(37,99,235,0.85);
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 情報ボックス */
.info-box {
    background: #e0f2fe;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.25rem;
    border-left: 4px solid #0284c7;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* small テキスト */
.form-group small {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: #6b7280;
}

/* btn-sm */
.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

/* 動画カード */
.video-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.video-info p { margin: 0.25rem 0; font-size: 0.875rem; color: #6b7280; }
.video-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.video-actions .btn { font-size: 0.875rem; }


/* ===== 使用量バー ===== */
.main-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 2rem;
}

.usage-bar-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.5rem 2rem 0.6rem;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.usage-bar-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.usage-label {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
    min-width: 52px;
}

.usage-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
}

.usage-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.6s ease, background 0.3s;
    width: 0%;
}

.usage-text {
    font-size: 0.75rem;
    white-space: nowrap;
    font-weight: 600;
    min-width: 110px;
}

.usage-plan {
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--primary-color);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .usage-bar-container { gap: 0.75rem; padding: 0.5rem 1rem; }
    .usage-bar-item { min-width: 150px; }
}

/* image-settings-modalの開始位置表示 */
#start-position-display {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2563eb;
    line-height: 1.8;
    margin: 0.5rem 0;
}



/* ===== 画像アップロードタブ（v16 完全修正版） ===== */
#images-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.upload-image-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.upload-image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.upload-image-preview {
    position: relative;
    width: 100%;
    padding-top: 66.67%; /* 3:2 aspect ratio */
    background: #f3f4f6;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
}

.upload-image-preview img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.upload-image-number {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: #2563eb;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.upload-image-info {
    padding: 0.75rem;
    background: white;
}

.upload-image-filename {
    margin: 0 0 0.25rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.upload-image-size {
    margin: 0;
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

.upload-image-card .btn-danger {
    margin: 0 0.75rem 0.75rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    width: calc(100% - 1.5rem);
}

.upload-image-card .btn-danger:hover {
    background: #b91c1c;
}

.upload-image-card .btn-danger:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    #images-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .upload-image-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
}

/* カスタムアスペクト比入力 */
#custom-aspect-ratio {
    margin-top: 0.5rem;
}

/* ===== 生成済み動画のアスペクト比対応 ===== */
.video-card video {
    max-height: 600px;
    background: #000;
    object-fit: contain; /* アスペクト比を維持 */
}

/* 縦型動画用のスタイル */
.video-card video.portrait {
    max-width: 450px !important;
    margin: 0 auto;
    display: block;
}

/* 横型動画用のスタイル */
.video-card video.landscape {
    max-width: 100% !important;
}

/* 正方形動画用のスタイル */
.video-card video.square {
    max-width: 600px !important;
    margin: 0 auto;
    display: block;
}
