:root {
    --primary-color: #4a90e2;
    --secondary-color: #f5f7fa;
    --text-color: #333;
    --card-bg: #ffffff;
    --accent-color: #ff6b6b;
    --success-color: #2ecc71;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --input-bg: #f5f7fa;
    --text-main: #2d3748;
    --text-light: #718096;
    --shadow-soft: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Sarabun', sans-serif;
    /* Google Font for Thai */
    background-color: var(--secondary-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.nav-buttons {
    margin-top: 20px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

/* Search Bar */
.search-container {
    margin: -20px auto 30px;
    max-width: 600px;
    text-align: center;
    position: relative;
    z-index: 10;
}

.search-form {
    display: flex;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 50px;
    overflow: hidden;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.search-input {
    flex: 1;
    padding: 15px 25px;
    border: none;
    font-size: 1rem;
    outline: none;
    font-family: 'Sarabun', sans-serif;
}

.search-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0 25px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.3s;
}

.search-btn:hover {
    background: #357abd;
}

.btn-primary {
    background-color: white;
    color: #667eea;
}

.btn-primary:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-danger {
    background-color: var(--accent-color);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

/* Card Styles */
.knowledge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 30px;
}

.year-separator {
    grid-column: 1 / -1;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    display: flex;
    align-items: center;
}

.year-separator i {
    margin-right: 10px;
    color: var(--primary-color);
}

.card {
    background: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.card-header {
    background-color: #fafafa;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.date-badge {
    background-color: #e3f2fd;
    color: #1976d2;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.fab-btn.setting {
    background-color: #607d8b;
    /* Blue Grey */
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    color: white;
}

.fab-btn.search {
    background-color: #2196F3;
    /* Blue */
    margin-bottom: 10px;
}

.card-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.25rem;
    color: #2c3e50;
}

.new-badge {
    background: #ff4757;
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 700;
    text-transform: uppercase;
    animation: pulse 1.5s infinite;
    vertical-align: middle;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 5px rgba(255, 71, 87, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0);
    }
}

.week-badge {
    background: #ffa502;
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
}

.month-badge {
    background: #20bf6b;
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    font-weight: 700;
    text-transform: uppercase;
    vertical-align: middle;
}

.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin-bottom: 10px;
    margin-top: 15px;
    font-weight: 700;
    display: block;
}

.video-list,
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.video-item {
    margin-bottom: 10px;
}

.video-link {
    display: flex;
    align-items: center;
    color: #c4302b;
    /* Youtube red */
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.video-link:hover {
    color: #a01a16;
}

.video-link i {
    margin-right: 8px;
}

.file-item {
    margin-bottom: 8px;
}

.file-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #555;
    transition: background-color 0.2s;
}

.file-link:hover {
    background-color: #e9ecef;
}

.file-link i {
    margin-right: 10px;
    color: #667eea;
}

/* Admin Form */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
}

input[type="text"],
input[type="date"],
input[type="file"] {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    box-sizing: border-box;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="date"]:focus {
    border-color: #667eea;
    outline: none;
}

.dynamic-field {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.remove-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 5px;
    width: 36px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-btn {
    background: #4a90e2;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.close-btn:hover {
    color: #333;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .knowledge-grid {
        grid-template-columns: 1fr;
    }
}

/* NEW PREMIUM LOGIN STYLES */

/* Reset login body styles specifically (scoped via class if possible, or override) */
body.login-body {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    /* Subtle light gradient */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    font-family: 'Sarabun', sans-serif;
}

/* Background Decorations */
.login-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-decoration .circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 20s infinite ease-in-out;
}

.circle-1 {
    width: 400px;
    height: 400px;
    background: rgba(102, 126, 234, 0.4);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.circle-2 {
    width: 300px;
    height: 300px;
    background: rgba(118, 75, 162, 0.4);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 50px);
    }
}

/* Glass Card */
.login-container.glass-effect {
    background: rgba(255, 255, 255, 0.85);
    /* Fallback */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 50px 40px;
    border-radius: 24px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    width: 100%;
    max-width: 420px;
    transform: translateY(0);
}

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    display: flex;
    flex-direction: column-reverse;
    gap: 15px;
    align-items: center;
}

.fab-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
    text-decoration: none;
    /* Ensure links look like buttons */
}

.fab-btn.search {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    /* Sunny gradient */
    width: 50px;
    /* Slightly smaller */
    height: 50px;
    font-size: 20px;
}

.fab-btn.home {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    /* Blue/Cyan gradient */
    width: 45px;
    height: 45px;
    font-size: 18px;
}

.fab-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.4);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    padding: 30px 40px;
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.7) translateY(20px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f1f3f5;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #555;
    font-size: 18px;
}

.modal-close:hover {
    background: #ff6b6b;
    color: white;
    transform: rotate(90deg);
}

/* Scrollbar for modal content */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.icon-bg {
    width: 80px;
    height: 80px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 10px 20px rgba(118, 75, 162, 0.3);
}

.icon-bg i {
    font-size: 36px;
    color: white;
}

.login-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 5px;
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-light);
    font-size: 1rem;
    margin: 0;
}

/* Form Inputs for Login */
.floating-group {
    position: relative;
    margin-bottom: 25px;
}

.floating-group .input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.floating-group .input-icon-wrapper i {
    position: absolute;
    left: 18px;
    color: #a0aec0;
    transition: color 0.3s;
    z-index: 2;
    top: 50%;
    transform: translateY(-50%);
}

.floating-group .input-icon-wrapper input {
    width: 100%;
    padding: 16px 16px 16px 50px;
    background: var(--input-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 1rem;
    color: var(--text-main);
    transition: all 0.3s;
    outline: none;
    font-family: inherit;
}

.floating-group .input-icon-wrapper input:focus {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.floating-group .input-icon-wrapper input:focus~i {
    color: #667eea;
}

/* Floating Label Simulation (Optional, can be removed if not working perfectly with icons) */
.floating-group label {
    display: none;
    /* Hidden for now as the placeholder is sufficient and cleaner */
}

/* Error Message */
.error-msg {
    background: #fff5f5;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 10px;
    border-left: 4px solid #fc8181;
    margin-bottom: 25px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Button */
.btn-login {
    width: 100%;
    padding: 16px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-login:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
    filter: brightness(1.1);
}

.btn-login:active {
    transform: translateY(-1px);
}

/* Responsive Login */
@media (max-width: 480px) {
    .login-container.glass-effect {
        padding: 40px 25px;
    }

    .login-header h2 {
        font-size: 1.75rem;
    }
}