/* Global Styles */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #334155;
    --heading-color: #0f172a;
    --accent-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

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

a {
    text-decoration: none;
    color: inherit;
}

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

/* Header */
.main-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 40px 0;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}


.logos {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.logo-img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.white-bg-circle {
    background-color: white;
    border-radius: 50%;
    padding: 1px;
    /* Adds space between image and white edge */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.logo-img:hover {
    transform: rotate(10deg) scale(1.1);
}

.header-text h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 600;
}

.header-text p {
    margin: 10px 0 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
.intro {
    padding: 40px 0 20px;
    text-align: center;
}

.intro h2 {
    font-size: 2rem;
    color: var(--heading-color);
    margin-bottom: 10px;
}

/* Filter Section */
.filter-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px 0 25px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.95rem;
    color: var(--secondary-color);
    font-weight: 500;
}

.filter-label i {
    margin-right: 5px;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-btn {
    padding: 10px 25px;
    border: 2px solid #e2e8f0;
    background-color: white;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--secondary-color);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Kanit', sans-serif;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
}

.filter-btn[data-filter="ปวช."]:hover,
.filter-btn[data-filter="ปวช."].active {
    background: linear-gradient(135deg, #10b981, #059669);
    border-color: transparent;
    color: white;
}

.filter-btn[data-filter="ปวส."]:hover,
.filter-btn[data-filter="ปวส."].active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: transparent;
    color: white;
}

/* Hide filtered cards */
.project-card.hidden {
    display: none !important;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    padding: 20px 0 60px;
}

/* Project Card */
.project-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--accent-color);
}

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

.card-image {
    height: 180px;
    background-color: #cbd5e1;
    position: relative;
    display: block;
    overflow: hidden;
    /* Important for clipping iframe */
}

.live-preview {
    width: 400%;
    height: 400%;
    transform: scale(0.25);
    transform-origin: top left;
    pointer-events: none;
    /* Disables interaction so clicking the card works */
    background-color: white;
    border: none;
}

.level-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 4px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.badge-vc {
    background-color: #10b981;
}

/* Green for Vocational (ปวช.) */
.badge-hvc {
    background-color: #f59e0b;
}

/* Orange for High Vocational (ปวส.) */

.card-image .overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-image .overlay i {
    color: white;
    font-size: 2rem;
}

.project-card:hover .card-image .overlay {
    opacity: 1;
}

.card-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-content h3 {
    margin: 0 0 10px;
    color: var(--heading-color);
    font-size: 1.25rem;
}

.card-content p {
    margin: 0 0 10px;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.card-content .student-name {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
    margin-bottom: 5px;
}

.card-content .student-names {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.card-content .student-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-content .student-badge i {
    font-size: 0.7rem;
}

.project-card:hover .student-badge {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}


.card-content .desc {
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 3em;
    /* Fixed height for consistency */
}

.tags {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.tag {
    background-color: #e0f2fe;
    color: #0369a1;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Footer */
.main-footer {
    background-color: #1e293b;
    color: #94a3b8;
    text-align: center;
    padding: 20px 0;
    margin-top: auto;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: white;
    width: 90%;
    height: 85%;
    max-width: 1200px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 15px 25px;
    background-color: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--heading-color);
    font-size: 1.25rem;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-actions a {
    color: var(--secondary-color);
    font-size: 1.1rem;
    transition: color 0.2s;
}

.modal-actions a:hover {
    color: var(--primary-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary-color);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ef4444;
}

/* Modal Title Area */
.modal-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-level-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.modal-level-badge.badge-vc {
    background: linear-gradient(135deg, #10b981, #059669);
}

.modal-level-badge.badge-hvc {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

/* Modal Info Panel */
.modal-info-panel {
    padding: 15px 25px;
    background-color: white;
    border-bottom: 1px solid #e2e8f0;
}

.modal-info-row {
    margin-bottom: 10px;
}

.modal-info-row:last-child {
    margin-bottom: 0;
}

.modal-info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.9rem;
}

.modal-info-item>i {
    color: var(--primary-color);
    margin-top: 3px;
    min-width: 18px;
}

.modal-info-label {
    font-weight: 600;
    color: var(--heading-color);
    white-space: nowrap;
}

.modal-students {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-student-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    font-weight: 500;
}

.modal-student-badge i {
    font-size: 0.7rem;
}

.modal-description p {
    margin: 0;
    color: var(--secondary-color);
    line-height: 1.5;
    flex: 1;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-tag {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    background-color: #e0f2fe;
    color: #0369a1;
    font-weight: 500;
}

.modal-desc-text {
    margin: 0;
    color: var(--secondary-color);
    line-height: 1.6;
    font-size: 0.9rem;
}

/* Modal Main Area - Split Layout */
.modal-main-area {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}


.modal-body {
    flex: 1;
    background-color: #e2e8f0;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

#projectFrame {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
}

/* Right side info panel */
.modal-main-area .modal-info-panel {
    width: 320px;
    min-width: 320px;
    padding: 20px;
    background-color: #f8fafc;
    border-left: 1px solid #e2e8f0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-main-area .modal-info-row {
    margin-bottom: 0;
}

.modal-main-area .modal-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.modal-main-area .modal-students,
.modal-main-area .modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Responsive - Stack on mobile */
@media (max-width: 900px) {
    .modal-main-area {
        flex-direction: column;
    }

    .modal-main-area .modal-info-panel {
        width: 100%;
        min-width: auto;
        max-height: 200px;
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }

    .modal-body {
        flex: 1;
        min-height: 300px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header-text h1 {
        font-size: 1.8rem;
    }

    .header-text p {
        font-size: 1rem;
        padding: 0 15px;
    }

    .logos {
        gap: 15px;
    }

    .logo-img {
        width: 80px;
        height: 80px;
    }

    .project-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
        padding: 20px 0 40px;
    }

    .intro h2 {
        font-size: 1.75rem;
    }

    .modal-content {
        width: 95%;
        height: 80%;
    }
}

@media (max-width: 480px) {
    .main-header {
        padding: 30px 0;
    }

    .logo-img {
        width: 70px;
        height: 70px;
    }

    .header-text h1 {
        font-size: 1.5rem;
    }

    .header-text p {
        font-size: 0.9rem;
    }

    .project-grid {
        grid-template-columns: 1fr;
        /* Single column on very small screens */
    }

    .modal-header h3 {
        font-size: 1.1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
}