/**
 * 棚番号検索 - フロントエンドスタイル
 * モバイル最優先、ダークモード対応
 */

/* ==================== 
   基本コンテナ
==================== */
.shelf-search-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.shelf-search-section,
.shelf-register-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==================== 
   アコーディオン
==================== */
.shelf-register-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    padding: 16px;
    margin: -24px -24px 24px -24px;
    border-radius: 12px 12px 0 0;
}

.shelf-register-header:hover {
    background-color: #f5f5f5;
}

.shelf-register-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 8px 0 !important;
}

.accordion-icon {
    font-size: 16px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.accordion-icon.collapsed {
    transform: rotate(-90deg);
}

.shelf-register-content {
    max-height: 3000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.shelf-register-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ==================== 
   検索UI
==================== */
.shelf-search-wrapper {
    position: relative;
}

.shelf-search-header {
    margin-bottom: 24px;
}

.shelf-search-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 16px 0;
}

.shelf-search-form {
    display: flex;
    gap: 8px;
    position: relative;
}

.shelf-search-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
}

.shelf-search-input:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.shelf-search-button {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: #2196F3;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.shelf-search-button:hover {
    background: #1976D2;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.shelf-search-button:active {
    transform: translateY(0);
}

.shelf-search-clear {
    position: absolute;
    right: 180px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 20px;
    display: none;
}

.shelf-search-clear:hover {
    color: #333;
}

/* ローディング */
.shelf-search-loading {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 検索結果 */
.shelf-search-results {
    margin-top: 24px;
}

.shelf-search-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

/* 結果カード（アコーディオン） */
.shelf-result-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.18s ease;
}

.shelf-result-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.shelf-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    cursor: pointer;
    min-height: 60px;
    -webkit-tap-highlight-color: transparent;
}

.shelf-result-header:active {
    background: rgba(0, 0, 0, 0.05);
}

.shelf-result-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.shelf-management-id {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.shelf-divider {
    color: #999;
    font-size: 18px;
}

.shelf-code-badge {
    display: inline-block;
    padding: 6px 12px;
    background: #2196F3;
    color: #ffffff;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
}

.shelf-expand-icon {
    font-size: 24px;
    color: #666;
    transition: transform 0.18s ease;
}

.shelf-result-card.expanded .shelf-expand-icon {
    transform: rotate(180deg);
}

.shelf-result-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.18s ease;
}

.shelf-result-card.expanded .shelf-result-content {
    max-height: 2000px;
}

.shelf-result-body {
    padding: 0 16px 16px 16px;
    border-top: 1px solid #e0e0e0;
}

.shelf-result-notes {
    margin: 16px 0;
}

.shelf-result-notes-label {
    font-weight: 600;
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
}

.shelf-result-notes-text {
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.shelf-result-photo {
    margin-top: 16px;
}

.shelf-result-photo-label {
    font-weight: 600;
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
}

.shelf-result-photo-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.shelf-result-photo-img:hover {
    transform: scale(1.02);
}

.shelf-result-no-photo {
    color: #999;
    font-style: italic;
    font-size: 14px;
}

/* ページネーション */
.shelf-search-pagination {
    text-align: center;
    margin-top: 24px;
}

.shelf-load-more-button {
    padding: 14px 32px;
    font-size: 16px;
    font-weight: 600;
    color: #2196F3;
    background: #ffffff;
    border: 2px solid #2196F3;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shelf-load-more-button:hover {
    background: #2196F3;
    color: #ffffff;
}

/* ==================== 
   登録UI
==================== */
.shelf-register-wrapper {
    position: relative;
}

.shelf-register-header {
    margin-bottom: 24px;
}

.shelf-register-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 8px 0;
}

.shelf-register-description {
    color: #666;
    margin: 0;
}

.shelf-register-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 15px;
}

.required {
    color: #f44336;
    font-weight: 700;
}

.optional {
    color: #999;
    font-weight: 400;
    font-size: 14px;
}

