@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --sidebar-bg: #4285F4;
    --sidebar-hover: #3367D6;
    --bg-color: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: linear-gradient(90deg, var(--sidebar-bg) 0%, #1e3a8a 100%);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 40px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 20px;
    align-items: center;
}

.nav-menu li a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: var(--transition);
}

.nav-menu li a:hover, .nav-menu li.active a {
    background-color: rgba(255,255,255,0.15);
    color: var(--white);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.8rem;
    cursor: pointer;
}

.main-content {
    flex: 1;
    padding: 30px 40px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: var(--white);
    padding: 16px 28px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    animation: fadeInDown 0.5s ease;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-main);
}

.title-section {
    display: flex;
    flex-direction: column;
}

.gradient-text {
    background: linear-gradient(90deg, #1e3a8a 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2.2rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
    font-weight: 500;
}

.year-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.year-selector select {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    background: #f8fafc;
    transition: var(--transition);
}

.year-selector select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(37, 99, 235, 0.3);
}

.topic-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeInUp 0.5s ease;
}

.topic-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.topic-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.main-topic {
    color: var(--white);
    padding: 18px 24px;
    font-size: 1.15rem;
    font-weight: 500;
}
.main-topic.blue-header {
   background: linear-gradient(90deg, #1a73e8 0%, #2563eb 100%);
}

.sub-topics-container {
    padding: 0;
}

.sub-topic-group {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}
.sub-topic-group:hover {
    background: #f8fafc;
}
.sub-topic-group:last-child {
    border-bottom: none;
}

.sub-topic {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 12px;
}

.minor-topics {
    list-style: none;
    padding-left: 20px;
}

.minor-topics li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 10px;
}

.minor-topics li::before {
    content: "\2022";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-size: 1.2em;
    top: -2px;
}

.minor-topics a {
    color: var(--primary-hover);
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition);
}

.minor-topics a:hover {
    text-decoration: underline;
    color: #1e40af;
}

/* Login Page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    position: relative;
    overflow: hidden;
}
.login-body::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 40%);
    top: -50%;
    left: -50%;
    animation: rotate 20s linear infinite;
}

.login-card {
    background: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(20px);
    z-index: 1;
    border: 1px solid rgba(255,255,255,0.5);
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.login-header h2 {
    color: var(--text-main);
    font-size: 2rem;
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #475569;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: var(--transition);
    background: #f8fafc;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

/* Management Page */
.draggable-item {
    cursor: grab;
}
.draggable-item:active {
    cursor: grabbing;
}
.drag-handle {
    cursor: grab;
    margin-right: 15px;
    color: var(--text-muted);
    font-size: 1.2rem;
}
.drag-handle:hover {
    color: var(--primary-color);
}
.drag-handle:active {
    cursor: grabbing;
}

.edit-actions {
    display: flex;
    gap: 10px;
    opacity: 0.7;
    transition: var(--transition);
}
.topic-card:hover .edit-actions, .sub-topic-group:hover .edit-actions, .minor-topics li:hover .edit-actions {
    opacity: 1;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #ef4444;
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}

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

.ghost {
    opacity: 0.4;
    background-color: #f1f5f9 !important;
    border: 2px dashed #94a3b8 !important;
}

.edit-input {
    transition: var(--transition);
}
.edit-input:focus {
    background: white !important;
    border-style: solid !important;
    border-color: var(--primary-color) !important;
    color: var(--text-main) !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.mb-4 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }
.w-full { width: 100%; }
.text-white { color: white !important; }
.flex-1 { flex: 1; }

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Footer CSS */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--border-color);
    padding: 20px 40px;
    text-align: center;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.site-footer strong {
    color: var(--text-main);
}

/* Modal CSS */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: zoomIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}
.btn-close:hover {
    color: #ef4444;
}

/* Responsive Mobile Mode */
@media (max-width: 768px) {
    .navbar {
        padding: 15px 20px;
        flex-wrap: wrap;
    }
    .nav-toggle {
        display: block;
    }
    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-top: 15px;
        gap: 10px;
    }
    .nav-menu.active {
        display: flex;
    }
    .nav-menu li {
        width: 100%;
    }
    .nav-menu li a {
        justify-content: center;
    }

    .main-content {
        padding: 20px 15px;
    }
    
    .topbar {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
        padding: 15px;
    }
    .flex-between-mobile {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .year-selector {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .year-selector select {
        flex: 1;
    }
    
    .sub-topic-group {
        padding: 15px 15px;
    }
    .main-topic {
        padding: 15px 15px;
    }
    
    /* Manage Mode adjustments */
    .edit-actions {
        opacity: 1; /* Always show buttons on mobile */
        margin-top: 10px;
        margin-left: 0 !important;
        width: 100%;
        justify-content: flex-end;
    }
    
    .flex-between {
        flex-direction: column;
        align-items: flex-start;
    }
    .flex-between > div:first-child {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .minor-topics li {
        flex-direction: column;
    }
    .minor-topics li > div:first-child {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .minor-topics li select {
        margin-left: 0;
        width: 100%;
    }
    .minor-topics li .dynamic-panel {
        margin-left: 0 !important;
        width: 100% !important;
    }

}
/* Navbar Dropdown */
.nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 10px 0;
    list-style: none;
    display: none;
    z-index: 100;
}
.nav-dropdown:hover .dropdown-menu {
    display: block;
    animation: fadeInDown 0.2s ease;
}
.dropdown-menu li {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}
.dropdown-menu li:last-child {
    border-bottom: none;
}
.dropdown-menu li a, .nav-menu li.active .dropdown-menu li a {
    color: var(--text-main);
    background-color: transparent;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 1rem;
}
.dropdown-menu li a:hover, .nav-menu li.active .dropdown-menu li a:hover {
    background-color: #f8fafc;
    color: var(--primary-color);
}
@media (max-width: 768px) {
    .dropdown-menu {
        position: static;
        box-shadow: none;
        background: transparent;
        padding-left: 20px;
    }
    .dropdown-menu li a {
        color: rgba(255,255,255,0.8);
    }
    .dropdown-menu li a:hover {
        background-color: transparent;
        color: white;
    }
}
