/* ==========================================================================
   cell_checkin_web - 自助製卡機系統專用樣式表
   Design System: Luxury Dark Glassmorphism (iPad Optimized)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
    /* 色彩代碼 */
    --bg-dark: #0B0F17;
    --bg-card: rgba(18, 24, 38, 0.75);
    --bg-card-hover: rgba(28, 36, 56, 0.85);
    --border-color: rgba(255, 255, 255, 0.12);
    --border-highlight: rgba(56, 189, 248, 0.35);

    --primary-cyan: #38BDF8;
    --primary-gradient: linear-gradient(135deg, #0284C7 0%, #06B6D4 100%);
    --emerald-green: #10B981;
    --emerald-gradient: linear-gradient(135deg, #059669 0%, #10B981 100%);
    --amber-warning: #F59E0B;
    --rose-danger: #F43F5E;

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-dim: #64748B;

    --shadow-glow: 0 0 35px rgba(56, 189, 248, 0.15);
    --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.5);

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 全域重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: 'Outfit', 'Noto Sans TC', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.5) 0px, transparent 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* 主容器 */
#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
}

/* 頂部導航列 */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 28px;
    box-shadow: var(--shadow-card);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 8px 16px rgba(2, 132, 199, 0.3);
}

.brand-text h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #FFFFFF, #94A3B8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: #0284C7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.btn-logout {
    background: rgba(244, 63, 94, 0.15);
    color: var(--rose-danger);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-logout:hover {
    background: var(--rose-danger);
    color: white;
}

/* 視圖區塊控制 */
.view-panel {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    width: 100%;
}

.view-panel.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   登入視圖 (#login-view)
   ========================================================================== */
.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-card), var(--shadow-glow);
    text-align: center;
    margin-top: 40px;
}

.login-header {
    margin-bottom: 36px;
}

.login-header .logo-badge {
    width: 64px;
    height: 64px;
    background: var(--primary-gradient);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px auto;
    box-shadow: 0 12px 24px rgba(2, 132, 199, 0.35);
}

.login-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-field {
    width: 100%;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

.input-field:focus {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
    background: rgba(15, 23, 42, 0.85);
}

.btn-submit {
    width: 100%;
    padding: 16px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.3);
    margin-top: 10px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(2, 132, 199, 0.45);
}

/* ==========================================================================
   動作選擇視圖 (#action-view)
   ========================================================================== */
.action-container {
    width: 100%;
    max-width: 960px;
    margin: 20px auto;
    text-align: center;
}

.section-title {
    margin-bottom: 40px;
}

.section-title h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(to right, #FFFFFF, #CBD5E1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-title p {
    font-size: 1.05rem;
    color: var(--text-muted);
}

.action-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

@media (max-width: 768px) {
    .action-cards-grid {
        grid-template-columns: 1fr;
    }
}

.action-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    transition: var(--transition-smooth);
}

.action-card.checkin::before {
    background: var(--primary-gradient);
}

.action-card.checkout::before {
    background: var(--emerald-gradient);
}

.action-card:hover {
    transform: translateY(-8px);
    background: var(--bg-card-hover);
    border-color: var(--border-highlight);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.card-icon-wrap {
    width: 88px;
    height: 88px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    margin-bottom: 24px;
    transition: var(--transition-smooth);
}

.checkin .card-icon-wrap {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.checkout .card-icon-wrap {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.action-card:hover .card-icon-wrap {
    transform: scale(1.1);
}

.action-card h3 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.action-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

.btn-action-trigger {
    padding: 12px 28px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    color: white;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.checkin .btn-action-trigger {
    background: var(--primary-gradient);
}

.checkout .btn-action-trigger {
    background: var(--emerald-gradient);
}

/* ==========================================================================
   前鏡頭掃碼視圖模組 (#scanner-modal)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 11, 19, 0.88);
    backdrop-filter: blur(24px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.scanner-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    overflow: hidden;
    box-shadow: var(--shadow-card), 0 0 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

.scanner-header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scanner-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-close-modal:hover {
    background: rgba(244, 63, 94, 0.2);
    color: var(--rose-danger);
}

/* 前鏡頭視訊與掃描觀景窗 */
.camera-container {
    position: relative;
    width: 100%;
    height: 380px;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 鏡像翻轉 (Mirror Effect) 專為 iPad 前鏡頭 */
#webcam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.scanner-viewfinder {
    position: absolute;
    width: 240px;
    height: 240px;
    border: 2px solid rgba(56, 189, 248, 0.5);
    border-radius: 20px;
    box-shadow: 0 0 0 9999px rgba(11, 15, 23, 0.65);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* 觀景窗四角圖示 */
.scanner-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--primary-cyan);
    border-style: solid;
}

.corner-tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-top-left-radius: 16px; }
.corner-tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-top-right-radius: 16px; }
.corner-bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-bottom-left-radius: 16px; }
.corner-br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-bottom-right-radius: 16px; }

/* 動態掃描雷射紅光束 */
.scanner-laser {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary-cyan), #38BDF8, transparent);
    box-shadow: 0 0 15px #38BDF8, 0 0 8px #0284C7;
    animation: laserScan 2.2s infinite ease-in-out;
}

@keyframes laserScan {
    0% { top: 5%; }
    50% { top: 90%; }
    100% { top: 5%; }
}

.scanner-hint {
    padding: 16px;
    text-align: center;
    background: rgba(15, 23, 42, 0.9);
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* 隱藏輔助 Canvas 用於圖像影格擷取 */
#qr-canvas {
    display: none;
}

/* ==========================================================================
   卡片確認與製卡執行視圖模組 (#dispenser-modal)
   ========================================================================== */
.card-preview-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 620px;
    padding: 36px;
    box-shadow: var(--shadow-card), var(--shadow-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 實體 RFID 房卡擬真視覺元件 */
.rfid-card-display {
    width: 340px;
    height: 210px;
    background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.rfid-card-display::after {
    content: 'RFID SMART CARD';
    position: absolute;
    right: -20px;
    bottom: 20px;
    font-size: 2.2rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.03);
    transform: rotate(-15deg);
    pointer-events: none;
}

.card-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chip-icon {
    width: 44px;
    height: 32px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.chip-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.3);
}

.card-hotel-name {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary-cyan);
}

.card-room-num {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 8px 0;
    color: #FFFFFF;
}

.card-guest-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.guest-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* AWS 解密資料詳細明細清單 */
.decrypted-details-list {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 24px;
    margin-bottom: 24px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 0.95rem;
}

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

.detail-label {
    color: var(--text-muted);
}

.detail-val {
    font-weight: 600;
    color: var(--text-main);
}

/* 大尺寸製卡/寫卡執行按鈕 */
.btn-issue-card {
    width: 100%;
    padding: 18px;
    background: var(--emerald-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-issue-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 35px rgba(16, 185, 129, 0.5);
}

.btn-issue-card:disabled {
    background: #475569;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 製卡進度條 Overlay */
.dispensing-status-overlay {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}

.dispensing-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(56, 189, 248, 0.2);
    border-top: 4px solid var(--primary-cyan);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin-bottom: 20px;
}

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

/* 狀態 Badges */
.badge-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-status.encrypted {
    background: rgba(245, 158, 11, 0.2);
    color: #FBBF24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-status.decrypted {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}
