/* --- CSS Reset & Variables --- */
:root {
    --primary-bg: transparent; 
    --sidebar-bg: rgba(255, 255, 255, 0.95); 
    --text-main: #2b3674;
    --text-muted: #8f9bba;
    --brand-color: #0d4d8c;
    --brand-hover: #0a3d70;
    --card-bg: #ffffff;
    --pastel-purple: #e2dcff;
    --pastel-green: #c8f7dc;
    --pastel-pink: #ffdce0;
    --pastel-yellow: #fff5dc;
    --pastel-blue: #dceaf8;
}

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

body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: linear-gradient(-45deg, #e3f2fd, #e1f5fe, #f3e5f5, #e8f5e9);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    box-shadow: 2px 0 20px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    z-index: 10;
}

.brand {
    font-size: 20px;
    font-weight: 600;
    color: var(--brand-color);
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    padding: 12px 15px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-item:hover, .nav-item.active {
    background-color: var(--brand-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(13, 77, 140, 0.2);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 25px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container input {
    width: 180px;
    height: 42px;
    padding: 10px 40px 10px 20px;
    border-radius: 50px;
    border: 1px solid #e0e5f2;
    background-color: #ffffff;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    transition: width 0.6s cubic-bezier(0.68, -0.55, 0.26, 1.55),
                box-shadow 0.3s ease, border-color 0.3s ease;
}

.search-container input::placeholder {
    color: #a3aed1;
    font-weight: 300;
    transition: color 0.3s ease;
}

.search-container input:focus {
    width: 320px;
    border-color: var(--brand-color);
    box-shadow: 0 10px 20px rgba(13, 77, 140, 0.1);
}

.search-container input:focus::placeholder {
    color: transparent;
}

.search-container i {
    position: absolute;
    right: 15px;
    color: #a3aed1;
    pointer-events: none;
    transition: color 0.3s ease;
}

.search-container input:focus + i {
    color: var(--brand-color);
}

.autocomplete-items {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1px solid #e0e5f2;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(13, 77, 140, 0.15);
    z-index: 99;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.autocomplete-items div {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid #f0f2f8;
    transition: all 0.2s ease;
}

.autocomplete-items div:last-child {
    border-bottom: none;
}

.autocomplete-items div:hover {
    background-color: #f4f7fe;
    color: var(--brand-color);
    padding-left: 25px;
}

.autocomplete-items strong {
    color: var(--brand-color);
    font-weight: 600;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: var(--text-main);
}

.text-primary { color: var(--brand-color); }

.btn-logout {
    background: #ffe5e5;
    color: #d32f2f;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 14px;
}

.btn-logout:hover {
    background: #d32f2f;
    color: #fff;
    box-shadow: 0 4px 10px rgba(211, 47, 47, 0.2);
}

.content {
    padding: 20px 40px 40px;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.02);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.03);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(13, 77, 140, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f2f8;
}

.card-icon {
    width: 45px;
    height: 45px;
    background: #f4f7fe;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-color);
    font-size: 20px;
    transition: background 0.3s ease;
}

.card[data-color="purple"] .card-icon { background-color: var(--pastel-purple); color: #6200ea; }
.card[data-color="green"] .card-icon { background-color: var(--pastel-green); color: #00897b; }
.card[data-color="pink"] .card-icon { background-color: var(--pastel-pink); color: #d81b60; }
.card[data-color="yellow"] .card-icon { background-color: var(--pastel-yellow); color: #fbc02d; }
.card[data-color="blue"] .card-icon { background-color: var(--pastel-blue); color: #0277bd; }

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

.link-list {
    list-style: none;
}

.link-item {
    margin-bottom: 10px;
}

.link-item a {
    text-decoration: none;
    color: #475569;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.link-item a:hover {
    background: #f8fafc;
    color: var(--brand-color);
    transform: translateX(5px);
}

.highlight-glow {
    color: #ffffff !important;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-block;
    animation: pulseGlow 1s infinite alternate;
}

@keyframes pulseGlow {
    0% { background-color: #ff9800; box-shadow: 0 0 5px rgba(255, 152, 0, 0.5); }
    100% { background-color: #ff3d00; box-shadow: 0 0 15px rgba(255, 61, 0, 0.9); }
}

.main-footer {
    text-align: center;
    padding: 20px 40px;
    margin-top: auto; 
    color: #8f9bba; 
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.5px; 
    border-top: 1px solid rgba(0, 0, 0, 0.03);
    background: transparent;
}

.main-footer p { margin: 0; }
.designer-note { color: #c0c7d6; font-weight: 300; margin-left: 5px; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-window {
    background: rgba(255, 255, 255, 0.85);
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal-window {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 20px;
    color: var(--brand-color);
    font-weight: 600;
}

.modal-close {
    font-size: 30px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #d32f2f;
}

.modal-body {
    flex: 1;
    overflow: hidden;
    padding: 20px 30px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.modal-download-btn-container {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.modal-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--pastel-green);
    color: #00897b;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.modal-download-btn:hover {
    background: #00897b;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 137, 123, 0.2);
}

.modal-preview-img-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.modal-preview-img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.modal-preview-img-wrapper img:hover {
    transform: scale(1.02);
}

.viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    cursor: pointer;
}

.viewer-content {
    display: block;
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.1);
    border: 4px solid rgba(255, 255, 255, 0.9);
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.viewer-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 50px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 2001;
}

.viewer-close:hover {
    color: #d32f2f;
}

/* --- 🌟 ฟอร์มตั้งค่าโปรไฟล์ (เพิ่มใหม่) --- */
.form-group { margin-bottom: 15px; width: 100%; text-align: left; }
.form-group label { display: block; font-size: 14px; font-weight: 500; color: var(--text-main); margin-bottom: 8px; }
.form-control { width: 100%; padding: 12px 15px; border-radius: 10px; border: 1px solid #cfd8e3; font-size: 14px; outline: none; transition: 0.3s; background: #fff;}
.form-control:focus { border-color: var(--brand-color); box-shadow: 0 0 0 3px rgba(13, 77, 140, 0.1); }
.password-wrapper { position: relative; width: 100%; display: block; box-sizing: border-box; }
.password-wrapper input { padding-right: 40px !important; margin: 0 !important; width: 100%; box-sizing: border-box; }
.toggle-password { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #a3aed1; transition: 0.3s; }
.toggle-password:hover { color: var(--brand-color); }
.text-danger { color: #d32f2f; margin-top: 5px; display: block; }
.btn-cancel { background: #f0f2f8; color: #475569; border: none; padding: 10px 20px; border-radius: 10px; cursor: pointer; font-weight: 500; margin-right: 10px; transition: 0.3s; font-size: 14px;}
.btn-cancel:hover { background: #e2e8f0; }
.btn-save { background: linear-gradient(135deg, #0b5cff, #003fa8); color: white; border: none; padding: 10px 20px; border-radius: 10px; cursor: pointer; font-weight: 500; transition: 0.3s; box-shadow: 0 5px 15px rgba(11, 92, 255, 0.3); font-size: 14px;}
.btn-save:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(11, 92, 255, 0.4); }