/* ==========================================================================
   MQRT Portal Modern Glassmorphism Stylesheet
   Version: 2.0
   ========================================================================== */

:root {
    --bg-base: #0a0e17;
    --bg-card: rgba(18, 24, 38, 0.75);
    --bg-card-hover: rgba(28, 38, 60, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(56, 189, 248, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #38bdf8;
    --accent-purple: #a855f7;
    --accent-green: #22c55e;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* 背景動態微光模糊光暈 */
.background-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: #0284c7;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 450px;
    height: 450px;
    background: #7c3aed;
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: #059669;
    top: 40%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 40px) scale(1.1); }
}

/* 主容器 */
.portal-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* 頂部標頭 */
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.brand-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #0284c7, #2563eb);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
    letter-spacing: -0.5px;
}

.logo-text { color: #ffffff; }
.logo-accent { color: #38bdf8; }

.portal-title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.portal-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

/* 頂部右側群組 */
.header-right-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-admin-gear {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    backdrop-filter: blur(12px);
    transition: var(--transition-fast);
}

.btn-admin-gear:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-blue);
    transform: translateY(-2px);
}

.btn-admin-gear .gear-icon {
    font-size: 1.1rem;
    transition: transform 0.4s ease;
}

.btn-admin-gear:hover .gear-icon {
    transform: rotate(90deg);
}

/* 狀態卡片 */
.server-status-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    text-align: right;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-green);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.live-clock {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-family: monospace;
}

/* 工具列（搜尋與分類標籤） */
.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.search-box {
    position: relative;
    max-width: 600px;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

#card-search {
    width: 100%;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 2.8rem 0.85rem 2.8rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
}

#card-search:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.clear-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
}

.pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.pill.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #041226;
    font-weight: 600;
}

/* 卡片網格 */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

/* 卡片設計 */
.portal-card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-bounce), border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    cursor: pointer;
}

.portal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.6), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.portal-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.portal-card:hover::before {
    opacity: 1;
}

/* 標籤 Badge */
.card-badge {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    letter-spacing: 0.2px;
}

.badge-active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-info {
    background: rgba(168, 85, 247, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-purple {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-lock {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* 圖示 */
.card-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.icon-ai { background: rgba(56, 189, 248, 0.1); border-color: rgba(56, 189, 248, 0.2); }
.icon-map { background: rgba(168, 85, 247, 0.1); border-color: rgba(168, 85, 247, 0.2); }
.icon-care { background: rgba(34, 197, 94, 0.1); border-color: rgba(34, 197, 94, 0.2); }
.icon-task { background: rgba(234, 179, 8, 0.1); border-color: rgba(234, 179, 8, 0.2); }
.icon-lottery { background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.2); }
.icon-iot { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); }

/* 卡片內容 */
.card-content {
    flex: 1;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

/* 底部路徑與箭頭 */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.service-path {
    font-size: 0.8rem;
    font-family: monospace;
    color: var(--text-muted);
}

.arrow-icon, .btn-unlock {
    color: var(--accent-blue);
    font-size: 0.95rem;
    font-weight: 600;
    transition: transform var(--transition-fast);
}

.portal-card:hover .arrow-icon {
    transform: translateX(4px);
}

/* 受保護卡片特殊樣式 */
.card-protected {
    border-color: rgba(245, 158, 11, 0.25);
}

.card-protected:hover {
    border-color: var(--accent-amber);
}

.card-protected .btn-unlock {
    color: var(--accent-amber);
}

/* 查無結果 */
.no-results-box {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* 骨架載入中 */
.cards-loading-skeleton {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: 1.05rem;
}

.footer-admin-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-admin-link:hover {
    color: var(--accent-blue);
}

/* 頁尾 */
.portal-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.footer-info {
    display: flex;
    gap: 1rem;
}

/* Modal 彈出視窗 (PIN 驗證) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-card {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: 2.2rem;
    max-width: 420px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.lock-icon-circle {
    width: 52px;
    height: 52px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.pin-input-group {
    margin-bottom: 0.75rem;
}

#pin-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    color: #ffffff;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 6px;
    outline: none;
    transition: var(--transition-fast);
}

#pin-input:focus {
    border-color: var(--accent-amber);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.pin-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-cancel, .btn-confirm {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-confirm {
    background: var(--accent-amber);
    color: #1a1002;
}

.btn-confirm:hover {
    background: #fbbf24;
}

/* 震動錯誤動畫 */
.shake {
    animation: shakeAnim 0.4s ease-in-out;
}

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

/* 手機 RWD 適應 */
@media (max-width: 768px) {
    .portal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.25rem;
    }
    
    .server-status-card {
        width: 100%;
        text-align: left;
    }
    
    .status-indicator {
        justify-content: flex-start;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .portal-footer {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    .footer-info {
        flex-direction: column;
        gap: 0.3rem;
    }
}
