/* ===== Hoksi-style Theme ===== */
:root {
    --primary: #1565c0;
    --primary-dark: #0d47a1;
    --primary-light: #42a5f5;
    --bg: #ffffff;
    --sidebar-bg: #ffffff;
    --sidebar-text: #333333;
    --sidebar-hover: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #666666;
    --text-light: #999999;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
    
    /* Card colors */
    --card-blue: #1565c0;
    --card-lightblue: #42a5f5;
    --card-orange: #ef6c00;
    --card-green: #2e7d32;
    --card-purple: #7b1fa2;
    --card-red: #c62828;
    --card-teal: #00838f;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: calc(100vh - 64px);
    background: #fafafa;
}

/* ===== Top Header ===== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    gap: 20px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: #000000;
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

.logo img, .logo .logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.logo-icon {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logo-icon:is(img) {
    background: none;
    display: block;
    object-fit: contain;
}

.header-search {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
}

.header-search input {
    width: 100%;
    padding: 10px 48px 10px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 1rem;
    background: #f5f5f5;
    transition: all 0.2s;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 87, 34, 0.1);
}

.search-button {
    position: absolute;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    padding: 0;
}

.search-button:hover {
    background: var(--sidebar-hover);
    color: var(--primary);
}

.search-button:active {
    transform: scale(0.95);
}

.header-icons {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-icon-mobile {
    display: none !important;
}

.header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-muted);
    font-size: 20px;
    position: relative;
    text-decoration: none;
}

.header-icon:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

.header-icon .badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--card-red);
    color: white;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 64px;
    left: 0;
    height: calc(100vh - 64px);
    overflow-y: auto;
    padding: 16px 0;
    z-index: 900;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 8px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

.nav-item.active {
    background: rgba(21, 101, 192, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.nav-item .icon {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-children {
    background: var(--sidebar-hover);
}

.nav-children .nav-item {
    padding-left: 56px;
    font-size: 0.9rem;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    margin-top: 64px;
    padding: 24px;
    background: #fafafa;
}

/* ===== Search Box (inline) ===== */
.search-box {
    display: none; /* Using header search instead */
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary);
}

/* ===== Page Title ===== */
.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text);
}

/* ===== Cards Grid ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ===== Card (Hoksi Style) ===== */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    text-decoration: none;
    display: block;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
}

.card-header {
    padding: 40px 20px;
    color: white;
    text-align: center;
    background: var(--card-blue);
}

.card-header.blue { background: var(--card-blue); }
.card-header.lightblue { background: var(--card-lightblue); }
.card-header.orange { background: var(--card-orange); }
.card-header.green { background: var(--card-green); }
.card-header.purple { background: var(--card-purple); }
.card-header.red { background: var(--card-red); }
.card-header.teal { background: var(--card-teal); }

.card-header-title {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-header-main {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.card-header-sub {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 8px;
}

.card-body {
    padding: 16px 20px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Card with image */
.card-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

/* ===== Article List (Alternative) ===== */
.article-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.article-item {
    display: block;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    text-decoration: none;
}

.article-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
}

.article-item-header {
    padding: 30px 20px;
    background: var(--card-blue);
    color: white;
    text-align: center;
}

.article-item-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.article-item-body {
    padding: 16px 20px;
}

.article-item-body h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.article-item-body p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.article-item-body small {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== Article Content ===== */
.article-content {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow);
    max-width: 900px;
}

.article-content h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}

.article-content h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 32px 0 16px;
    color: var(--primary);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.article-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--text);
}

.article-content p {
    margin-bottom: 16px;
    line-height: 1.8;
}

.article-content ul, .article-content ol {
    margin: 16px 0;
    padding-left: 28px;
}

.article-content li {
    margin-bottom: 8px;
    line-height: 1.7;
}

.article-content pre {
    background: #263238;
    color: #eeffff;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
    font-size: 0.9rem;
}

.article-content code {
    font-family: 'Monaco', 'Consolas', 'Fira Code', monospace;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.95rem;
}

.article-content th, .article-content td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.article-content th {
    background: #f5f5f5;
    font-weight: 600;
}

