/* ===== 陽光社區智慧管理系統 主樣式 ===== */

:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: #fef3c7;
    --secondary: #1e3a5f;
    --secondary-dark: #152d4a;
    --accent: #10b981;
    --sidebar-width: 250px;
    --topnav-height: 58px;
    --sidebar-bg: #1e3a5f;
    --sidebar-text: rgba(255,255,255,0.85);
    --sidebar-hover: rgba(255,255,255,0.1);
    --sidebar-active: rgba(245,158,11,0.2);
    --border-radius: 12px;
    --shadow: 0 2px 15px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 25px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: #f0f4f8;
    color: #333;
    min-height: 100vh;
}

/* ===== 頂部導航 ===== */
#topNav {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    height: var(--topnav-height);
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1050;
}

#topNav .btn-link { color: white; text-decoration: none; }
#topNav .btn-link:hover { color: var(--primary); }
#topNav .navbar-brand { font-size: 1rem; letter-spacing: 0.5px; }

/* ===== 側邊欄 ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--topnav-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--topnav-height));
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 1040;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
}

.sidebar-nav .nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    padding: 1rem 1rem 0.3rem;
    font-weight: 600;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
    border-radius: 8px;
    margin: 2px 8px;
}

.sidebar-nav li a i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-nav li a:hover { background: var(--sidebar-hover); color: white; }
.sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: var(--primary);
    font-weight: 600;
    border-left: 3px solid var(--primary);
    margin-left: 5px;
}

/* ===== 主內容區域 ===== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topnav-height);
    min-height: calc(100vh - var(--topnav-height));
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ===== 卡片 ===== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    background: white;
    border-bottom: 1px solid #e8ecf0;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    padding: 1rem 1.25rem;
}

/* ===== 統計卡片 ===== */
.stat-card {
    border-radius: var(--border-radius);
    padding: 1.25rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-3px); }

.stat-card .stat-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.stat-card .stat-number { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.85rem; opacity: 0.9; }

.stat-primary   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-success   { background: linear-gradient(135deg, #10b981, #059669); }
.stat-info      { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-warning   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-purple    { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-teal      { background: linear-gradient(135deg, #14b8a6, #0f766e); }

/* ===== 頁面標題 ===== */
.page-header {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--secondary);
    margin: 0;
}

.page-header .breadcrumb,
nav[aria-label="breadcrumb"] {
    display: none;
}

/* ===== 頭像 ===== */
.avatar-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    flex-shrink: 0;
}

.avatar-circle-lg {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem;
    flex-shrink: 0;
}

/* ===== 通知下拉 ===== */
.notification-dropdown .dropdown-item {
    white-space: normal;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.notification-item.unread { background: #fef9e7; }
.notification-item .notif-time { font-size: 0.75rem; color: #999; }

/* ===== 表格 ===== */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    color: #666;
    background: #f8fafc;
    border-bottom: 2px solid #e8ecf0;
}

.table td { font-size: 0.9rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #fef9f0; }

/* ===== 徽章 ===== */
.badge { font-weight: 500; font-size: 0.78rem; padding: 0.35em 0.75em; }

/* ===== 按鈕 ===== */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 500;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ===== 側邊欄遮罩 ===== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    display: none;
}

.sidebar-overlay.show { display: block; }

/* ===== 公告卡片 ===== */
.announcement-card {
    border-left: 4px solid var(--primary);
    padding: 1rem;
    background: white;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}

.announcement-card.urgent { border-left-color: #ef4444; }
.announcement-card.maintenance { border-left-color: #3b82f6; }
.announcement-card.activity { border-left-color: #10b981; }
.announcement-card.finance { border-left-color: #8b5cf6; }

/* ===== 報修狀態時間軸 ===== */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: 0.6rem;
    top: 0; bottom: 0;
    width: 2px;
    background: #e8ecf0;
}
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-dot {
    position: absolute;
    left: -1.6rem;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

/* ===== 登入頁面 ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5986 50%, #1e3a5f 100%);
    display: flex;
    align-items: center;
}

.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.login-brand {
    background: linear-gradient(135deg, #1e3a5f, #2d5986);
    padding: 3rem 2rem;
    text-align: center;
    color: white;
}

.login-brand .brand-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* ===== 搜尋框 ===== */
.search-box {
    position: relative;
}
.search-box .bi-search {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}
.search-box input { padding-left: 2.2rem; border-radius: 20px; }

/* ===== 表單控件 ===== */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(245,158,11,0.2);
}

/* ===== 響應式 ===== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 576px) {
    .main-content { padding: 1rem; }
    .stat-card .stat-number { font-size: 1.4rem; }
    .page-header { flex-wrap: wrap; gap: 0.5rem; }
    .page-header > div:first-child { flex: 1; min-width: 0; }
}

/* 儀表板標題區：手機版日期時間換行到標題下方 */
@media (max-width: 768px) {
    .page-header-date {
        width: 100%;
        margin-top: 0.1rem;
        flex-basis: 100%;
    }
}

/* ===== 動畫 ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp 0.4s ease forwards; }

/* ===== 空狀態 ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}
.empty-state i { font-size: 3.5rem; opacity: 0.3; }

/* ===== 快速連結卡片 ===== */
.quick-link-card {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    display: block;
}
.quick-link-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    color: var(--primary);
}
.quick-link-card .icon-wrap {
    width: 60px; height: 60px;
    border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.6rem;
}

/* ===== 管理員報修卡片進度 ===== */
.progress { border-radius: 10px; height: 8px; }
.progress-bar { border-radius: 10px; }
