/*
 * 檔案用途：這是所有工具頁面的主要樣式表，定義了通用的外觀、變數和響應式設計。
 * This file is the main stylesheet for all tool pages, defining the common appearance, variables, and responsive design.
 */

/* :root 定義了全域 CSS 變數，方便統一管理顏色和字體 */
:root {
    --bg-color: #1a1a2e;
    /* 主要背景色 */
    --container-bg: rgba(27, 38, 59, 0.7);
    /* 容器背景色 (帶透明度) */
    --text-color: #e0e0e0;
    /* 主要文字顏色 */
    --accent-color: #00FFFF;
    /* 強調色 (青色) */
    --accent-dark: #00BFFF;
    /* 深一點的強調色 */
    --border-color: #3f51b5;
    /* 邊框顏色 */
    --input-bg: #2b3a55;
    /* 輸入框背景色 */
    --error-color: #ff6b6b;
    /* 錯誤訊息顏色 */
    --success-color: #2ecc71;
    /* 成功訊息顏色 */
    --code-color: #00FFD1;
    /* 程式碼文字顏色 */
    --font-main: 'Noto Sans TC', sans-serif;
    /* 主要字體 */
    --font-mono: 'Roboto Mono', monospace;
    /* 等寬字體 (用於程式碼) */
}

/* 全域重設 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 60px 20px 20px 20px;
    /* 為固定頂部欄位增加上邊距 */
    box-sizing: border-box;
    overflow-x: hidden;
    background-image: url('../images/wallpaper-new.svg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

body.is-desktop {
    display: block;
}

/* 移除舊的偽元素背景效果，避免衝突，或保留作為覆蓋紋理。
   使用者要求使用固定的彩色圖片，因此移除複雜的漸變和動畫，只保留桌布。 */
body::before {

    to {
        background-position: 300px 300px, 315px 315px;
    }
}

/* 主要內容容器 */
.container {
    width: 100%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    border: 1px solid rgba(255, 255, 255, 0.18);
    text-align: center;
    position: relative;
    overflow: hidden;
    /* 頁尾修正 */
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
}

/* RWD: 當螢幕寬度小於 600px 時，減少 padding */
/* RWD: 當螢幕寬度小於 600px 時，減少 padding */
@media (max-width: 600px) {
    body {
        padding: 50px 0 120px 0;
        /* 為頂部欄位增加上邊距，底部增加邊距以避開 Dock */
        /* 移除內邊距以達到滿版寬度 */
    }

    .container {
        padding: 20px;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        /* 移除圓角以達到滿版寬度 */
        border-left: none;
        border-right: none;
        min-height: 100vh;
        /* 確保完整高度 */
    }
}

/* 標題樣式 */
h1,
h2,
h3 {
    color: var(--accent-color);
    text-align: center;
    font-weight: 700;
}

h1 {
    font-size: 2em;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(var(--accent-color), 0.5);
}

/* 表單通用樣式 */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--accent-color);
    font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: var(--font-mono);
    box-sizing: border-box;
    background-color: var(--input-bg);
    color: var(--code-color);
    box-shadow: inset 0 0 8px rgba(var(--accent-color), 0.1);
    transition: all 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-color);
    box-shadow: inset 0 0 12px rgba(var(--accent-color), 0.3), 0 0 10px rgba(var(--accent-color), 0.3);
    outline: none;
}

textarea {
    resize: vertical;
    /* 允許使用者垂直調整大小 */
    min-height: 100px;
}

/* 按鈕通用樣式 */
button,
.btn {
    background: var(--accent-color);
    color: var(--bg-color);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

button:hover,
.btn:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* 結果顯示框 */
.result-box {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 20px;
    font-family: var(--font-mono);
    word-break: break-all;
    position: relative;
    min-height: 50px;
}

/* 複製按鈕 */
.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 0.8em;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 頁腳 */
.footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid rgba(var(--border-color), 0.5);
    font-size: 0.9em;
    color: var(--text-color);
    opacity: 0.7;
}

.footer p {
    margin: 5px 0 0 0;
}

/* 返回首頁連結 */
.back-link {
    color: var(--accent-color);
    text-decoration: none;
    display: block;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-dark);
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    width: 100%;
    min-height: 30px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* 允許多行換行 */
    padding: 5px 20px;
    /* 為換行調整內邊距 */
    z-index: 1001;
    font-size: 14px;
    color: #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-bar-logo {
    height: 20px;
    width: 20px;
}

.top-bar-title {
    font-weight: bold;
    font-family: 'Noto Sans TC', sans-serif;
}

.top-bar-right {
    display: flex;
    gap: 15px;
    font-family: 'Roboto Mono', monospace;
    align-items: center;
}

.install-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
}

.install-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.install-btn .icon {
    font-size: 1.2em;
}

/* Top Bar RWD */
@media (max-width: 600px) {
    .top-bar {
        padding: 5px 10px;
        height: auto;
    }

    .top-bar-title {
        display: none;
        /* 在小螢幕上隱藏標題 */
    }

    .top-bar-right #clock-date {
        display: none;
        /* 在小螢幕上隱藏日期，保留時間 */
    }

    .dropbtn {
        padding: 5px;
        /* 減少內邊距 */
    }
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background-color: transparent;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Noto Sans TC', sans-serif;
    padding: 5px 10px;
    border-radius: 4px;
}

