/* 主題變數定義 */
:root {
    /* 預設：TKU Blue (原版) */
    --primary-color: #003366;
    --sidebar-bg: #003366;
    --sidebar-text: rgba(255, 255, 255, 0.8);
    --sidebar-active: #ffffff;
    --bg-color: #f8f9fa;
    --card-shadow: rgba(0, 0, 0, 0.075);
    --sidebar-width: 260px;
    --header-border: transparent;
    --header-height: 106px;
}

/* 方案一：午夜安全風 (Midnight) */
[data-theme="midnight"] {
    --primary-color: #0ea5e9;
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-active: #38bdf8;
    --bg-color: #030712;
    --card-shadow: rgba(0, 0, 0, 0.3);
    color: #e5e7eb;
}
[data-theme="midnight"] .card { background-color: #1f2937; color: #f3f4f6; border-color: #374151; }
[data-theme="midnight"] .sticky-header { background-color: #111827; color: white; border-bottom-color: #374151; }
[data-theme="midnight"] .table { color: #f3f4f6; border-color: #374151; }
[data-theme="midnight"] .table-light { --bs-table-bg: #374151; --bs-table-color: #f3f4f6; }
[data-theme="midnight"] .text-dark { color: #f3f4f6 !important; }
[data-theme="midnight"] .text-muted { color: #9ca3af !important; }
[data-theme="midnight"] .bg-light { background-color: #374151 !important; }

/* 方案二：現代藍靛風 (Indigo) */
[data-theme="indigo"] {
    --primary-color: #4f46e5;
    --sidebar-bg: #312e81;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-active: #ffffff;
    --bg-color: #f8fafc;
    --card-shadow: rgba(79, 70, 229, 0.1);
}

/* 方案三：淡江紅白色系 (TKU Red) */
[data-theme="tku-red"] {
    --primary-color: #B22222;
    --sidebar-bg: #B22222;
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --sidebar-active: #ffffff;
    --bg-color: #ffffff;
    --card-shadow: rgba(178, 34, 34, 0.12);
}
[data-theme="tku-red"] .sticky-header { border-bottom: 2px solid #B22222; }

/* 方案四：ISMS 經典橘金 (ISMS Classic) */
[data-theme="isms-classic"] {
    --primary-color: #B22222; 
    --sidebar-bg: #F7B52C;    
    --sidebar-text: #B22222;  
    --sidebar-active: #ffffff;
    --bg-color: #ffffff;
    --card-shadow: rgba(247, 181, 44, 0.15);
    --header-border: #F7B52C;
}

/* 全域標頭樣式 (Fixed Header) */
#global-header {
    background: url('../images/container-headerbg.png') no-repeat;
    height: var(--header-height);
    display: flex;
    align-items: center;
    width: 100%;
    position: fixed;
    top: 10px;
    left: 0px;
    z-index: 1100;
}

#header-title {
    font-size: 36px;
    margin-left: var(--sidebar-width);
    padding: 0 20px;
    font-style: normal; 
    color: #b10606;
    text-decoration: none;
    font-weight: bold;
    letter-spacing: -1px;
}

.login-status-container {
    transition: all 0.3s ease;
}

/* 全域樣式應用 */
body {
    background-color: var(--bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: background-color 0.3s ease;
    padding-top: var(--header-height); /* 為固定標頭留白 */
}

#sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    background-color: var(--sidebar-bg);
    color: white;
    z-index: 1000;
    transition: all 0.3s ease;
}

#sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 12px 20px;
    border-left: 4px solid transparent;
    font-weight: 600;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-active);
}

#sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--sidebar-active);
    border-left: 4px solid var(--primary-color);
}

/* ISMS 經典橘金專屬修正 */
[data-theme="isms-classic"] #sidebar .nav-link.active {
    background-color: #B22222;
    color: white;
    border-left: 0;
}

#main-content {
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--header-height) - 60px); /* 減去 header 與 footer */
    display: flex;
    flex-direction: column;
}

.sticky-header {
    position: sticky;
    top: var(--header-height);
    z-index: 999;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 2rem;
}

.card { border: none; box-shadow: 0 4px 6px var(--card-shadow); border-radius: 12px; transition: transform 0.2s; }
.card:hover { transform: translateY(-2px); }

.btn-primary, .tku-bg { background-color: var(--primary-color) !important; border-color: var(--primary-color) !important; color: white !important; }
.btn-outline-primary { color: var(--primary-color) !important; border-color: var(--primary-color) !important; }
.btn-outline-primary:hover { background-color: var(--primary-color) !important; color: white !important; }
.tku-text { color: var(--primary-color) !important; }

/* 全域頁尾樣式 */
#global-footer {
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2rem;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    font-size: 0.85rem;
    color: #6c757d;
    text-align: center;
}

/* 工具控制箱 */
.controls-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 1px solid #eee;
    width: 220px;
}

[data-theme="midnight"] .controls-box { background: #1f2937; border-color: #374151; }

.status-badge { font-size: 0.75rem; font-weight: 700; padding: 4px 8px; border-radius: 6px; }
.hash-masked { font-family: monospace; opacity: 0.7; }

@media (max-width: 768px) {
    #sidebar { margin-left: calc(-1 * var(--sidebar-width)); }
    #main-content, #global-footer { margin-left: 0; }
    #header-title { margin-left: 0; padding-left: 20px; font-size: 24px; }
    .login-status-container { margin-right: 10px !important; }
}

/* Page Hero Header (Deprecated in favor of global-header but kept for compatibility) */
.page-hero {
  background: url('../images/container-headerbg.png') no-repeat #fff;
  background-position: left;
  height: 140px;
  padding: 0 2.5rem;
  color: white;
  margin-bottom: 0;
  transition: all 0.4s ease;
}



/* 動畫效果 */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-in {
    animation: slideIn 0.3s ease forwards;
}
