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

body {
    font-family: "Microsoft JhengHei", "微軟正黑體", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
}

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

/* Header */
header {
    background: linear-gradient(135deg, #d32f2f 0%, #c62828 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
    padding: 0.5rem 1rem;
    border-radius: 5px;
}

nav a:hover {
    background: rgba(255,255,255,0.1);
}

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

/* Home Blocks */
.home-blocks {
    margin: 2rem 0;
}

.block {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.block-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 3rem 2rem;
}

.block-hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.block-hero h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.block-info {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.block-image {
    flex: 0 0 300px;
}

.block-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

.block-content {
    flex: 1;
}

.block h2 {
    color: #d32f2f;
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

.block h3 {
    color: #666;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* Section */
.section {
    margin: 3rem 0;
}

.section-title {
    font-size: 2rem;
    color: #333;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid #d32f2f;
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.category-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    border: 3px solid #e0e0e0;
    text-align: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-card:hover {
    transform: translateY(-5px);
    border-color: #d32f2f;
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.category-icon img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
    margin: 0 auto;
}

.category-icon-text {
    font-size: 3rem;
    margin: 0 auto;
}

.category-card h3 {
    color: #d32f2f;
    font-size: 1.3rem;
    margin: 0;
}

.category-card p {
    color: #666;
    font-size: 0.9rem;
    flex: 1;
}

.article-count {
    color: #999;
    font-size: 0.85rem;
}

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.article-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.article-image {
    height: 200px;
    overflow: hidden;
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.article-card:hover .article-image img {
    transform: scale(1.1);
}

.article-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-category {
    display: inline-block;
    background: #d32f2f;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.article-content h3 {
    color: #333;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.article-excerpt {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex: 1;
}

.read-more {
    color: #d32f2f;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.read-more:hover {
    color: #b71c1c;
}

/* Button */
.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: #d32f2f;
    color: white;
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s;
    font-weight: 500;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover {
    background: #b71c1c;
    transform: scale(1.05);
}

.btn-secondary {
    background: #666;
}

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

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group textarea {
    min-height: 200px;
    resize: vertical;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

/* Alert Messages */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table th,
table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    vertical-align: middle;
}

table th {
    background: linear-gradient(to bottom, #f8f9fa, #f1f3f5);
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #dee2e6;
}

table tbody tr {
    transition: background-color 0.2s ease;
}

table tbody tr:hover {
    background: #f8f9fa;
}

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

/* Action Buttons */
.actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-edit {
    background: #007bff;
}

.btn-edit:hover {
    background: #0056b3;
}

.btn-delete {
    background: #dc3545;
}

.btn-delete:hover {
    background: #c82333;
}

/* Responsive */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    nav ul {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    nav li {
        width: 100%;
    }
    
    nav a {
        display: block;
        text-align: center;
    }
    
    .categories-grid,
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .block-info {
        flex-direction: column;
    }
    
    .block-image {
        flex: 1;
        width: 100%;
    }
    
    .block-hero h2 {
        font-size: 1.8rem;
    }
}

/* ========================================
   互動式教材展示區塊 - 方塊卡片樣式
   ======================================== */

.section-subtitle {
    text-align: center;
    color: #666;
    font-size: 1rem;
    margin-top: -1rem;
    margin-bottom: 2rem;
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* 方塊卡片樣式 */
.material-card-box {
    border-radius: 16px;
    border: 4px solid rgba(255,255,255,0.3);
    padding: 2.5rem 2rem;
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 280px;
}

.material-card-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(0,0,0,0.15) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.material-card-box:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.material-card-box:hover::before {
    opacity: 1;
}

/* 大圖示 */
.material-icon-large {
    font-size: 5rem;
    margin-bottom: 1.5rem;
    animation: bounce 2s ease-in-out infinite;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* 標題 */
.material-title-box {
    font-size: 1.6rem;
    font-weight: bold;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 說明文字 */
.material-desc-box {
    font-size: 1rem;
    opacity: 0.95;
    margin-bottom: 1.5rem;
    line-height: 1.7;
    position: relative;
    z-index: 1;
    flex-grow: 1;
}

/* 動作區域 */
.material-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.2);
    position: relative;
    z-index: 1;
}

.material-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.material-arrow {
    font-size: 1.5rem;
    font-weight: bold;
    transition: all 0.3s;
}

.material-card-box:hover .material-badge {
    background: rgba(255,255,255,0.35);
    transform: translateX(-5px);
}

.material-card-box:hover .material-arrow {
    transform: translateX(5px);
}

/* 響應式設計 */
@media (max-width: 1024px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .materials-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
    }
    
    .material-card-box {
        padding: 2rem 1.5rem;
        min-height: 240px;
    }
    
    .material-icon-large {
        font-size: 3.5rem;
    }
    
    .material-title-box {
        font-size: 1.3rem;
    }
    
    .material-desc-box {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .materials-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .material-card-box {
        min-height: auto;
    }
}

/* 簡化版互動教材卡片 */
.material-card-simple {
    border-radius: 16px;
    border: 4px solid rgba(255,255,255,0.3);
    padding: 2rem;
    color: white;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 200px;
}

.material-card-simple:hover {
    transform: translateY(-8px) scale(1.05);
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.material-title-simple {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .material-card-simple {
        min-height: 160px;
        padding: 1.5rem;
    }
    
    .material-title-simple {
        font-size: 1.2rem;
    }
}
