/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

/* --- CSS Variables (Theme) --- */
:root {
    --bg-color: #f8f9fa;
    --card-bg: #FFFFFF;
    --primary-blue: #007BFF;
    --dark-blue: #0056b3;
    --light-blue-bg: #F0F7FF;
    --text-dark: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --card-shadow: 0px 4px 15px rgba(0, 0, 0, 0.07);
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --transition-speed: 0.3s;
}

/* --- General & Reset Styles --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    margin: 0;
    line-height: 1.6;
}

/* --- Smooth Transitions --- */
a, button, input, select, .card, .subject-box, .solution-card {
    transition: all var(--transition-speed) ease;
}

/* --- Reusable Components --- */
.main-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.page-header h2 {
    margin: 0;
}

.btn {
    padding: 12px 24px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}
.btn-primary:hover {
    background-color: var(--dark-blue);
    border-color: var(--dark-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--light-blue-bg);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}
.btn-danger:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
}
.back-link:hover {
    text-decoration: underline;
    color: var(--dark-blue);
}

/* --- CSS สำหรับ User Profile Dropdown --- */
.user-actions {
    position: relative;
}

.user-profile-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50px;
    transition: background-color 0.2s ease;
}

.user-profile-container:hover {
    background-color: var(--light-blue-bg);
}

.profile-picture {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.username-display {
    font-weight: 500;
    color: var(--text-dark);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--card-shadow);
    min-width: 220px;
    z-index: 100;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.user-dropdown.show {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.dropdown-header strong {
    display: block;
    color: var(--text-dark);
}
.role-badge {
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--light-blue-bg);
    color: var(--dark-blue);
    text-transform: capitalize;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.9rem;
}
.dropdown-item:hover {
    background-color: var(--light-blue-bg);
}
.dropdown-item.danger {
    color: var(--danger-color);
}
.dropdown-item.danger:hover {
    background-color: #fbebeb;
}

/* --- CSS สำหรับ About Dev Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    /* --- เพิ่มส่วนนี้เพื่อให้เลื่อนได้ --- */
    overflow-y: auto;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 800px; 
    position: relative;
    animation: slideUp 0.3s ease-out;
    margin: auto; /* เพิ่มเพื่อให้จัดกลางสวยงามเมื่อ scroll */
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}
.close-modal-btn:hover {
    color: var(--text-dark);
}

.modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.modal-column {
    display: flex;
    flex-direction: column;
}

.dev-profile {
    text-align: center;
}

.dev-picture {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--primary-blue);
    margin-bottom: 1rem;
    object-fit: cover;
}

.dev-profile h2 {
    margin: 0 0 0.25rem 0;
}

.dev-title {
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
}

.dev-contact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.contact-email {
    font-size: 0.95rem;
    color: var(--text-dark);
    margin: 0;
    word-break: break-all;
}

.contact-email i {
    margin-right: 0.5rem;
    color: var(--text-secondary);
}

.social-logos {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.social-logos a {
    display: inline-block;
    line-height: 0;
}

.social-logos img {
    height: 30px;
    transition: transform 0.2s ease;
}

.social-logos img:hover {
    transform: scale(1.1);
}

.dev-details, .tech-stack {
    margin-bottom: 1.5rem;
}

.dev-details h3, .tech-stack h3 {
    text-align: left;
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    font-weight: 700;
}
.dev-details h3 i, .tech-stack h3 i {
    margin-right: 0.5rem;
    color: var(--primary-blue);
    width: 20px;
    text-align: center;
}

.dev-details p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
}

.tech-stack ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.tech-stack li {
    background-color: var(--light-blue-bg);
    padding: 0.75rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.dream-companies {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.dream-companies h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.company-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.company-logos img {
    height: 40px;
    max-width: 120px;
    object-fit: contain;
}

.company-logos img[alt="OpenAI Logo"] {
    height: 35px;
}


@media (max-width: 768px) {
    .modal-body-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .dream-companies {
        margin-top: 1.5rem;
    }
}


/* --- Dark Mode --- */
body.dark-mode {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --primary-blue: #3a96ff;
    --dark-blue: #007bff;
    --light-blue-bg: #2a2a2a;
    --text-dark: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #333333;
    --card-shadow: 0px 4px 15px rgba(0, 0, 0, 0.3);
}

/* Dark mode for dropdown & modal */
body.dark-mode .user-profile-container:hover { background-color: #2f2f2f; }
body.dark-mode .dropdown-item:hover { background-color: #2f2f2f; }
body.dark-mode .dropdown-item.danger:hover { background-color: #4d2323; }
body.dark-mode .role-badge { background-color: #333; color: #ccc; }
body.dark-mode .tech-stack li { background-color: #2a2a2a; }
body.dark-mode .dev-details h3 { color: var(--text-dark); }
body.dark-mode .company-logos img {
    filter: invert(1) grayscale(1) brightness(2);
}
body.dark-mode .contact-email {
    color: var(--text-dark);
}
body.dark-mode .contact-email i {
    color: var(--text-secondary);
}


/* Smooth color transition for all elements */
body, .card, .modal-content, .sidebar, .btn, input, select, table, th, td {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
