/**
 * Smart Photo Upload - CSS 樣式
 * 拖放上傳介面、預覽、進度條等樣式
 * 
 * @package LineLoginPush
 * @subpackage SmartPhotoUpload
 * @since 2.0
 */

/* ==========================================================================
   基本容器樣式
   ========================================================================== */

.smart-photo-upload-container {
    max-width: 800px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.smart-photo-upload-error {
    background: #ffeaa7;
    color: #d63031;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

/* ==========================================================================
   拖放上傳區域
   ========================================================================== */

.drag-drop-area {
    border: 3px dashed #ddd;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #fafafa;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drag-drop-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.1);
}

.drag-drop-area.drag-over {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea15, #764ba215);
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.drag-drop-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.drag-drop-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
}

.drag-drop-hint {
    font-size: 14px;
    color: #666;
    margin: 0 0 12px 0;
}

.upload-requirements {
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 6px;
    color: #555;
}

.upload-requirements small {
    font-size: 12px;
    line-height: 1.4;
}

/* 按鈕樣式 */
.drag-drop-area .btn {
    pointer-events: auto;
    margin: 0 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* ==========================================================================
   預覽容器
   ========================================================================== */

.upload-preview-container {
    margin-top: 30px;
}

.upload-preview-container h4 {
    color: #333;
    font-size: 16px;
    margin-bottom: 15px;
    font-weight: 600;
}

.upload-preview-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* 預覽項目 */
.preview-item {
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.preview-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.preview-item.status-uploading {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.preview-item.status-uploaded {
    border-color: #00b894;
    box-shadow: 0 2px 8px rgba(0, 184, 148, 0.2);
}

.preview-item.status-error {
    border-color: #e74c3c;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2);
}

/* 預覽縮圖 */
.preview-thumbnail {
    height: 160px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.preview-image {
    transform-origin: center center;
}

.preview-thumbnail:hover img {
    transform: scale(1.05);
}

.preview-placeholder {
    font-size: 48px;
    opacity: 0.3;
}

/* 預覽覆蓋層 */
.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    gap: 8px;
}

.preview-thumbnail:hover .preview-overlay {
    opacity: 1;
}

.preview-rotate-btn,
.preview-zoom-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.preview-rotate-btn:hover,
.preview-zoom-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 預覽資訊 */
.preview-info {
    padding: 16px;
    position: relative;
}

.preview-filename {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-filesize,
.preview-dimensions {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.preview-dimensions {
    font-family: monospace;
}

.preview-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

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

.preview-status.status-uploading {
    background: #e1f5fe;
    color: #0277bd;
}

.preview-status.status-uploaded {
    background: #d4edda;
    color: #155724;
}

.preview-status.status-error {
    background: #f8d7da;
    color: #721c24;
}

/* 預覽操作按鈕 */
.preview-actions {
    position: absolute;
    top: 8px;
    right: 8px;
}

.preview-delete-btn {
    background: rgba(231, 76, 60, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.preview-delete-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* 預覽進度條 */
.preview-progress {
    margin-top: 8px;
}

.preview-progress-bar {
    height: 4px;
    background: #eee;
    border-radius: 2px;
    overflow: hidden;
}

.preview-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* ==========================================================================
   上傳進度條
   ========================================================================== */

.upload-progress-container {
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

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

.upload-progress-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.cancel-upload-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-upload-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.upload-progress-bar {
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    border-radius: 4px;
    position: relative;
}

.upload-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite linear;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-stats {
    font-size: 12px;
    color: #666;
    text-align: center;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.progress-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.progress-stat-icon {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   圖片預覽模態框
   ========================================================================== */

.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.image-modal-container {
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

.image-modal-header {
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 40px);
}

.image-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: #666;
}

.image-modal-close:hover {
    background: #e9ecef;
    color: #333;
}

.image-modal-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    min-height: 300px;
    max-height: 60vh;
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    transform-origin: center center;
}

.image-modal-controls {
    padding: 16px 24px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-rotate-btn,
.modal-zoom-in-btn,
.modal-zoom-out-btn,
.modal-reset-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.modal-rotate-btn:hover,
.modal-zoom-in-btn:hover,
.modal-zoom-out-btn:hover,
.modal-reset-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 模態框響應式設計 */
@media (max-width: 768px) {
    .image-modal-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .image-modal-header {
        padding: 16px 20px;
    }
    
    .image-modal-header h3 {
        font-size: 16px;
    }
    
    .image-modal-content {
        padding: 16px;
        max-height: 50vh;
    }
    
    .image-modal-controls {
        padding: 12px 16px;
        gap: 8px;
    }
    
    .modal-rotate-btn,
    .modal-zoom-in-btn,
    .modal-zoom-out-btn,
    .modal-reset-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ==========================================================================
   相機模態框
   ========================================================================== */

.camera-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.camera-modal-container {
    max-width: 90vw;
    max-height: 90vh;
    background: #1a1a1a;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
    color: white;
}

.camera-modal-header {
    padding: 20px 24px;
    background: #2a2a2a;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.camera-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: #ccc;
}

.camera-modal-close:hover {
    background: #3a3a3a;
    color: white;
}

.camera-modal-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #000;
    min-height: 300px;
    max-height: 60vh;
}

#camera-video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background: #222;
}

.camera-modal-controls {
    padding: 20px 24px;
    background: #2a2a2a;
    border-top: 1px solid #333;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.camera-capture-btn,
.camera-switch-btn,
.camera-cancel-btn {
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.camera-capture-btn {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.camera-capture-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.camera-switch-btn {
    background: #6c757d;
    color: white;
}

.camera-switch-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.camera-cancel-btn {
    background: #6c757d;
    color: white;
}

.camera-cancel-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* 相機模態框響應式設計 */
@media (max-width: 768px) {
    .camera-modal-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .camera-modal-header {
        padding: 16px 20px;
    }
    
    .camera-modal-header h3 {
        font-size: 16px;
    }
    
    .camera-modal-content {
        padding: 16px;
        max-height: 50vh;
        min-height: 250px;
    }
    
    .camera-modal-controls {
        padding: 16px 20px;
        gap: 8px;
    }
    
    .camera-capture-btn,
    .camera-switch-btn,
    .camera-cancel-btn {
        padding: 10px 16px;
        font-size: 13px;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .camera-modal-content {
        min-height: 200px;
        padding: 12px;
    }
    
    .camera-modal-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .camera-capture-btn,
    .camera-switch-btn,
    .camera-cancel-btn {
        width: 100%;
        padding: 12px;
        font-size: 14px;
    }
}

/* ==========================================================================
   訊息提示
   ========================================================================== */

.upload-message {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 500;
}

.upload-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.upload-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.upload-message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.upload-message-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.message-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    margin-left: 16px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.message-close:hover {
    opacity: 1;
}

/* ==========================================================================
   響應式設計與裝置特定樣式
   ========================================================================== */

/* 裝置類型特定樣式 */
.smart-photo-upload-container.is-mobile .drag-drop-area {
    min-height: 120px;
    padding: 20px 16px;
}

.smart-photo-upload-container.is-mobile .btn {
    padding: 12px 20px;
    font-size: 14px;
    width: 100%;
    max-width: 200px;
    margin: 6px auto;
}

.smart-photo-upload-container.is-tablet .drag-drop-area {
    min-height: 160px;
    padding: 30px 20px;
}

.smart-photo-upload-container.has-touch .preview-item {
    /* 觸控設備的預覽項目優化 */
    margin-bottom: 4px;
}

.smart-photo-upload-container.has-touch .preview-delete-btn,
.smart-photo-upload-container.has-touch .preview-rotate-btn,
.smart-photo-upload-container.has-touch .preview-zoom-btn {
    /* 觸控設備的按鈕優化 */
    min-width: 44px;
    min-height: 44px;
    font-size: 16px;
}

/* 視窗大小類別 */
.smart-photo-upload-container.viewport-xs .upload-preview-list {
    grid-template-columns: 1fr;
    gap: 12px;
}

.smart-photo-upload-container.viewport-sm .upload-preview-list {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.smart-photo-upload-container.viewport-md .upload-preview-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.smart-photo-upload-container.viewport-lg .upload-preview-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

/* 緊湊統計模式 */
.progress-stats.compact-stats {
    flex-direction: column;
    text-align: left;
    gap: 4px;
}

.progress-stats.compact-stats .progress-stat {
    font-size: 11px;
}

/* 觸控優化 */
.smart-photo-upload-container.touch-optimized .drag-drop-area {
    /* 增大觸控區域 */
    padding: 24px 20px;
}

.smart-photo-upload-container.touch-optimized .btn {
    /* 符合觸控標準的最小尺寸 */
    min-height: 44px;
    min-width: 88px;
}

/* ==========================================================================
   響應式設計 (傳統斷點)
   ========================================================================== */

/* 平板版 */
@media (max-width: 1024px) {
    .smart-photo-upload-container {
        margin: 16px;
    }
    
    .drag-drop-area {
        padding: 30px 16px;
        min-height: 180px;
    }
    
    .upload-icon {
        font-size: 40px;
        margin-bottom: 12px;
    }
    
    .drag-drop-text {
        font-size: 16px;
    }
    
    .upload-preview-list {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
    }
}

/* 手機版 */
@media (max-width: 768px) {
    .smart-photo-upload-container {
        margin: 12px;
    }
    
    .drag-drop-area {
        padding: 24px 12px;
        min-height: 150px;
    }
    
    .upload-icon {
        font-size: 32px;
        margin-bottom: 8px;
    }
    
    .drag-drop-text {
        font-size: 14px;
    }
    
    .drag-drop-hint {
        font-size: 12px;
    }
    
    .drag-drop-area .btn {
        padding: 10px 18px;
        font-size: 12px;
        margin: 4px;
        display: block;
        width: 100%;
        max-width: 200px;
        margin: 4px auto;
    }
    
    .upload-preview-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .preview-item {
        max-width: 100%;
    }
    
    .preview-thumbnail {
        height: 120px;
    }
    
    .preview-info {
        padding: 12px;
    }
    
    .upload-message {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* 小手機版 */
@media (max-width: 480px) {
    .drag-drop-area {
        padding: 20px 8px;
        min-height: 120px;
    }
    
    .upload-icon {
        font-size: 28px;
        margin-bottom: 6px;
    }
    
    .drag-drop-text {
        font-size: 13px;
    }
    
    .drag-drop-hint {
        font-size: 11px;
    }
    
    .preview-thumbnail {
        height: 100px;
    }
    
    .preview-info {
        padding: 10px;
    }
    
    .preview-filename {
        font-size: 13px;
    }
    
    .preview-filesize {
        font-size: 11px;
    }
}

/* ==========================================================================
   無障礙設計
   ========================================================================== */

/* 高對比模式 */
@media (prefers-contrast: high) {
    .drag-drop-area {
        border-color: #000;
        background: #fff;
    }
    
    .drag-drop-area:hover,
    .drag-drop-area.drag-over {
        border-color: #000;
        background: #f0f0f0;
    }
    
    .btn-primary {
        background: #000;
        color: #fff;
    }
    
    .btn-secondary {
        background: #fff;
        color: #000;
        border-color: #000;
    }
}

/* 動畫縮減模式 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .upload-progress-fill::after {
        animation: none;
    }
}

/* 聚焦樣式 */
.drag-drop-area:focus-within,
.btn:focus,
.preview-delete-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ==========================================================================
   列印樣式
   ========================================================================== */

@media print {
    .smart-photo-upload-container {
        display: none;
    }
}