.dropbtn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: rgba(40, 40, 40, 0.95);
    backdrop-filter: blur(10px);
    min-width: 200px;
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.5);
    z-index: 1;
    border-radius: 8px;
    padding: 5px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    top: 30px;
}

.dropdown-content a {
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    display: block;
    font-size: 13px;
}

.dropdown-content a:hover {
    background-color: var(--accent-color);
    color: black;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-category {
    padding: 8px 16px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    pointer-events: none;
}

.dropdown-divider {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

/* Desktop Icons Layout */
.desktop {
    position: fixed;
    top: 30px;
    /* 頂部欄下方 */
    right: 20px;
    bottom: 100px;
    /* Dock 上方 */
    display: flex;
    flex-direction: row-reverse;
    /* 欄位由右至左排列 */
    align-items: flex-start;
    gap: 10px;
    z-index: 1;
    pointer-events: none;
    /* 允許點擊穿透空白區域 */
}

@media (max-width: 600px) {
    .desktop {
        bottom: 120px;
        /* 在手機上增加底部距離，避免被 Dock 遮擋 */
    }
}

.desktop-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
    /* 為圖示重新啟用指標事件 */
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
    width: 80px;
}

.desktop-icon:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.desktop-icon .icon {
    font-size: 3em;
    margin-bottom: 5px;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

.desktop-icon .label {
    font-size: 0.9em;
    text-align: center;
    line-height: 1.2;
    background: none;
    /* 移除背景以獲得更簡潔的外觀 */
    padding: 2px 4px;
    border-radius: 4px;
}

.desktop-icon:hover .label {
    background: rgba(0, 0, 0, 0.5);
}

/* Dock RWD Fix */
@media (max-width: 768px) {
    .dock-container {
        padding: 10px;
        gap: 10px;
        width: 90%;
        max-width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        /* 如果項目過多，允許滾動 */
    }

    .dock-icon {
        font-size: 2em;
    }

    .dock-tooltip {
        display: none;
        /* 在行動裝置上隱藏工具提示 */
    }
}

/* Dock */
.dock-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 10px 20px;
    display: flex;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.2);
    z-index: 1000;
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
    position: relative;
}

.dock-item:hover {
    transform: scale(1.2) translateY(-10px);
}

.dock-icon {
    font-size: 2.5em;
    filter: drop-shadow(0 0 5px rgba(0, 255, 255, 0.7));
    color: #fff;
}

.dock-tooltip {
    position: absolute;
    top: -40px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    white-space: nowrap;
}

.dock-item:hover .dock-tooltip {
    opacity: 1;
}

/* Launchpad Overlay */
.launchpad {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 999;
    display: flex;
    flex-direction: column;
    padding: 40px;
    padding-bottom: 160px;
    /* 修復：增加內邊距以避免 Dock 遮擋 */
    box-sizing: border-box;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: scale(1.05);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0.2s;
}

.launchpad::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle, rgba(0, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.5;
    z-index: -1;
}

.launchpad.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.category-title {
    color: #00ffff;
    font-size: 1.5em;
    margin: 20px 0 10px 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    padding-bottom: 5px;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: white;
    transition: transform 0.2s;
}

.app-item:hover {
    transform: scale(1.05);
}

.app-icon {
    font-size: 3.5em;
    margin-bottom: 10px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 18px;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3), inset 0 0 10px rgba(0, 255, 255, 0.2);
}

.app-label {
    font-size: 0.9em;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.close-launchpad {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2em;
    cursor: pointer;
    opacity: 0.7;
    text-shadow: 0 0 5px #000;
}

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

/* Print Styles */
@media print {

    .top-bar,
    .dock-container,
    .desktop,
    .launchpad,
    .back-link,
    .footer,
    #pwa-install-btn,
    .install-btn {
        display: none !important;
    }

    body {
        padding: 0 !important;
        background: white !important;
        background-image: none !important;
        color: black !important;
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Ensure text is black for printing */
    h1,
    h2,
    h3,
    p,
    label,
    div,
    span {
        color: black !important;
        text-shadow: none !important;
    }

    /* Adjust input borders for print */
    input,
    textarea,
    select {
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }
}@media print {
    /* 隱藏非列印元素 */
    .top-bar, .desktop, .dock-container, .launchpad {
        display: none !important;
    }

    /* 基本頁面設定 */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        min-width: 0 !important; /* 確保沒有最小寬度限制 */
    }

    body.is-desktop {
        background-image: none !important;
        background-color: #ffffff !important; /* 白色背景以利列印 */
    }

    /* 讓工具的主要內容在列印時可以正常顯示並滿版 */
    .window, .container {
        border: none !important;
        box-shadow: none !important;
        height: auto !important;
        width: 100% !important;
        max-width: none !important; /* 移除最大寬度限制 */
        position: static !important;
        transform: none !important;
        color: #000000 !important; /* 確保文字為黑色 */
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* 通用列印樣式調整 */
    a {
        text-decoration: none;
        color: #000000;
    }

    /* 確保所有內容元素都沒有限制寬度或邊距 */
    * {
        box-sizing: border-box !important;
    }
}
