/**
 * QRスキャナー機能スタイルシート (Safari最適化)
 */

/* カメラセクション */
.camera-section {
    text-align: center;
    padding: 2rem;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.camera-area {
    width: 100%;
    max-width: 500px;
    height: 300px;
    background: #1f2937;
    border-radius: 8px;
    margin: 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

/**
 * Safari最適化QRスキャナーCSS
 * safari_qr_with_url_redirect.htmlのスタイルを移植・最適化
 */

/* QRスキャン関連の基本スタイル */
.qr-video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
    max-height: 400px;
    margin: 1rem 0;
}

.qr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* スキャンガイド */
.qr-scan-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    border: 2px dashed rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    pointer-events: none;
}

/* スキャンコーナー */
.qr-scan-corners {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    pointer-events: none;
}

.qr-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #60a5fa;
}

.qr-corner-tl { 
    top: -3px; 
    left: -3px; 
    border-right: none; 
    border-bottom: none; 
}

.qr-corner-tr { 
    top: -3px; 
    right: -3px; 
    border-left: none; 
    border-bottom: none; 
}

.qr-corner-bl { 
    bottom: -3px; 
    left: -3px; 
    border-right: none; 
    border-top: none; 
}

.qr-corner-br { 
    bottom: -3px; 
    right: -3px; 
    border-left: none; 
    border-top: none; 
}

/* スキャンアニメーション */
@keyframes scanning {
    0% { background-position: 0% 0%; }
    100% { background-position: 0% 100%; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-green {
    0%, 100% { background-color: #16a34a; }
    50% { background-color: #22c55e; }
}

@keyframes calibration-pulse {
    0%, 100% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.qr-scanning-line {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    background: linear-gradient(180deg, transparent 0%, transparent 45%, #60a5fa 50%, transparent 55%, transparent 100%);
    background-size: 100% 200%;
    animation: scanning 2s linear infinite;
    border-radius: 12px;
    pointer-events: none;
}

/* Safari最適化キャリブレーション表示 */
.qr-calibration-indicator {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10;
}

.qr-calibration-content {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    animation: calibration-pulse 1.5s ease-in-out infinite;
}

/* 成功オーバーレイ */
.qr-success-overlay {
    position: absolute;
    inset: 0;
    background: rgba(22, 163, 74, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 10;
    animation: pulse-green 0.8s ease-in-out;
}

.qr-success-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

/* エラーオーバーレイ */
.qr-error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(220, 38, 38, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
    z-index: 10;
}

/* ステータス表示 */
.qr-status {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 5;
}

/* デバッグ情報 */
.qr-debug-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    max-width: 200px;
    z-index: 5;
}

.qr-debug-info div {
    margin-bottom: 2px;
}

/* コントロールボタン */
.qr-controls {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
    justify-content: center;
}

.qr-controls .btn {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

/* 結果表示 */
.qr-result-display {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.qr-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.qr-result-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.qr-result-data {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
    color: #333;
}

/* カメラセクション */
.camera-section {
    margin: 1.5rem 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .qr-scan-guide,
    .qr-scan-corners,
    .qr-scanning-line {
        width: 180px;
        height: 180px;
    }
    
    .qr-corner {
        width: 25px;
        height: 25px;
        border-width: 2px;
    }
    
    .qr-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .qr-controls .btn {
        min-width: auto;
        max-width: none;
    }
    
    .qr-calibration-content {
        padding: 1.5rem;
        font-size: 0.9rem;
    }
    
    .qr-debug-info {
        font-size: 10px;
        max-width: 150px;
        top: 5px;
        right: 5px;
    }
}

/* Safari特有の調整 */
@supports (-webkit-appearance: none) {
    .qr-video {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    .qr-video-container {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* 高解像度画面対応 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .qr-corner {
        border-width: 2px;
    }
    
    .qr-scan-guide {
        border-width: 1px;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .qr-result-display {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .qr-result-title {
        color: #e2e8f0;
    }
    
    .qr-result-data {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}

/* アニメーション */
@keyframes qr-scanning {
    0% { background-position: 0% 0%; }
    100% { background-position: 0% 100%; }
}

@keyframes qr-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes qr-pulse-green {
    0%, 100% { background-color: #16a34a; }
    50% { background-color: #22c55e; }
}

.qr-scanning-line {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px;
    height: 240px;
    background: linear-gradient(180deg, transparent 0%, transparent 45%, #60a5fa 50%, transparent 55%, transparent 100%);
    background-size: 100% 200%;
    animation: qr-scanning 2s linear infinite;
    border-radius: 12px;
    pointer-events: none;
}

.qr-calibrating {
    animation: qr-pulse 1s ease-in-out infinite;
}

.qr-pulse-green {
    animation: qr-pulse-green 1s ease-in-out infinite;
}

/* ビデオコンテナ */
.qr-video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.qr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* デバッグ情報 */
.qr-debug-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
    max-width: 200px;
}

/* ステータス表示 */
.qr-status {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* 調整インジケーター */
.qr-calibration-indicator {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

/* 成功オーバーレイ */
.qr-success-overlay {
    position: absolute;
    inset: 0;
    background: rgba(34, 197, 94, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
}

.qr-success-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* エラーオーバーレイ */
.qr-error-overlay {
    position: absolute;
    inset: 0;
    background: rgba(239, 68, 68, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    padding: 20px;
    border-radius: 12px;
}

/* コントロール */
.qr-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* 結果表示 */
.qr-result-display {
    background: #f0fdf4;
    border: 2px solid #22c55e;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    display: none;
}

.qr-result-display.show {
    display: block;
}

.qr-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.qr-result-title {
    font-size: 18px;
    font-weight: 600;
    color: #15803d;
}

.qr-result-data {
    background: white;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 12px;
    font-family: monospace;
    font-size: 14px;
    word-break: break-all;
    color: #374151;
}

/* 統計情報表示 */
.qr-stats {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-top: 1rem;
}

.qr-stats .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    text-align: center;
}

.qr-stats .stat-value {
    font-weight: bold;
    font-size: 1.25rem;
    color: #1f2937;
}

.qr-stats .stat-label {
    color: #6b7280;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* アラート・通知 */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.alert-info {
    background: #dbeafe;
    border: 1px solid #3b82f6;
    color: #1e3a8a;
}

.alert-info strong {
    color: #1e40af;
    display: block;
    margin-bottom: 0.5rem;
}

.alert-info ul {
    margin: 0.5rem 0 0 1.5rem;
    font-size: 0.875rem;
}

.alert-info li {
    margin: 0.25rem 0;
}

/* フレックスユーティリティ */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.gap-3 {
    gap: 0.75rem;
}

/* Safari最適化表示 */
.safari-optimized-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}