@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;800&family=JetBrains+Mono:wght@600&display=swap');

/* --- 顏色變數定義 --- */
:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --bg-main: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-title: #f8fafc;
    --text-body: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --border: rgba(255, 255, 255, 0.1);
}

body.light-mode {
    --bg-main: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-title: #1e293b;
    --text-body: #64748b;
    --input-bg: #ffffff;
    --border: rgba(0, 0, 0, 0.1);
}

/* --- 全域設定 --- */
* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-body);
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center; /* 保持垂直居中 */
    padding: 30px;
    transition: background-color 0.3s;
    font-size: 16px; /* 降回標準 16px，視覺更精緻 */
}

/* --- 佈局容器 (適中版 1080px) --- */
.app-container {
    width: 100%;
    max-width: 1080px; 
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
    gap: 30px;
}

/* --- 主面板設定 --- */
.main-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 32px; 
    padding: 45px; /* 縮小內距，避免過度空曠 */
}

h1 {
    font-size: 2.8rem; /* 從 3.5rem 調降，減少壓迫感 */
    font-weight: 800;
    margin: 0;
    color: var(--text-title);
    letter-spacing: -1.5px;
    line-height: 1.1;
}

.subtitle {
    font-size: 1.05rem;
    margin: 12px 0 35px 0;
    line-height: 1.6;
}

/* --- 輸入框與按鈕 --- */
input[type="url"] {
    width: 100%;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 18px 24px;
    color: var(--text-title);
    font-size: 1.1rem;
    transition: all 0.3s;
    outline: none;
}

input[type="url"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-generate {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 18px;
    width: 100%;
    font-size: 1.15rem; 
    font-weight: 700;
    cursor: pointer;
    margin-top: 15px;
    box-shadow: 0 8px 16px var(--primary-glow);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-generate:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* --- 結果區塊 --- */
.result-card {
    margin-top: 35px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 24px;
    padding: 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 25px;
    border: 1.5px solid var(--primary);
}

.qr-code-box {
    background: white;
    padding: 12px;
    border-radius: 16px;
    flex-shrink: 0;
}

.short-link-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem; 
    color: var(--primary);
    font-weight: 800;
    display: block;
    margin-bottom: 12px;
    word-break: break-all;
}

/* --- 側邊歷史紀錄 --- */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.history-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    transition: transform 0.3s;
}

.history-card:hover {
    transform: translateX(5px);
}

.history-card a {
    font-size: 1.1rem;
    font-family: 'JetBrains Mono';
    text-decoration: none;
    color: var(--primary);
    font-weight: 700;
}

.history-full-url {
    font-size: 0.8rem;
    margin-top: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-body);
}

/* --- 清空彈窗深度美化 --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; 
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75); /* 稍微深一點的背景遮罩 */
    backdrop-filter: blur(10px);    /* 強調毛玻璃感 */
    display: flex; 
    justify-content: center; 
    align-items: center;
    z-index: 9999;
    opacity: 0; 
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 40px;
    border-radius: 32px; /* 與主面板圓角一致 */
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-title);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.modal-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-body);
    margin-bottom: 30px;
}

/* 彈窗按鈕佈局 */
.modal-buttons {
    display: flex;
    gap: 15px;
}

.btn-modal {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-cancel {
    background: var(--input-bg);
    color: var(--text-title);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-confirm-danger {
    background: #ef4444; /* 警告紅 */
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-confirm-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.4);
}

/* --- 響應式修正 --- */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        max-width: 700px;
    }
    body { padding: 30px 20px; }
}

.theme-toggle {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 1000;
    background: var(--card-bg);
    color: var(--text-title);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.hidden { display: none !important; }