/*
    CSS Đã Tùy Chỉnh cho Sachtony Portal
    File này chứa các định nghĩa cho các class CSS tùy chỉnh,
    đã được FIX và BỔ SUNG cho Form Auth, đồng thời sắp xếp lại.
*/

/* ======================== */
/* 1. GLOBAL STYLES & VARIABLES */
/* ======================== */
:root {
    /* Biến Màu Sắc & Shadow */
    --primary-color: #4b5563; /* grey-700 (Dùng cho Text chính/Mô tả) */
    --secondary-color: #1f2937; /* grey-800 (Dùng cho Tiêu đề/Nền Footer) */
    --accent-color: #2563eb; /* blue-600 (Dùng cho Action/Link) */
    --danger-color: #dc3545; /* Red (Dùng cho Logout) */
    
    --light-bg-color: #f9fafb; /* grey-50 (Nền Body) */
    --card-bg-color: #ffffff; /* white (Nền Card/Header) */
    --border-color: #e5e7eb; /* grey-200 (Đường viền nhẹ) */
    
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px 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);

    /* Biến Kích thước & Font */
    --font-family: 'Inter', sans-serif;

    --header-padding-y: 0.75rem;
}

/* Reset và Box-sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    color: var(--secondary-color);
    background-color: var(--light-bg-color);
}

/* ======================== */
/* 2. LAYOUT TỔNG THỂ */
/* ======================== */
.app-container {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    padding-top: 5rem; /* ĐÃ ĐIỀU CHỈNH: Giảm từ 6rem xuống 5rem */
}

/* ======================== */
/* 3. HEADER VÀ NAVIGATION */
/* ======================== */
.app-header {
    background-color: var(--card-bg-color);
    box-shadow: var(--shadow-lg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: var(--header-padding-y) 1.5rem; /* ĐÃ ĐIỀU CHỈNH: Dùng biến 0.75rem */
}

.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
}

/* Logo */
.logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-img {
    height: 1.75rem; /* ĐÃ BỔ SUNG: Giảm kích thước ảnh logo */
    width: auto;
}

.logo-text {
    font-size: 1.35rem; /* ĐÃ ĐIỀU CHỈNH: Giảm kích thước chữ logo */
    font-weight: 700;
    color: var(--secondary-color);
}

/* Nội dung Nav (Liên kết & Auth) */
.nav-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

.nav-link:hover, .nav-link.active {
    color: var(--accent-color);
}

/* Auth Controls (Login/Signup/Logout) */
.auth-controls {
    display: flex;
    align-items: center;
    gap: 1rem; 
}

.auth-unauthenticated, .auth-authenticated {
    display: none;
    align-items: center;
    gap: 0.75rem;
}

.auth-unauthenticated.active {
    display: flex;
}

.auth-authenticated.active {
    display: flex;
}

.user-greeting {
    font-weight: 600;
    color: var(--secondary-color);
    margin-right: 0.5rem;
}

.btn-login, .btn-signup, .btn-logout {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, border 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-block;
}

.btn-login {
    background-color: transparent;
    color: var(--primary-color);
}

.btn-login:hover {
    background-color: var(--border-color);
}

.btn-signup {
    background-color: var(--accent-color);
    color: var(--card-bg-color);
    border-color: var(--accent-color);
}

.btn-signup:hover {
    background-color: #1e40af;
}

.btn-logout {
    background-color: var(--danger-color);
    color: var(--card-bg-color);
    border-color: var(--danger-color);
}

.btn-logout:hover {
    background-color: #c82333;
}

/* Mobile Menu Toggle */
.menu-toggle-container {
    display: none;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
}

.menu-toggle-svg {
    width: 1.5rem;
    height: 1.5rem;
    fill: var(--primary-color);
}

/* ======================== */
/* 4. MAIN SECTIONS & COMPONENTS */
/* ======================== */

/* Section Visibility */
.main-section {
    padding-top: 3rem;
    padding-bottom: 3rem;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out;
}

.main-section.active {
    display: block;
    opacity: 1;
    visibility: visible;
}

.section-title {
    font-size: 2.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--secondary-color);
}

/* Home Section */
.home-section-container {
    text-align: center;
    padding: 4rem 0;
}

