/* PapaRadar Base Module - 基礎樣式模組 */
/* 包含：CSS重置、權限控制、基礎字型、工具類別、滾動條樣式 */

/* ===== 權限控制基礎樣式 ===== */
/* 預設隱藏所有權限控制元素，JavaScript 會根據用戶角色顯示對應元素 */
.admin-only {
    display: none;
}

.user-only {
    display: none;
}

.basic-only {
    display: none;
}

/* admin-user：只有真正的管理員（不管當前視角）才能看到 */
.admin-user {
    display: none;
}

/* ===== 基礎重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 為手機版底部工具列預留空間 */
body {
    padding-bottom: 60px;
}

/* ===== 基礎字型樣式 ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-md);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--space-md);
    line-height: 1.6;
}

/* ===== 連結樣式 ===== */
a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover, a:focus {
    color: var(--btn-primary-hover);
    text-decoration: underline;
}

/* ===== 基礎表單元素 ===== */
input, textarea, select {
    font-family: inherit;
    font-size: var(--text-sm);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition-fast);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== 基礎列表樣式 ===== */
ul, ol {
    padding-left: var(--space-lg);
}

li {
    margin-bottom: var(--space-xs);
}

/* 移除清單樣式的類別 */
.list-none {
    list-style: none;
    padding-left: 0;
}

/* ===== 工具類別 ===== */
.text-positive {
    color: var(--success-color) !important;
}

.text-negative {
    color: var(--danger-color) !important;
}

.text-neutral {
    color: var(--text-primary) !important;
}

.bg-positive {
    background-color: rgba(0, 255, 136, 0.1) !important;
}

.bg-negative {
    background-color: rgba(255, 71, 87, 0.1) !important;
}

.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* 文字對齊 */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* 文字大小工具類別 */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

/* 間距工具類別 */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* Flexbox 工具類別 */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* 圓角工具類別 */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 50%; }

/* 陰影工具類別 */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* 過渡動畫工具類別 */
.transition-fast { transition: var(--transition-fast); }
.transition-normal { transition: var(--transition-normal); }
.transition-slow { transition: var(--transition-slow); }

/* ===== 載入動畫 ===== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 動畫類別 */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.spin {
    animation: spin 1s linear infinite;
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.slide-in-down {
    animation: slideInDown 0.3s ease-out;
}

/* ===== 滾動條樣式 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Firefox 滾動條 */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ===== 無障礙樣式 ===== */
/* 高對比度模式支援 */
@media (prefers-contrast: high) {
    :root {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* 動作減少偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 焦點樣式 */
*:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* 跳過連結 (無障礙功能) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--accent-color);
    color: var(--primary-bg);
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 6px;
}

/* ===== 列印樣式 ===== */
@media print {
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }

    .mobile-toolbar,
    .left-panel-toggle,
    button,
    input {
        display: none !important;
    }

    .tab-content {
        display: block !important;
    }

    .content {
        display: block !important;
        page-break-inside: avoid;
    }
}