@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;700&display=swap');

:root {
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --text-primary: #1e293b;
    --text-gray: #64748b;
    --border-color: #e2e8f0;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Kanit', sans-serif;
    margin: 0;
    padding: 15px; 
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); text-decoration: none; transition: 0.3s; }
a:hover { color: var(--accent-hover); }

h1, h2, h3 {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.btn {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px; 
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    font-family: 'Kanit', sans-serif;
    display: inline-block;
    text-align: center;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

@media (hover: hover) {
    .btn:hover {
        background: var(--accent);
        color: #ffffff;
        border-color: var(--accent);
    }
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

@media (hover: hover) {
    .card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }
}

.card-img-wrapper {
    position: relative;
    overflow: hidden;
    height: 200px;
    background: #e2e8f0;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-content { padding: 15px; }

.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.lightbox-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.lightbox img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    background: #000;
}

.lightbox-caption {
    margin-top: 15px;
    color: #ffffff;
    text-align: center;
    font-size: 16px;
}

.lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border: none;
    width: 44px;
    height: 44px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: background 0.2s;
}

.lightbox-btn:active { background: var(--accent); color: #fff; }
.prev-btn { left: -22px; }
.next-btn { right: -22px; }

.close-btn {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    border: none;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.pagination { display: flex; gap: 8px; margin-top: 35px; justify-content: center; flex-wrap: wrap; }
.pagination a { padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px; min-width: 40px; text-align: center; color: var(--text-primary); }
.pagination a.active { background: var(--accent); color: #fff; font-weight: bold; border-color: var(--accent); }

@media (max-width: 768px) {
    body { padding: 12px; }
    h1 { font-size: 24px !important; }

    .lightbox-content { height: auto; width: 100%; padding-bottom: 80px; }
    .lightbox img { max-height: 55vh; }
    .lightbox-btn { top: auto; bottom: 10px; transform: none; width: 50px; height: 44px; border-radius: 6px; }
    .prev-btn { left: 15%; }
    .next-btn { right: 15%; }
    
    .close-btn {
        top: auto;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 44px;
        height: 44px;
        border-radius: 6px;
        background: #ef4444;
        color: #fff;
    }

    .admin-grid { grid-template-columns: 1fr !important; gap: 15px !important; }
}

@media (max-width: 480px) {
    .grid-container { grid-template-columns: 1fr; gap: 15px; }
    .card-img-wrapper { height: 220px; }
    .btn { padding: 8px 14px; font-size: 14px; }
    .prev-btn { left: 5%; }
    .next-btn { right: 5%; }
}