.main-title {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.main-description {
    font-size: 1.125rem;
    color: var(--primary-color);
    margin: 0 auto 2rem;
    max-width: 600px;
}

.explore-btn {
    display: inline-block;
    background-color: var(--accent-color);
    color: #ffffff;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.explore-btn:hover {
    background-color: #1e40af;
}

/* Grid & Card Styles (Projects, Articles) */
.projects-grid, .portal-articles-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background-color: var(--card-bg-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-light);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}

.card-text {
    color: var(--primary-color);
    line-height: 1.5;
    flex-grow: 1;
    margin-bottom: 1rem;
}

.card-link {
    color: var(--accent-color);
    font-weight: 500;
    text-decoration: none;
    align-self: flex-start;
}

.card-link:hover {
    text-decoration: underline;
}

/* Tab Styles */
.tab-buttons {
    display: none; 
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-buttons:has(button:nth-child(2)) {
    display: flex; 
}

.tab-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-color);
    background-color: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-button.active {
    color: var(--accent-color);
    font-weight: 600;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
}

.tab-pane {
    display: none; 
    animation: fadeIn 0.5s ease-in-out;
}

.tab-pane.active {
    display: block; 
}

/* ======================== */
/* 5. AUTHENTICATION FORMS */
/* ======================== */
.auth-form-container {
    max-width: 400px;
    margin: 0 auto;
    background-color: var(--card-bg-color);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.auth-form.active {
    display: flex;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-submit {
    padding: 0.75rem;
    margin-top: 0.5rem;
    background-color: var(--accent-color);
    color: var(--card-bg-color);
    font-weight: 700;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background-color: #1e40af;
}

.form-switch-text {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--primary-color);
}

.switch-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.switch-link:hover {
    text-decoration: underline;
}

/* ======================== */
/* 6. FOOTER */
/* ======================== */
.app-footer {
    background-color: var(--secondary-color);
    color: #d1d5db; 
    padding: 2rem 1rem;
    text-align: center;
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.footer-link {
    color: #d1d5db;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-link:hover {
    color: var(--card-bg-color);
}

/* ======================== */
/* 7. RESPONSIVE DESIGN */
/* ======================== */

/* Desktop & Tablet Grid */
@media (min-width: 640px) {
    .projects-grid, .portal-articles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .projects-grid, .portal-articles-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Mobile Header (Max-width 1024px) */
@media (max-width: 1024px) {
    .app-header {
        padding: var(--header-padding-y) 1.5rem; /* Giữ đồng bộ với desktop */
    }

    .nav-content {
        display: none;
        flex-direction: column;
        align-items: flex-start; /* Căn trái */
        width: 100%;
        top: 4rem; /* ĐÃ ĐIỀU CHỈNH: Giảm vị trí top */
        left: 0;
        background-color: var(--card-bg-color);
        box-shadow: var(--shadow-light);
        padding: 0; /* Đã chuyển padding vào các link */
        z-index: 40;
    }
    .nav-content.active {
        display: flex;
    }
    
    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: 0; /* Loại bỏ khoảng cách giữa các link */
    }

    .nav-link {
        color: var(--secondary-color);
        padding: 0.75rem 1.5rem; /* Padding cho từng link */
        width: 100%;
        border-bottom: 1px solid var(--border-color);
        text-align: left;
    }
    .nav-link:hover, .nav-link.active {
        background-color: var(--light-bg-color);
    }
    .nav-link:last-child {
        border-bottom: none;
    }

    .menu-toggle-container {
        display: block;
    }

    /* Auth controls trong Mobile Menu */
    .auth-controls {
        width: 100%;
        padding: 1rem 1.5rem 0.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .auth-unauthenticated, .auth-authenticated {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
        align-items: flex-start;
    }
    .user-greeting {
        padding: 0.5rem 0;
    }
    .btn-login, .btn-signup, .btn-logout {
        width: 100%;
        text-align: center;
        margin: 0;
    }
}

/* Small Mobile Adjustments (Max-width 768px) */
@media (max-width: 768px) {
    .main-title {
        font-size: 2.5rem;
    }

    .main-description {
        font-size: 1rem;
    }

    .section-title {
        font-size: 2rem;
    }
}