/* リセット・基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* ヘッダー */
header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

header .main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-auth {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

header nav a:hover {
    background-color: #34495e;
}

.nav-username {
    margin-right: 0.25rem;
    color: #f0f0f0;
}

.nav-logout-btn {
    margin-left: 0.25rem;
    padding: 0.4rem 0.9rem;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.nav-logout-btn:hover {
    background: #b02a37;
}

.nav-login-link {
    margin-left: 0.5rem;
}

/* メイン */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* フッター */
footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

/* フォームコンテナ */
.form-container {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.form-container h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.5rem;
}

.form-section {
    margin-bottom: 2rem;
}

.form-section h3 {
    color: #34495e;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* 画像アップロード */
.image-upload-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.upload-box {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 1rem;
    background-color: #fafafa;
}

.upload-box label {
    display: block;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.upload-box input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    cursor: pointer;
}

.image-preview {
    width: 100%;
    height: 250px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-placeholder {
    text-align: center;
    color: #999;
}

.preview-placeholder svg {
    stroke: #ccc;
    margin-bottom: 0.5rem;
}

/* フォームグループ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.form-group select {
    height: 45px;
    padding: 0 0.75rem;
    background-color: #fff;
}

/* ボタン */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #b02a37;
}

/* スピナー */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* エラーメッセージ */
.error-message {
    background-color: #e74c3c;
    color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

/* 成功メッセージ */
.success-message {
    background-color: #27ae60;
    color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .image-upload-group {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    header h1 {
        font-size: 1.2rem;
    }

    header nav {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ステータス画面 */
.status-container {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.status-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.status-icon.queued { color: #f39c12; }
.status-icon.processing { color: #3498db; }
.status-icon.done { color: #27ae60; }
.status-icon.failed { color: #e74c3c; }

.status-info {
    margin: 2rem 0;
}

.status-info p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}

.status-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1rem;
    margin: 1rem 0;
}

.status-badge.queued { background-color: #f39c12; color: white; }
.status-badge.processing { background-color: #3498db; color: white; }
.status-badge.done { background-color: #27ae60; color: white; }
.status-badge.failed { background-color: #e74c3c; color: white; }

.report-details {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: left;
}

.report-details h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.detail-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: bold;
    color: #555;
}

.detail-value {
    color: #333;
}

/* 台帳一覧画面 */
.list-container {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.list-container h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.5rem;
}

/* 検索フォーム */
.search-form {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-grid .form-group {
    margin-bottom: 0;
}

.search-grid select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
}

.search-actions {
    display: flex;
    gap: 1rem;
}

.search-actions .btn {
    padding: 0.75rem 1.5rem;
}

/* 検索結果情報 */
.results-info {
    margin-bottom: 1rem;
    color: #555;
    font-size: 0.95rem;
}

/* テーブル */
.table-container {
    overflow-x: auto;
    margin-bottom: 2rem;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.report-table thead {
    background-color: #2c3e50;
    color: white;
}

.report-table th {
    padding: 1rem;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid #34495e;
}

.report-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.2s;
}

.report-table tbody tr:hover {
    background-color: #f8f9fa;
}

.report-table td {
    padding: 1rem;
}

.comment-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-cell {
    white-space: nowrap;
}

.action-cell .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

/* 検索結果なし */
.no-results {
    text-align: center;
    padding: 3rem;
    color: #999;
}

/* ページネーション */
.pagination {
    display: flex;
    list-style: none;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 0;
}

.pagination a {
    display: inline-block;
    color: black;
    text-decoration: none;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
}

.pagination a:hover {
    background-color: #9d9ae2;
    color: white;
}

.pagination li {
    display: inline-block;
}

.pagination .active a {
    background-color: #4F46E5;
    color: white;
}

.pagination .disabled a {
    pointer-events: none;
    color: #ccc;
}

.pagination .disabled a:hover {
    background-color: initial;
    color: #ccc;
}

/* Admin approval feature */
.approval-cell {
    white-space: nowrap;
    text-align: center;
}

.approval-status {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85em;
}

.approval-status.approved {
    color: #28a745;
}

.approval-status small {
    font-size: 0.75em;
    color: #666;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
    border: none;
}

.btn-warning:hover {
    background-color: #e0a800;
}

/* レスポンシブ - 台帳一覧 */
@media (max-width: 768px) {
    .search-grid {
        grid-template-columns: 1fr;
    }

    .search-actions {
        flex-direction: column;
    }

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

    .report-table {
        font-size: 0.85rem;
    }

    .report-table th,
    .report-table td {
        padding: 0.5rem;
    }

    .comment-cell {
        max-width: 150px;
    }

    .action-cell .btn {
        display: block;
        margin-bottom: 0.5rem;
        width: 100%;
    }
}