.article-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 16px 0;
}

/* ===== Welcome Card ===== */
.welcome-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 32px;
    text-align: center;
}

.welcome-card h2 {
    font-size: 1.75rem;
    margin-bottom: 12px;
}

.welcome-card p {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f5f5f5;
    color: var(--text);
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: var(--card-red);
}

.btn-danger:hover {
    background: #b71c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

.form-group textarea {
    min-height: 300px;
    font-family: 'Monaco', 'Consolas', monospace;
    line-height: 1.6;
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th,
.data-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #fafafa;
}

.actions {
    display: flex;
    gap: 8px;
}

.actions a {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.actions a:hover {
    text-decoration: none;
}

.actions .edit {
    background: rgba(21, 101, 192, 0.1);
    color: var(--primary);
}

.actions .edit:hover {
    background: rgba(21, 101, 192, 0.2);
}

.actions .delete {
    background: rgba(198, 40, 40, 0.1);
    color: var(--card-red);
}

.actions .delete:hover {
    background: rgba(198, 40, 40, 0.2);
}

/* ===== Alerts ===== */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
}

.alert-info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 4px solid #1565c0;
}

/* ===== Admin Header ===== */
.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.admin-header .logo {
    color: white;
    font-size: 1.25rem;
}

.admin-header .logo-icon {
    background: none;
}

.admin-header .logo-icon:is(img) {
    background: none;
    object-fit: contain;
}

/* ===== Footer ===== */
.site-footer {
    background: #fafafa;
    padding: 24px;
    margin-top: 0;
    margin-left: 260px;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.admin-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-nav a {
    color: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.admin-nav a:hover {
    background: rgba(255,255,255,0.15);
    text-decoration: none;
}

.admin-nav a.active {
    background: rgba(255,255,255,0.2);
}

/* ===== Admin Container ===== */
.admin-container {
    padding: 24px;
    max-width: 1200px;
    margin: 80px auto 24px;
}

.admin-page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ===== Status Badge ===== */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-published {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-draft {
    background: #fff3e0;
    color: #ef6c00;
}

/* ===== MathJax ===== */
.MathJax {
    font-size: 1.1em !important;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .cards-grid,
    .article-list {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .site-footer {
        margin-left: 0;
    }
    
    .top-header {
        padding: 0 12px;
        gap: 8px;
        align-items: center;
        justify-content: space-between;
    }
    
    .menu-toggle {
        flex-shrink: 0;
        order: 1;
    }
    
    .logo {
        font-size: 1.25rem;
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        order: 2;
        margin-right: auto;
    }
    
    .logo .logo-icon {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }
    
    .header-search {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        padding: 12px 16px;
        background: var(--bg);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        z-index: 1000;
    }
    
    .header-search.mobile-show {
        display: flex;
        align-items: center;
    }
    
    .header-search.mobile-show input {
        padding-right: 48px;
        width: 100%;
    }
    
    .header-search.mobile-show .search-button {
        right: 24px;
        top: auto;
        transform: none;
    }
    
    .header-icons {
        flex-shrink: 0;
        gap: 6px;
        display: flex;
        align-items: center;
        order: 3;
        margin-left: 8px;
    }
    
    .header-icon {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .search-icon-mobile {
        display: flex !important;
    }
    
    .cards-grid,
    .article-list {
        grid-template-columns: 1fr;
    }
    
    .article-content {
        padding: 24px;
    }
    
    .welcome-card {
        padding: 24px;
    }
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --sidebar-bg: #1e1e1e;
        --sidebar-text: #e0e0e0;
        --sidebar-hover: #2d2d2d;
        --card-bg: #1e1e1e;
        --text: #e0e0e0;
        --text-muted: #9e9e9e;
        --text-light: #757575;
        --border: #333333;
    }
    
    .header-search input {
        background: #2d2d2d;
        border-color: #333;
        color: white;
    }
    
    .data-table th {
        background: #2d2d2d;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        background: #2d2d2d;
        border-color: #333;
        color: white;
    }
}
