:root {
    --primary: #f59e0b; /* Amber */
    --primary-hover: #d97706;
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #10b981;
    --danger: #ef4444;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; color: inherit; }

body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: 'Noto Sans TC', sans-serif;
    line-height: 1.6;
}

/* Header & Brand */
.header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
}

.brand { color: var(--primary) !important; font-weight: 900; font-size: 1.5rem; text-decoration: none; }
.menu a { color: var(--text-muted); text-decoration: none; transition: 0.3s; font-weight: 500; }
.menu a:hover, .menu a.active { color: var(--primary); }

/* Global Banner */
.global-ann-item { background: rgba(245, 158, 11, 0.1); border: 1px solid var(--primary); color: var(--primary); }
.global-ann-item.success { border-color: var(--accent); color: var(--accent); background: rgba(16, 185, 129, 0.1); }

/* Buttons - No Blue */
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { background: var(--primary-hover); color: #000; }
.btn-outline { border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #000; }

/* AI Floating Assistant */
.ai-fab {
    position: fixed; bottom: 30px; right: 30px;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--primary); color: #000;
    font-size: 1.5rem; border: none; cursor: pointer;
    box-shadow: 0 5px 20px rgba(245, 158, 11, 0.4);
    z-index: 999; transition: 0.3s;
}
.ai-fab:hover { transform: scale(1.1); }

.ai-panel {
    position: fixed; bottom: 100px; right: 30px;
    width: 350px; height: 500px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    display: flex; flex-direction: column; z-index: 1000;
    overflow: hidden; opacity: 0; pointer-events: none; transform: translateY(20px); transition: 0.3s;
}
.ai-panel.active { opacity: 1; pointer-events: auto; transform: translateY(0); }

.ai-header { padding: 15px; background: var(--primary); color: #000; font-weight: bold; display: flex; justify-content: space-between; }
.ai-messages { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { padding: 10px; border-radius: 8px; max-width: 85%; font-size: 0.9rem; }
.ai-msg.bot { background: var(--border); align-self: flex-start; }
.ai-msg.user { background: var(--primary); color: #000; align-self: flex-end; }
.ai-input-area { padding: 15px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.ai-input-area input { flex: 1; background: var(--bg-body); border: 1px solid var(--border); padding: 8px; border-radius: 6px; color: white; }

/* Links - No Blue */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Chat Bubbles */
.bubble { background: var(--border); padding: 12px 18px; border-radius: 18px; color: var(--text-main); }
.message.mine .bubble { background: var(--primary); color: #000; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.brand {
    font-size: 1.5rem;
    font-weight: 900;
    text-decoration: none;
    color: var(--primary);
    display: flex;
    align-items: center;
}

.menu { display: flex; gap: 20px; }
.menu a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: 0.3s;
}
.menu a:hover, .menu a.active { color: var(--primary); }

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
    padding: 40px 0;
}

@media (max-width: 900px) {
    .main-grid { grid-template-columns: 1fr; }
    .sidebar { order: 2; }
}

/* Sidebar Widgets */
.widget {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 30px;
    border: 1px solid var(--border);
}

.widget-title {
    font-size: 1.1rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
    color: var(--text-main);
}

.category-list { list-style: none; }
.category-list li a {
    display: flex;
    justify-content: space-between;
    text-decoration: none;
    color: var(--text-muted);
    padding: 8px 0;
    transition: 0.3s;
}
.category-list li a:hover, .category-list li a.active { color: var(--primary); }
.count { background: var(--border); padding: 2px 8px; border-radius: 20px; font-size: 0.8rem; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-item {
    background: var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text-muted);
    transition: 0.3s;
}
.tag-item:hover, .tag-item.active { background: var(--primary); color: white; }

/* Post Cards */
.post-list { display: grid; gap: 30px; }
.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: transform 0.3s, box-shadow 0.3s;
    overflow: hidden;
}
.post-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.post-card-inner { padding: 30px; }

.post-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 10px;
}

.post-title { margin-bottom: 15px; }
.post-title a { text-decoration: none; color: var(--text-main); }

.post-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.post-excerpt { color: var(--text-muted); margin-bottom: 25px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.post-tags .tag { color: var(--primary); font-size: 0.85rem; margin-right: 10px; }
.read-more { text-decoration: none; color: var(--accent); font-weight: 700; }

/* Footer */
.site-footer { background: var(--bg-card); padding: 40px 0; border-top: 1px solid var(--border); margin-top: 60px; }
.footer-info p { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.footer-info small { color: var(--text-muted); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { text-decoration: none; color: var(--text-muted); font-size: 0.9rem; transition: 0.3s; }
.footer-links a:hover { color: var(--primary); }

/* Modal Utility */
.modal { display: flex; align-items: center; justify-content: center; }
.btn-danger { background: var(--danger); color: white; }

/* Dashboard Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: var(--bg-card); padding: 25px; border-radius: 12px; border: 1px solid var(--border); text-align: center; }
.stat-card h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 10px; }
.stat-card p { font-size: 2rem; font-weight: 900; color: var(--primary); }

.admin-actions { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 40px; }
.admin-table { margin-top: 20px; }
.text-btn { background: none; border: none; cursor: pointer; color: var(--primary); padding: 0; font: inherit; text-decoration: underline; }
.text-btn.danger { color: var(--danger); }

/* Auth Cards */
.auth-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.auth-card { width: 100%; max-width: 400px; padding: 40px; }
.auth-card h1 { margin-bottom: 30px; text-align: center; }
.auth-footer { margin-top: 20px; text-align: center; color: var(--text-muted); }
.divider { display: flex; align-items: center; margin: 20px 0; color: var(--text-muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.divider span { padding: 0 10px; font-size: 0.8rem; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-muted); }
.form-group input, .form-group textarea {
    width: 100%; padding: 12px; background: var(--bg-body); border: 1px solid var(--border);
    border-radius: 8px; color: white; transition: 0.3s;
}
.form-group input:focus { border-color: var(--primary); outline: none; }

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none; position: absolute; background: var(--bg-card); min-width: 200px;
    box-shadow: var(--shadow); border-radius: 8px; border: 1px solid var(--border);
    z-index: 1000; overflow: hidden;
}
.dropdown-content a { color: var(--text-main); padding: 12px 16px; text-decoration: none; display: block; }
.dropdown-content a:hover { background: var(--border); }
.dropdown:hover .dropdown-content { display: block; }

/* Nav Avatar */
.nav-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; margin-right: 5px; }

/* Comments */
.comments-section { margin-top: 60px; padding-top: 40px; border-top: 1px solid var(--border); }
.comment-form { margin: 30px 0; }
.comment-form textarea { height: 120px; margin-bottom: 15px; }
.comments-list { display: grid; gap: 20px; }
.comment-item { background: var(--bg-card); padding: 20px; border-radius: 12px; border: 1px solid var(--border); }
.comment-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar-sm { width: 32px; height: 32px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.comment-content { color: var(--text-main); font-size: 0.95rem; }

/* Post Nav */
.post-nav { margin: 40px 0; padding: 20px; background: rgba(255, 255, 255, 0.02); border-radius: 12px; }
.post-nav small { display: block; color: var(--text-muted); margin-bottom: 5px; }
.post-nav a { color: var(--primary); font-weight: bold; text-decoration: none; }
.text-right { text-align: right; }

/* Utility Classes */
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.btn { 
    display: inline-block; padding: 10px 20px; border-radius: 8px; 
    text-decoration: none; border: none; cursor: pointer; font-weight: 600;
    transition: 0.3s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border: 1px solid var(--primary); color: var(--primary); background: transparent; }
.btn-accent { background: var(--accent); color: white; }
.full-width { width: 100%; text-align: center; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.status-badge.pending { background: #f59e0b; color: white; }
.status-badge.approved { background: var(--accent); color: white; }
.status-badge.rejected { background: var(--danger); color: white; }

/* Profile Layout */
.profile-layout { display: grid; grid-template-columns: 350px 1fr; gap: 40px; margin-top: 40px; }
.profile-card { text-align: center; }
.profile-avatar { width: 120px; height: 120px; margin: 0 auto 20px; border-radius: 50%; overflow: hidden; border: 4px solid var(--primary); }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder { width: 100%; height: 100%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 3rem; color: white; }
.profile-nickname { margin-bottom: 10px; }
.profile-bio { color: var(--text-muted); margin-bottom: 30px; }
.profile-stats { display: flex; justify-content: space-around; background: rgba(15, 23, 42, 0.5); padding: 15px; border-radius: 12px; margin-bottom: 30px; }
.stat-item { display: flex; flex-direction: column; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stat-value { font-weight: 700; color: var(--primary); }
.profile-actions-btns { display: grid; gap: 15px; }

/* Tables */
.styled-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.styled-table th, .styled-table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border); }
.styled-table th { color: var(--text-muted); font-size: 0.9rem; }
.styled-table tr:hover { background: rgba(255, 255, 255, 0.02); }
.post-content h2, .post-content h3 { margin: 40px 0 20px; }
.post-content p { margin-bottom: 25px; }
/* Chat Layout */
.chat-layout { margin-top: 30px; }
.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* Mobile Responsive Utilities */
.mobile-only { display: none; }

@media (max-width: 900px) {
    .nav { flex-direction: column; height: auto; padding: 15px 0; gap: 15px; }
    .menu { flex-wrap: wrap; justify-content: center; gap: 10px; font-size: 0.9rem; }
    .top-search { width: 100%; }
    .main-grid { grid-template-columns: 1fr; padding: 20px 0; }
    .profile-layout { grid-template-columns: 1fr; gap: 20px; }
    .grid-2 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .ai-panel { width: calc(100% - 40px); right: 20px; bottom: 80px; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .brand { font-size: 1.2rem; }
    .nav-avatar { display: none; }
    .styled-table { display: block; overflow-x: auto; }
    .post-card-inner { padding: 20px; }
    .post-meta { flex-wrap: wrap; gap: 10px; }
    .auth-card { padding: 20px; }
    .ai-fab { width: 50px; height: 50px; bottom: 20px; right: 20px; }
    .ai-panel { bottom: 80px; height: 400px; }
    .form-group.flex { flex-direction: column; align-items: flex-start; }
}

/* Flash Messages & Alerts */
.flash-messages {
    max-width: 1200px;
    margin: 20px auto 0;
    padding: 0 20px;
}
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}
.alert.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}
.alert.info {
    background: rgba(245, 158, 11, 0.1);
    color: var(--primary);
    border-color: var(--primary);
}

/* Scrollbar customization */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Table responsive wrapping */
.styled-table-container { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
