/**
 * 簡易動作検証デモ画面 スタイルシート
 * HT（ハンディターミナル）向けモバイルファースト設計
 * 既存HT画面スタイルを踏襲
 */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background-color: #f5f5f5;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ===========================
   コンテナ
   =========================== */
.ht-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background-color: #fff;
}

/* ===========================
   ヘッダー
   =========================== */
.ht-header {
    flex-shrink: 0;
    padding: 12px 16px;
    background-color: #0066cc;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ht-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 4px;
}

.ht-plan-info {
    font-size: 14px;
    opacity: 0.9;
}

.plan-number {
    font-weight: 500;
}

/* ===========================
   メインコンテンツ
   =========================== */
.ht-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* プロンプトエリア */
.prompt-area {
    margin-bottom: 16px;
    text-align: center;
}

.prompt-label {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    line-height: 1.6;
}

/* 入力エリア */
.input-area {
    margin-bottom: 16px;
}

.input-group {
    margin-bottom: 12px;
}

.input-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
}

.ht-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.ht-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.ht-input::placeholder {
    color: #aaa;
}

/* ヒントエリア */
.hint-area {
    margin-top: 16px;
    text-align: center;
}

.hint-text {
    font-size: 14px;
    color: #888;
}

/* ===========================
   照合状況エリア
   =========================== */
.status-area {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    margin-bottom: 16px;
    background-color: #e6f2ff;
    border-radius: 8px;
}

.status-item {
    text-align: center;
}

.status-label {
    font-size: 12px;
    color: #666;
    display: block;
}

.status-value {
    font-size: 28px;
    font-weight: bold;
    color: #0066cc;
}

.status-unit {
    font-size: 14px;
    color: #666;
}

/* ===========================
   照合結果表示
   =========================== */
.match-result {
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
}

.match-result.match-success {
    background-color: #d4edda;
    color: #155724;
    border: 2px solid #28a745;
}

.match-result.match-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 2px solid #dc3545;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* ===========================
   エラー・成功メッセージ
   =========================== */
.error-message {
    padding: 12px 16px;
    margin-bottom: 12px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    font-size: 14px;
}

.success-message {
    padding: 12px 16px;
    margin-bottom: 12px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    font-size: 14px;
}

/* ===========================
   履歴エリア
   =========================== */
.history-area {
    margin-top: 16px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.history-title {
    font-size: 14px;
    font-weight: bold;
    color: #666;
    margin-bottom: 8px;
}

.history-list {
    max-height: 120px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 14px;
    border-bottom: 1px solid #eee;
}

.history-item:last-child {
    border-bottom: none;
}

.history-number {
    color: #888;
    min-width: 40px;
}

.history-lot {
    flex: 1;
    color: #333;
    font-size: 13px;
}

.history-quantity {
    font-weight: bold;
    color: #0066cc;
}

/* ===========================
   フッター
   =========================== */
.ht-footer {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

.ht-button {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.ht-button:active {
    transform: scale(0.98);
}

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

.ht-button-primary {
    background-color: #0066cc;
    color: #fff;
}

.ht-button-primary:active:not(:disabled) {
    background-color: #0052a3;
}

.ht-button-success {
    background-color: #28a745;
    color: #fff;
}

.ht-button-success:active:not(:disabled) {
    background-color: #1e7e34;
}

.ht-button-tertiary {
    background-color: #6c757d;
    color: #fff;
}

.ht-button-tertiary:active:not(:disabled) {
    background-color: #545b62;
}

/* ===========================
   モーダル
   =========================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 16px;
    background-color: #0066cc;
    color: #fff;
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
    margin: 0;
}

.modal-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

/* 結果サマリー */
.result-summary {
    margin-bottom: 16px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

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

.result-label {
    color: #666;
    font-size: 14px;
}

.result-value {
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

/* 履歴詳細 */
.result-history {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #eee;
}

.history-detail {
    max-height: 150px;
    overflow-y: auto;
}

.history-detail-item {
    display: inline-block;
    padding: 4px 10px;
    margin: 4px;
    background-color: #e6f2ff;
    border-radius: 16px;
    font-size: 14px;
}

/* ===========================
   保存済み検品履歴（ホーム画面）
   =========================== */
.saved-history-area {
    margin-top: 20px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.saved-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.saved-history-title {
    font-size: 14px;
    font-weight: bold;
    color: #495057;
    margin: 0;
}

.saved-history-count {
    font-size: 12px;
    color: #6c757d;
    background-color: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
}

.saved-history-list {
    max-height: 200px;
    overflow-y: auto;
}

.saved-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    background-color: #fff;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: background-color 0.2s;
}

.saved-history-item:hover {
    background-color: #e6f2ff;
}

.saved-history-item:last-child {
    margin-bottom: 0;
}

.saved-history-info {
    flex: 1;
}

.saved-history-code {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.saved-history-date {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

.saved-history-stats {
    text-align: right;
}

.saved-history-quantity {
    font-weight: bold;
    color: #0066cc;
    font-size: 14px;
}

.saved-history-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 2px;
    display: inline-block;
}

.saved-history-status.pending {
    background-color: #fff3cd;
    color: #856404;
}

.saved-history-status.synced {
    background-color: #d4edda;
    color: #155724;
}

.saved-history-empty {
    text-align: center;
    color: #6c757d;
    font-size: 13px;
    padding: 20px;
}

/* ===========================
   同期ボタン・オンライン状態
   =========================== */
.sync-status-area {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.online-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #28a745;
}

.online-indicator.offline {
    background-color: #dc3545;
}

.sync-button {
    position: relative;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.sync-button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.sync-button:active {
    background-color: rgba(255, 255, 255, 0.4);
}

.sync-button.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

.sync-icon {
    font-size: 20px;
    font-weight: bold;
}

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

.sync-pending-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background-color: #dc3545;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-link {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color 0.2s;
}

.admin-link:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* ヘッダーをrelativeに */
.ht-header {
    position: relative;
}

/* ===========================
   レスポンシブ対応
   =========================== */
@media (min-width: 768px) {
    .ht-container {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    }
}