.form-input,
.form-textarea {
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-input-file {
    padding: 10px;
    font-size: 16px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-input-file:hover {
    border-color: #2196F3;
    background: rgba(33, 150, 243, 0.05);
}

.form-input-small {
    max-width: 150px;
}

.form-help {
    font-size: 13px;
    color: #666;
    margin-top: 6px;
}

.form-error {
    font-size: 13px;
    color: #f44336;
    margin-top: 6px;
    display: none;
}

.form-error.visible {
    display: block;
}

/* 写真プレビュー */
.photo-preview {
    margin-top: 12px;
    position: relative;
}

.photo-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    display: block;
}

.photo-remove-button {
    margin-top: 8px;
    padding: 8px 16px;
    font-size: 14px;
    color: #f44336;
    background: #ffffff;
    border: 2px solid #f44336;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.photo-remove-button:hover {
    background: #f44336;
    color: #ffffff;
}

/* CAPTCHA */
.captcha-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.captcha-question {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* 送信ボタン */
.form-actions {
    margin-top: 8px;
}

.form-submit-button {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    background: #4CAF50;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
}

.form-submit-button:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.form-submit-button:active {
    transform: translateY(0);
}

.form-submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 登録完了メッセージ */
.register-success-message {
    text-align: center;
    padding: 40px 20px;
    background: #f1f8f4;
    border: 2px solid #4CAF50;
    border-radius: 12px;
}

.success-icon {
    font-size: 64px;
    color: #4CAF50;
    margin-bottom: 16px;
}

.register-success-message h3 {
    font-size: 24px;
    color: #1a1a1a;
    margin: 0 0 24px 0;
}

.success-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.button-secondary {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #2196F3;
    background: #ffffff;
    border: 2px solid #2196F3;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.button-secondary:hover {
    background: #2196F3;
    color: #ffffff;
}

/* ==================== 
   レスポンシブ（タブレット）
==================== */
@media (max-width: 768px) {
    .shelf-search-container {
        padding: 16px;
    }
    
    .shelf-search-section,
    .shelf-register-section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .shelf-search-form {
        flex-direction: column;
    }
    
    .shelf-search-clear {
        right: 16px;
        top: 26px;
    }
    
    .search-text {
        display: inline;
    }
}

/* ==================== 
   レスポンシブ（スマートフォン）
==================== */
@media (max-width: 480px) {
    .shelf-search-container {
        padding: 12px;
    }
    
    .shelf-search-section,
    .shelf-register-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .shelf-search-title,
    .shelf-register-title {
        font-size: 20px;
    }
    
    .shelf-result-header {
        padding: 12px;
    }
    
    .shelf-result-info {
        gap: 8px;
    }
    
    .shelf-management-id {
        font-size: 16px;
    }
    
    .shelf-code-badge {
        font-size: 14px;
        padding: 4px 10px;
    }
    
    .success-actions {
        flex-direction: column;
    }
    
    .button-secondary {
        width: 100%;
    }
}

/* ==================== 
   ダークモード対応
==================== */
@media (prefers-color-scheme: dark) {
    .shelf-search-section,
    .shelf-register-section {
        background: #1e1e1e;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .shelf-register-header:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
    
    .shelf-search-title,
    .shelf-register-title,
    .shelf-register-description {
        color: #ffffff;
    }
    
    .shelf-search-input,
    .form-input,
    .form-textarea {
        background: #2a2a2a;
        border-color: #444;
        color: #ffffff;
    }
    
    .shelf-search-input:focus,
    .form-input:focus,
    .form-textarea:focus {
        border-color: #2196F3;
        background: #333;
    }
    
    .shelf-result-card {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .shelf-result-header:active {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .shelf-management-id {
        color: #ffffff;
    }
    
    .shelf-result-body {
        border-top-color: #444;
    }
    
    .shelf-result-notes-text {
        color: #ddd;
    }
    
    .shelf-result-notes-label,
    .shelf-result-photo-label {
        color: #aaa;
    }
    
    .form-label {
        color: #ddd;
    }
    
    .form-help {
        color: #999;
    }
    
    .shelf-register-description {
        color: #aaa;
    }
    
    .register-success-message {
        background: #1e3a1e;
        border-color: #4CAF50;
    }
    
    .register-success-message h3 {
        color: #ffffff;
    }
}

/* ==================== 
   アクセシビリティ
==================== */
.shelf-search-button:focus,
.shelf-load-more-button:focus,
.form-submit-button:focus,
.button-secondary:focus {
    outline: 3px solid #2196F3;
    outline-offset: 2px;
}

/* タップ領域の確保（モバイル） */
@media (max-width: 768px) {
    .shelf-search-button,
    .shelf-load-more-button,
    .form-submit-button,
    .button-secondary {
        min-height: 48px;
        min-width: 48px;
    }
    
    .shelf-result-header {
        min-height: 48px;
    }
}

