@import url("https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap");

/* Navbar */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.navbar-brand { font-size: 1.1rem; font-weight: 700; color: #03e9f4; text-decoration: none; }
.navbar-right { display: flex; align-items: center; gap: 10px; }
.nav-btn {
    padding: 6px 14px; border-radius: 20px; font-size: 0.82rem;
    text-decoration: none; font-family: 'Kanit', sans-serif;
    cursor: pointer; border: none; transition: all 0.3s;
    background: rgba(255,255,255,0.1); color: #fff;
}
.nav-btn:hover { background: rgba(255,255,255,0.2); }
.nav-btn-logout { background: rgba(231,76,60,0.7) !important; }
.nav-btn-logout:hover { background: #e74c3c !important; }
.nav-profile-img { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #03e9f4; object-fit: cover; cursor: pointer; }

/* Page header */
header { text-align: center; padding: 90px 20px 20px; position: relative; }

/* Search & Filter bar */
.projects-toolbar {
    display: flex; gap: 12px; align-items: center; justify-content: center;
    flex-wrap: wrap; padding: 0 20px 20px; max-width: 900px; margin: 0 auto;
}
.projects-search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.projects-search input {
    width: 100%; padding: 10px 40px 10px 16px;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 25px;
    background: rgba(255,255,255,0.08); color: #fff;
    font-size: 0.9rem; font-family: 'Kanit', sans-serif;
    outline: none; transition: border-color 0.3s; box-sizing: border-box;
}
.projects-search input::placeholder { color: #666; }
.projects-search input:focus { border-color: #03e9f4; }
.projects-search i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #666; pointer-events: none; }
.projects-count { color: #888; font-size: 0.85rem; white-space: nowrap; }

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
    padding: 0 20px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.project-card {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
    position: relative;
}
.project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(3,233,244,0.15);
    border-color: rgba(3,233,244,0.35);
}

/* Preview box */
.project-preview {
    width: 100%; height: 150px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; position: relative; overflow: hidden;
}
.project-preview > i { transition: opacity 0.3s; position: relative; z-index: 1; }

/* iframe preview */
.project-iframe-wrap {
    position: absolute; inset: 0;
    opacity: 0; pointer-events: none;
    transition: opacity 0.4s ease;
    background: #000; z-index: 2;
}
.project-iframe-wrap iframe {
    width: 300%; height: 300%;
    transform: scale(0.333); transform-origin: top left;
    border: none; pointer-events: none;
}
.project-card:hover .project-iframe-wrap { opacity: 1; }
.project-card:hover .project-preview > i { opacity: 0; }

/* Loading overlay */
.iframe-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #03e9f4; font-size: 0.75rem; gap: 6px;
    background: rgba(0,0,0,0.7); z-index: 3; transition: opacity 0.3s;
}
.iframe-loading.hidden { opacity: 0; pointer-events: none; }

.project-card h3 { color: #03e9f4; margin: 10px 14px 4px; font-size: 0.95rem; line-height: 1.3; }
.project-card p  { color: #999; margin: 0 14px 12px; font-size: 0.8rem; flex: 1; line-height: 1.4; }

/* Buttons row */
.card-btns {
    display: flex;
    gap: 8px;
    padding: 0 14px 14px;
    flex-wrap: wrap;
}

.view-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; background: #03e9f4; color: #050801;
    text-decoration: none; border-radius: 20px;
    font-size: 0.82rem; font-weight: 600; transition: all 0.3s;
}
.view-btn:hover { background: #fff; box-shadow: 0 0 15px rgba(3,233,244,0.4); transform: scale(1.04); }

/* Source Code Button */
.src-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 8px 14px;
    background: rgba(255,165,0,0.1);
    border: 1px solid rgba(255,165,0,0.3);
    border-radius: 20px; color: #ffa500;
    font-size: 0.82rem; font-weight: 500;
    cursor: pointer; transition: all 0.25s; text-decoration: none;
}
.src-btn:hover { background: rgba(255,165,0,0.2); border-color: rgba(255,165,0,0.6); }

/* No results */
.no-results { text-align: center; color: #666; padding: 40px; grid-column: 1 / -1; font-size: 1rem; }
.no-results i { font-size: 2.5rem; display: block; margin-bottom: 12px; color: #444; }

/* ===== Source Code Modal ===== */
#srcModal {
    display: none; position: fixed; inset: 0; z-index: 9999;
    align-items: center; justify-content: center; padding: 20px;
}
#srcModal.show { display: flex; }

.src-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
}
.src-modal-box {
    position: relative; z-index: 1;
    background: #0d1117; border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px; width: 100%; max-width: 900px; max-height: 85vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.src-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: #161b22;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 12px; flex-shrink: 0;
}
.src-modal-title { color: #fff; font-size: 0.9rem; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-modal-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.src-open-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; background: rgba(3,233,244,0.15);
    border: 1px solid rgba(3,233,244,0.3); border-radius: 20px;
    color: #03e9f4; font-size: 0.78rem; text-decoration: none;
    transition: all 0.2s; font-family: 'Kanit', sans-serif;
}
.src-open-btn:hover { background: rgba(3,233,244,0.25); }

.src-copy-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15); border-radius: 20px;
    color: #ccc; font-size: 0.78rem; cursor: pointer;
    transition: all 0.2s; font-family: 'Kanit', sans-serif;
}
.src-copy-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

.src-close-btn {
    background: none; border: none; color: #666; font-size: 1.1rem;
    cursor: pointer; padding: 4px 8px; border-radius: 6px;
    transition: all 0.2s; line-height: 1;
}
.src-close-btn:hover { background: rgba(231,76,60,0.2); color: #e74c3c; }

.src-loading {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; padding: 40px; color: #03e9f4;
    font-size: 0.9rem; font-family: 'Kanit', sans-serif;
}

/* File tabs */
.src-file-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: #0d1117;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.src-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #888; font-size: 0.75rem;
    font-family: 'Kanit', sans-serif;
    cursor: pointer; transition: all 0.2s;
    white-space: nowrap;
}
.src-tab:hover { background: rgba(255,255,255,0.1); color: #ccc; }
.src-tab.active {
    background: rgba(3,233,244,0.12);
    border-color: rgba(3,233,244,0.4);
    color: #03e9f4;
}
.src-tab .fab, .src-tab .fas {
    font-size: 0.8rem;
}
/* icon colors */
.src-tab .fa-html5  { color: #e34c26; }
.src-tab .fa-css3-alt { color: #264de4; }
.src-tab .fa-js     { color: #f7df1e; }
.src-tab .fa-sass   { color: #cc6699; }
.src-tab.active .fab,
.src-tab.active .fas { color: inherit; }
.src-code {
    flex: 1; overflow: auto; padding: 20px; margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.78rem; line-height: 1.6; color: #e6edf3;
    background: #0d1117; white-space: pre; tab-size: 2;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.src-code::-webkit-scrollbar { width: 6px; height: 6px; }
.src-code::-webkit-scrollbar-track { background: transparent; }
.src-code::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* Responsive */
@media (max-width: 600px) {
    .projects-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); padding: 0 12px 30px; gap: 1rem; }
    header { padding-top: 75px; }
    .navbar { padding: 10px 14px; }
    .project-iframe-wrap { display: none; }
    #srcModal { padding: 10px; }
    .src-modal-box { max-height: 90vh; }
    .src-modal-header { flex-wrap: wrap; }
}
