/**
 * メインスタイルシート
 * 基本レイアウトとコンポーネント
 */

/* リセットとベース */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

/* 画面管理 */
.screen {
    display: none;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin: 1rem 0;
    padding: 2rem;
    min-height: 600px;
}

.screen.active {
    display: block;
}

/* 検索セクション */
.search-section {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border-left: 4px solid #2563eb;
}

/* フォームレイアウト */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #374151;
}

input, select {
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input:focus, select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ボタン */
.btn {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.btn-info {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

/* パンくずリスト */
.breadcrumb {
    background: #e5e7eb;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.breadcrumb a {
    color: #2563eb;
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ナビゲーション */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.input-group {
    display: flex;
    gap: 1rem;
    align-items: end;
}

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

.pagination-info {
    color: #6b7280;
    font-size: 0.9rem;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .navigation {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* テーブルスタイル */
.items-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-header {
    display: grid;
    grid-template-columns: 120px 100px 200px 80px 100px 100px 100px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    padding: 0;
}

.table-header .table-cell {
    padding: 15px 10px;
    border-right: 1px solid rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-header .table-cell:last-child {
    border-right: none;
}

.table-row {
    display: grid;
    grid-template-columns: 120px 100px 200px 80px 100px 100px 100px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.table-row:hover {
    background-color: #f8f9fa;
}

.table-cell {
    padding: 12px 10px;
    border-right: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.9rem;
}

.table-cell:last-child {
    border-right: none;
}

/* 詳細画面スタイル */
.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.detail-title h2 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.detail-info {
    color: #666;
    line-height: 1.6;
}

.detail-info div {
    margin-bottom: 5px;
}

.items-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.items-section h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #3498db;
    font-size: 1.1rem;
    animation: pulse 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* ボタンスタイル追加 */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
}

/* ステータスバッジスタイル */
.status-pending {
    background-color: #f39c12;
    color: white;
}

.status-processing {
    background-color: #3498db;
    color: white;
}

.status-shipped {
    background-color: #9b59b6;
    color: white;
}

.status-completed {
    background-color: #27ae60;
    color: white;
}

/* レスポンシブ対応（テーブル） */
@media (max-width: 768px) {
    .table-header,
    .table-row {
        grid-template-columns: 1fr;
        display: block;
    }

    .table-cell {
        display: block;
        padding: 8px 15px;
        border-right: none;
        border-bottom: 1px solid #eee;
        text-align: left;
    }

    .table-cell:before {
        content: attr(data-label) ': ';
        font-weight: bold;
        color: #333;
        margin-right: 10px;
    }

    .table-header .table-cell:before {
        display: none;
    }

    .detail-header {
        flex-direction: column;
    }
}

/* ピッキング関連スタイル */
.picking-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.picking-section h3 {
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.2rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.form-actions .btn {
    flex: 1;
    min-width: 150px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-suffix {
    color: #666;
    font-weight: 500;
}

.qty-input {
    width: 120px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    text-align: center;
}

.qty-input:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 2px rgba(42, 82, 152, 0.2);
}

.picked-items {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.picked-items h3 {
    margin-bottom: 1rem;
    color: #333;
}

.status-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.status-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.status-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2a5298;
}

/* ローディング状態 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #2a5298;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   モバイルユーティリティ
   ============================================ */

/* iOS対応のビューポート高さ */
:root {
    --vh: 1vh;
}

/* モバイルデバイス用のスムーススクロール */
.mobile-device {
    -webkit-overflow-scrolling: touch;
}

.mobile-device .screen {
    min-height: auto;
    padding: 1rem;
}

/* iOS特有のスタイル調整 */
.ios-device input,
.ios-device select,
.ios-device textarea {
    -webkit-appearance: none;
    border-radius: 8px;
}

.ios-device .btn {
    -webkit-appearance: none;
}

/* タッチフィードバック */
.touchable {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.touchable:active {
    opacity: 0.7;
}

/* セーフエリア対応 */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}