<?php
session_start();
include 'koneksi.php';

// ========== HIT COUNTER PENGUNJUNG ==========
$ip = $_SERVER['REMOTE_ADDR'];
$tanggal = date('Y-m-d');

// Buat tabel jika belum ada
mysqli_query($koneksi, "
    CREATE TABLE IF NOT EXISTS visitor_counter (
        id INT AUTO_INCREMENT PRIMARY KEY,
        ip_address VARCHAR(100),
        tanggal DATE,
        user_agent VARCHAR(255)
    )
");

// Cek apakah IP sudah tercatat hari ini
$cek = mysqli_query($koneksi, "
    SELECT * FROM visitor_counter 
    WHERE ip_address = '$ip' AND tanggal = '$tanggal'
");

if(mysqli_num_rows($cek) == 0){
    mysqli_query($koneksi, "
        INSERT INTO visitor_counter (ip_address, tanggal) 
        VALUES ('$ip', '$tanggal')
    ");
}

// Hitung total pengunjung unik
$totalVisitor = mysqli_fetch_assoc(mysqli_query($koneksi, "
    SELECT COUNT(DISTINCT ip_address) as total FROM visitor_counter
"))['total'];

// Hitung pengunjung hari ini
$hariIni = mysqli_fetch_assoc(mysqli_query($koneksi, "
    SELECT COUNT(DISTINCT ip_address) as total 
    FROM visitor_counter WHERE tanggal = '$tanggal'
"))['total'];
?>

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DPAD Solok Selatan | Dinas Perpustakaan dan Kearsipan Daerah</title>

<meta name="description" content="Website Resmi Dinas Perpustakaan dan Arsip Daerah Kabupaten Solok Selatan">

<link rel="icon" href="img/logo.png">

<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">

<!-- Swiper CSS untuk carousel background -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />

<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    :root {
        --primary: #1a5f4b;
        --primary-dark: #0f3b2c;
        --primary-light: #e8f5e9;
        --accent: #f5c542;
        --accent-hover: #eab308;
        --gray-50: #f9fafb;
        --gray-100: #f3f4f6;
        --gray-600: #4b5563;
        --gray-700: #374151;
        --gray-800: #1f2937;
        --white: #ffffff;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
        --radius-lg: 1rem;
        --radius-xl: 1.5rem;
    }

    html {
        scroll-behavior: smooth;
    }

    body {
        font-family: 'Inter', sans-serif;
        background: var(--white);
        color: var(--gray-800);
        line-height: 1.6;
        transition: background 0.3s, color 0.3s;
    }

    /* DARK MODE */
    body.dark-mode {
        background: #0f172a;
        color: #f1f5f9;
    }

    body.dark-mode .top-bar,
    body.dark-mode .main-header,
    body.dark-mode .card,
    body.dark-mode .search-box,
    body.dark-mode footer {
        background: #1e293b;
        color: #f1f5f9;
    }

    body.dark-mode .top-bar a,
    body.dark-mode .nav-menu a {
        color: #cbd5e1;
    }

    body.dark-mode .section-title p,
    body.dark-mode .service-card p,
    body.dark-mode .news-content p {
        color: #94a3b8;
    }

    /* CONTAINER */
    .container {
        max-width: 1280px;
        margin: 0 auto;
        padding: 0 24px;
    }

    /* ========== TOP BAR RESPONSIVE ========== */
    .top-bar {
        background: #0d6efd;
        color: #fff;
        display: flex;
        align-items: center;
        height: 45px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        position: relative;
    }

    .breaking-label {
        background: #dc3545;
        color: white;
        font-weight: 700;
        font-size: 14px;
        padding: 0 20px;
        height: 100%;
        display: flex;
        align-items: center;
        white-space: nowrap;
        letter-spacing: 1px;
        text-transform: uppercase;
        flex-shrink: 0;
    }

    .top-marquee {
        flex: 1;
        overflow: hidden;
        position: relative;
        min-width: 0;
    }

    .marquee-content {
        display: flex;
        align-items: center;
        white-space: nowrap;
        animation: marquee 35s linear infinite;
    }

    .marquee-item {
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    .marquee-item a {
        color: #fff;
        text-decoration: none;
        font-size: 14px;
        padding: 0 10px;
        transition: 0.3s;
        white-space: nowrap;
    }

    .marquee-item a:hover {
        color: #ffd700;
    }

    .separator {
        color: rgba(255,255,255,0.7);
        font-size: 18px;
        margin: 0 10px;
    }

    @keyframes marquee {
        from {
            transform: translateX(0);
        }
        to {
            transform: translateX(-50%);
        }
    }

    .marquee-content:hover {
        animation-play-state: paused;
    }

    /* ========== HEADER & NAVBAR RESPONSIVE ========== */
    .main-header {
        background: var(--white);
        position: sticky;
        top: 0;
        z-index: 999;
        box-shadow: var(--shadow-sm);
    }

    .header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 18px 0;
        gap: 15px;
    }

    /* LOGO */
    .logo-area {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
        min-width: 0;
    }

    .logo-box {
        width: 54px;
        height: 54px;
        background: linear-gradient(135deg, var(--primary), var(--primary-dark));
        border-radius: var(--radius-lg);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s, background 0.3s;
        flex-shrink: 0;
    }

    .logo-box:hover {
        transform: scale(1.02);
        background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    }

    .logo-img {
        width: 36px;
        height: 36px;
        object-fit: contain;
    }

    .logo-text h1 {
        font-size: 0.95rem;
        font-weight: 700;
        line-height: 1.25;
    }

    .logo-text span {
        font-size: 0.75rem;
        color: #64748b;
    }

    body.dark-mode .logo-text h1 {
        color: white;
    }

    /* NAVIGATION */
    .nav-menu {
        display: flex;
        align-items: center;
        gap: 22px;
        margin-left: auto;
        flex-wrap: wrap;
    }

    .nav-menu a {
        text-decoration: none;
        color: var(--gray-700);
        font-weight: 600;
        position: relative;
        transition: all 0.3s ease;
        font-size: 14px;
        white-space: nowrap;
    }

    .nav-menu a::after {
        content: '';
        position: absolute;
        left: 0;
        bottom: -6px;
        width: 0%;
        height: 3px;
        background: var(--accent);
        border-radius: 10px;
        transition: 0.3s;
    }

    .nav-menu a:hover::after {
        width: 100%;
    }

    .nav-menu a:hover {
        color: var(--primary);
        transform: translateY(-2px);
    }

    /* DROPDOWN */
    .dropdown {
        position: relative;
    }

    .dropdown-content {
        position: absolute;
        top: 100%;
        left: 0;
        background: white;
        min-width: 200px;
        border-radius: 12px;
        box-shadow: var(--shadow-lg);
        opacity: 0;
        visibility: hidden;
        transform: translateY(8px);
        transition: all 0.2s;
        z-index: 1000;
    }

    .dropdown:hover .dropdown-content {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .dropdown-content a {
        display: block;
        padding: 12px 18px;
        color: var(--gray-700);
        border-bottom: 1px solid var(--gray-100);
    }

    .dropdown-content a:hover {
        background: var(--primary-light);
        color: var(--primary);
        padding-left: 24px;
    }

    /* SEARCH & BUTTONS */
    .search-box {
        display: flex;
        background: var(--gray-100);
        border-radius: 40px;
        overflow: hidden;
        max-width: 200px;
        min-width: 120px;
    }

    .search-box input {
        border: none;
        padding: 10px 16px;
        background: transparent;
        width: 100%;
        outline: none;
        font-size: 14px;
        min-width: 60px;
    }

    .search-box button {
        background: var(--primary);
        border: none;
        padding: 0 18px;
        color: white;
        cursor: pointer;
        flex-shrink: 0;
    }

    .dark-btn {
        background: var(--primary);
        border: none;
        width: 42px;
        height: 42px;
        border-radius: 40px;
        color: white;
        cursor: pointer;
        transition: 0.2s;
        flex-shrink: 0;
    }

    .dark-btn:hover {
        background: var(--primary-dark);
    }

    .login-btn {
        background: var(--primary);
        color: white !important;
        padding: 10px 20px;
        border-radius: 40px;
        white-space: nowrap;
    }

    .login-btn:hover {
        background: var(--primary-dark);
    }

    .mobile-menu-btn {
        display: none;
        font-size: 26px;
        cursor: pointer;
        padding: 5px;
    }

    /* ========== HERO SECTION ========== */
    .hero {
        position: relative;
        padding: 70px 0;
        overflow: hidden;
        min-height: 500px;
    }

    .hero-swiper {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 0;
    }

    .hero-swiper .swiper-slide {
        position: relative;
    }

    .hero-swiper .swiper-slide::before {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(
            135deg,
            rgba(26,95,75,0.45),
            rgba(15,59,44,0.55)
        );
        z-index: 1;
    }

    .hero-swiper .swiper-slide img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        animation: zoomHero 12s ease-in-out infinite alternate;
    }

    @keyframes zoomHero {
        from {
            transform: scale(1);
        }
        to {
            transform: scale(1.12);
        }
    }

    .hero .container {
        position: relative;
        z-index: 2;
        text-align: center;
        color: white;
    }

    .hero h1 {
        font-size: 3rem;
        font-weight: 800;
        margin-bottom: 1rem;
        text-shadow: 0 4px 20px rgba(0,0,0,0.2);
    }

    .hero h2 {
        font-size: 1.8rem;
        font-weight: 600;
        margin-bottom: 1rem;
        color: var(--accent);
        text-shadow: 0 4px 20px rgba(0,0,0,0.2);
    }

    .hero p {
        max-width: 700px;
        margin: 0 auto 2rem;
        font-size: 1.125rem;
        opacity: 0.95;
    }

    .btn-group {
        display: flex;
        justify-content: center;
        gap: 1rem;
        flex-wrap: wrap;
        margin-bottom: 2rem;
    }

    .btn {
        padding: 12px 28px;
        border-radius: 40px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.3s;
        display: inline-block;
    }

    .btn-primary {
        background: var(--accent);
        color: var(--primary-dark);
    }

    .btn-primary:hover {
        background: var(--accent-hover);
        transform: translateY(-2px);
    }

    .btn-outline {
        border: 2px solid white;
        color: white;
    }

    .btn-outline:hover {
        background: white;
        color: var(--primary-dark);
        transform: translateY(-2px);
    }

    /* VISITOR COUNTER */
    .visitor-stats {
        display: inline-flex;
        gap: 32px;
        background: rgba(255,255,255,0.15);
        backdrop-filter: blur(10px);
        padding: 12px 28px;
        border-radius: 60px;
        margin-top: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .stat-item {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 0.9rem;
    }

    .stat-item i {
        font-size: 1.3rem;
        color: var(--accent);
    }

    .stat-item .number {
        font-weight: 800;
        font-size: 1.2rem;
    }

    /* ========== SECTION ========== */
    .section {
        padding: 80px 0;
    }

    .section-title {
        text-align: center;
        margin-bottom: 48px;
    }

    .section-title h2 {
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 12px;
    }

    .section-title p {
        color: var(--gray-600);
    }

    /* GRID & CARD */
    .grid {
        display: grid;
        gap: 30px;
    }

    .grid-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }

    .card {
        background: white;
        border-radius: 24px;
        overflow: hidden;
        transition: transform 0.3s, box-shadow 0.3s;
        box-shadow: var(--shadow-sm);
    }

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

    .service-card {
        text-align: center;
        padding: 32px 24px;
    }

    .service-icon {
        font-size: 48px;
        color: var(--primary);
        margin-bottom: 20px;
    }

    /* NEWS */
    .news-section {
        background: var(--gray-50);
    }

    .news-image {
        height: 200px;
        overflow: hidden;
    }

    .news-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.4s;
    }

    .card:hover .news-image img {
        transform: scale(1.05);
    }

    .news-content {
        padding: 20px;
    }

    .news-date {
        color: var(--primary);
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    .read-more {
        color: var(--primary);
        font-weight: 600;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    /* GALLERY - DIPERBAIKI HANYA 3 ITEM SEPERTI BERITA */
    .gallery-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
        margin-bottom: 40px;
    }

    .gallery-item {
        background: white;
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 5px 20px rgba(0,0,0,0.08);
        transition: all 0.4s ease;
        cursor: pointer;
    }

    .gallery-item:hover {
        transform: translateY(-8px);
        box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    }

    .image-wrapper {
        position: relative;
        overflow: hidden;
        height: 220px;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.5s ease;
    }

    .gallery-item:hover img {
        transform: scale(1.1);
    }

    .image-overlay {
        position: absolute;
        inset: 0;
        background: rgba(26, 95, 75, 0.85);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .gallery-item:hover .image-overlay {
        opacity: 1;
    }

    .image-overlay i {
        font-size: 40px;
        color: #f5c542;
    }

    .overlay-text {
        color: white;
        font-size: 0.85rem;
        font-weight: 500;
    }

    .badge-multi {
        position: absolute;
        top: 12px;
        right: 12px;
        background: rgba(0,0,0,0.7);
        backdrop-filter: blur(5px);
        padding: 5px 12px;
        border-radius: 30px;
        font-size: 0.7rem;
        color: white;
        display: flex;
        align-items: center;
        gap: 6px;
        z-index: 2;
    }

    .badge-multi i {
        color: #f5c542;
    }

    .gallery-info {
        padding: 18px;
    }

    .gallery-info h3 {
        font-size: 1rem;
        font-weight: 700;
        color: #1a5f4b;
        margin-bottom: 6px;
    }

    .tahun {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: #e8f5e9;
        padding: 4px 12px;
        border-radius: 30px;
        font-size: 0.7rem;
        color: #1a5f4b;
        margin-bottom: 10px;
    }

    .gallery-info p {
        color: #64748b;
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .view-all-container {
        text-align: center;
        margin-top: 20px;
    }

    .btn-view-all {
        display: inline-flex;
        align-items: center;
        gap: 12px;
        background: linear-gradient(135deg, #1a5f4b, #0f3b2c);
        color: white;
        padding: 12px 32px;
        border-radius: 50px;
        text-decoration: none;
        font-weight: 600;
        transition: all 0.3s;
    }

    .btn-view-all:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 20px rgba(26, 95, 75, 0.3);
        gap: 18px;
    }

    .btn-view-all i:last-child {
        transition: transform 0.3s;
    }

    .btn-view-all:hover i:last-child {
        transform: translateX(5px);
    }

    /* ========== FOOTER PREMIUM RESPONSIVE ========== */
    .footer-premium {
        background: linear-gradient(135deg, #0a3d32, #0f3b2c);
        color: #ffffff;
        position: relative;
        overflow: hidden;
        padding-top: 60px;
    }

    .footer-premium::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: linear-gradient(90deg, #f5c542, #eab308, #f5c542);
    }

    .footer-premium::after {
        content: '📚';
        position: absolute;
        bottom: 20px;
        right: 20px;
        font-size: 120px;
        opacity: 0.03;
        pointer-events: none;
    }

    .footer-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 35px;
        margin-bottom: 50px;
    }

    .footer-logo {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 20px;
    }

    .footer-logo .logo-icon {
        width: 50px;
        height: 50px;
        background: rgba(255,255,255,0.1);
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: 0.3s;
        flex-shrink: 0;
    }

    .footer-logo .logo-icon i {
        font-size: 28px;
        color: #f5c542;
    }

    .footer-logo .logo-text h3 {
        font-size: 1.1rem;
        font-weight: 700;
        margin-bottom: 4px;
    }

    .footer-logo .logo-text p {
        font-size: 0.7rem;
        opacity: 0.7;
    }

    .footer-description {
        color: #cbd5e1;
        line-height: 1.6;
        margin-bottom: 20px;
        font-size: 0.85rem;
    }

    .footer-col h3 {
        font-size: 1.1rem;
        font-weight: 700;
        margin-bottom: 25px;
        position: relative;
        display: inline-block;
        padding-bottom: 10px;
    }

    .footer-col h3::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 40px;
        height: 2px;
        background: #f5c542;
        border-radius: 2px;
    }

    .footer-col h3 i {
        margin-right: 8px;
        color: #f5c542;
    }

    .footer-menu {
        list-style: none;
    }

    .footer-menu li {
        margin-bottom: 12px;
    }

    .footer-menu li a {
        color: #cbd5e1;
        text-decoration: none;
        transition: all 0.3s;
        display: inline-flex;
        align-items: center;
        gap: 10px;
        font-size: 0.85rem;
    }

    .footer-menu li a i {
        width: 20px;
        font-size: 0.8rem;
        color: #f5c542;
        transition: 0.3s;
    }

    .footer-menu li a:hover {
        color: #f5c542;
        transform: translateX(8px);
    }

    .footer-menu li a:hover i {
        transform: scale(1.1);
    }

    /* Social Links */
    .social-links {
        display: flex;
        gap: 12px;
        margin-top: 20px;
        flex-wrap: wrap;
    }

    .social-icon {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: white;
        transition: all 0.3s ease;
        text-decoration: none;
        font-size: 1rem;
    }

    .social-fb { background: #1877f2; }
    .social-ig { background: #e4405f; }
    .social-yt { background: #ff0000; }
    .social-tt { background: #010101; }
    .social-tw { background: #1da1f2; }
    .social-wa { background: #25d366; }

    .social-icon:hover {
        transform: translateY(-5px) scale(1.1);
        filter: brightness(1.1);
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    }

    /* Map Card */
    .map-card {
        position: relative;
        margin-bottom: 20px;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    }

    .map-wrapper {
        position: relative;
    }

    .map-wrapper iframe {
        width: 100%;
        height: 150px;
        transition: 0.3s;
        display: block;
    }

    .map-wrapper:hover iframe {
        transform: scale(1.02);
    }

    .map-overlay {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
        padding: 8px 12px;
        font-size: 0.7rem;
        color: white;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .map-overlay i {
        color: #f5c542;
    }

    /* Contact Info */
    .contact-info {
        margin-top: 15px;
    }

    .contact-item {
        display: flex;
        gap: 12px;
        margin-bottom: 15px;
        padding: 8px 0;
        border-bottom: 1px dashed rgba(255,255,255,0.1);
    }

    .contact-icon {
        width: 35px;
        height: 35px;
        background: rgba(255,255,255,0.08);
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .contact-icon i {
        font-size: 16px;
        color: #f5c542;
    }

    .contact-text {
        flex: 1;
        min-width: 0;
    }

    .contact-text strong {
        display: block;
        font-size: 0.8rem;
        color: white;
        margin-bottom: 3px;
    }

    .contact-text span {
        font-size: 0.75rem;
        color: #cbd5e1;
        line-height: 1.4;
        word-wrap: break-word;
    }

    /* Footer Bottom */
    .footer-bottom {
        border-top: 1px solid rgba(255,255,255,0.08);
        padding-top: 25px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 15px;
    }

    .footer-copyright p {
        font-size: 0.75rem;
        color: #94a3b8;
        margin-bottom: 5px;
    }

    .footer-copyright a {
        color: #94a3b8;
        text-decoration: none;
        transition: 0.3s;
    }

    .footer-copyright a:hover {
        color: #f5c542;
    }

    .footer-credit {
        text-align: right;
    }

    .footer-credit p {
        font-size: 0.7rem;
        color: #64748b;
        margin-bottom: 5px;
    }

    .visitor-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: rgba(255,255,255,0.08);
        padding: 5px 12px;
        border-radius: 30px;
        font-size: 0.7rem;
        color: #f5c542;
    }

    .dev-credit {
        text-align: center;
        padding-top: 20px;
        margin-top: 20px;
        border-top: 1px solid rgba(255,255,255,0.05);
        color: #94a3b8;
        font-size: 0.75rem;
    }

    .dev-credit a {
        color: #f5c542;
        text-decoration: none;
        font-weight: 500;
        transition: 0.3s;
    }

    .dev-credit a:hover {
        color: #eab308;
        text-decoration: underline;
    }

    /* ========== MODAL GALERI ========== */
    .modal-galeri {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.95);
        z-index: 9999;
        justify-content: center;
        align-items: center;
    }

    .modal-galeri.active {
        display: flex;
    }

    .modal-galeri-content {
        max-width: 90%;
        max-height: 90%;
        position: relative;
    }

    .modal-galeri-content img {
        max-width: 100%;
        max-height: 80vh;
        object-fit: contain;
        border-radius: 12px;
    }

    .modal-galeri-close {
        position: absolute;
        top: -40px;
        right: 0;
        color: white;
        font-size: 35px;
        cursor: pointer;
        background: none;
        border: none;
    }

    .modal-galeri-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 100%;
        display: flex;
        justify-content: space-between;
        padding: 0 20px;
        pointer-events: none;
    }

    .modal-galeri-nav button {
        background: rgba(0,0,0,0.5);
        border: none;
        color: white;
        font-size: 24px;
        width: 45px;
        height: 45px;
        border-radius: 50%;
        cursor: pointer;
        pointer-events: auto;
        transition: 0.2s;
    }

    .modal-galeri-nav button:hover {
        background: #1a5f4b;
        transform: scale(1.05);
    }

    .modal-galeri-caption {
        position: absolute;
        bottom: -50px;
        left: 0;
        right: 0;
        text-align: center;
        color: white;
        background: rgba(0,0,0,0.6);
        padding: 12px;
        border-radius: 10px;
        font-size: 0.85rem;
    }

    /* ========== EMPTY GALLERY ========== */
    .empty-gallery {
        text-align: center;
        padding: 60px;
        background: #f8fafc;
        border-radius: 30px;
    }

    .empty-gallery i {
        font-size: 70px;
        color: #cbd5e1;
        margin-bottom: 20px;
    }

    .empty-gallery h3 {
        color: #1e293b;
        margin-bottom: 10px;
    }

    .empty-gallery p {
        color: #64748b;
    }

    .btn-admin-add {
        display: inline-block;
        margin-top: 20px;
        background: #1a5f4b;
        color: white;
        padding: 10px 25px;
        border-radius: 30px;
        text-decoration: none;
    }

    /* ========== RESPONSIVE ========== */
    
    /* Tablet Landscape & Small Laptop */
    @media (max-width: 1024px) {
        .grid-4 {
            grid-template-columns: repeat(2, 1fr);
        }
        
        .gallery-grid {
            grid-template-columns: repeat(2, 1fr);
        }
        
        .footer-grid {
            grid-template-columns: repeat(2, 1fr);
        }
        
        .hero h1 {
            font-size: 2.5rem;
        }
        
        .hero h2 {
            font-size: 1.5rem;
        }
        
        .search-box {
            max-width: 150px;
        }
        
        .search-box input {
            padding: 8px 12px;
            font-size: 12px;
        }
        
        .nav-menu {
            gap: 15px;
        }
        
        .nav-menu a {
            font-size: 13px;
        }
    }

    /* Tablet Portrait */
    @media (max-width: 768px) {
        .mobile-menu-btn {
            display: block;
        }
        
        .nav-menu {
            display: none;
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            width: 100%;
            background: white;
            flex-direction: column;
            padding: 20px;
            box-shadow: var(--shadow-lg);
            max-height: 80vh;
            overflow-y: auto;
        }
        
        .nav-menu.active {
            display: flex;
        }
        
        .nav-menu a {
            font-size: 14px;
            padding: 8px 0;
            width: 100%;
        }
        
        .dropdown-content {
            position: static;
            box-shadow: none;
            opacity: 1;
            visibility: visible;
            transform: none;
            padding-left: 20px;
            display: none;
        }
        
        .dropdown:hover .dropdown-content {
            display: block;
        }
        
        .search-box {
            width: 100%;
            max-width: 100%;
            margin: 5px 0;
        }
        
        .search-box input {
            width: 100%;
        }
        
        .login-btn {
            width: 100%;
            text-align: center;
        }
        
        .hero {
            padding: 40px 0;
            min-height: 400px;
        }
        
        .hero h1 {
            font-size: 1.8rem;
        }
        
        .hero h2 {
            font-size: 1.2rem;
        }
        
        .hero p {
            font-size: 0.95rem;
            padding: 0 15px;
        }
        
        .btn {
            padding: 10px 20px;
            font-size: 0.9rem;
        }
        
        .visitor-stats {
            gap: 16px;
            padding: 10px 20px;
            flex-wrap: wrap;
            justify-content: center;
        }
        
        .stat-item {
            font-size: 0.8rem;
        }
        
        .stat-item .number {
            font-size: 1rem;
        }
        
        .grid-3 {
            grid-template-columns: 1fr;
        }
        
        .gallery-grid {
            grid-template-columns: 1fr;
            gap: 20px;
        }
        
        .image-wrapper {
            height: 200px;
        }
        
        .footer-grid {
            grid-template-columns: 1fr;
            text-align: center;
            gap: 30px;
        }
        
        .footer-logo {
            justify-content: center;
        }
        
        .footer-col h3::after {
            left: 50%;
            transform: translateX(-50%);
        }
        
        .footer-menu li a {
            justify-content: center;
        }
        
        .social-links {
            justify-content: center;
        }
        
        .footer-bottom {
            flex-direction: column;
            text-align: center;
        }
        
        .footer-credit {
            text-align: center;
        }
        
        .contact-item {
            text-align: left;
            justify-content: center;
        }
        
        .section {
            padding: 50px 0;
        }
        
        .section-title h2 {
            font-size: 1.6rem;
        }
        
        .top-bar {
            height: auto;
            min-height: 40px;
            flex-wrap: wrap;
        }
        
        .breaking-label {
            font-size: 11px;
            padding: 0 12px;
            height: 40px;
        }
        
        .marquee-item a {
            font-size: 11px;
            padding: 0 8px;
        }
        
        .header-content {
            padding: 12px 0;
            flex-wrap: wrap;
        }
        
        .logo-text h1 {
            font-size: 0.8rem;
        }
        
        .logo-text span {
            font-size: 0.65rem;
        }
        
        .logo-box {
            width: 45px;
            height: 45px;
        }
        
        .logo-img {
            width: 30px;
            height: 30px;
        }
        
        .modal-galeri-nav button {
            width: 35px;
            height: 35px;
            font-size: 18px;
        }
    }

    /* Mobile Small */
    @media (max-width: 480px) {
        .container {
            padding: 0 15px;
        }
        
        .hero h1 {
            font-size: 1.5rem;
        }
        
        .hero h2 {
            font-size: 1rem;
        }
        
        .hero p {
            font-size: 0.85rem;
        }
        
        .btn-group {
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }
        
        .btn {
            width: 100%;
            max-width: 280px;
            text-align: center;
            padding: 10px 20px;
            font-size: 0.85rem;
        }
        
        .stat-item {
            font-size: 0.7rem;
        }
        
        .stat-item i {
            font-size: 1rem;
        }
        
        .stat-item .number {
            font-size: 0.9rem;
        }
        
        .visitor-stats {
            padding: 8px 15px;
            gap: 12px;
        }
        
        .section-title h2 {
            font-size: 1.3rem;
        }
        
        .gallery-info h3 {
            font-size: 0.9rem;
        }
        
        .footer-premium {
            padding-top: 40px;
        }
        
        .footer-grid {
            gap: 25px;
        }
        
        .contact-item {
            flex-direction: column;
            align-items: center;
            text-align: center;
        }
        
        .contact-icon {
            margin: 0 auto;
        }
        
        .contact-text {
            text-align: center;
        }
        
        .footer-logo .logo-text h3 {
            font-size: 0.95rem;
        }
        
        .footer-logo .logo-text p {
            font-size: 0.6rem;
        }
        
        .map-wrapper iframe {
            height: 120px;
        }
        
        .breaking-label {
            font-size: 10px;
            padding: 0 10px;
        }
        
        .marquee-item a {
            font-size: 10px;
            padding: 0 5px;
        }
        
        .separator {
            font-size: 14px;
            margin: 0 5px;
        }
        
        .logo-text h1 {
            font-size: 0.7rem;
        }
        
        .logo-box {
            width: 38px;
            height: 38px;
        }
        
        .logo-img {
            width: 25px;
            height: 25px;
        }
        
        .dark-btn {
            width: 36px;
            height: 36px;
            font-size: 14px;
        }
        
        .login-btn {
            padding: 8px 15px;
            font-size: 12px;
        }
        
        .dev-credit {
            font-size: 0.65rem;
            padding-top: 15px;
            margin-top: 15px;
        }
    }

    /* Mobile Extra Small */
    @media (max-width: 360px) {
        .logo-text h1 {
            font-size: 0.6rem;
        }
        
        .logo-text span {
            font-size: 0.55rem;
        }
        
        .logo-box {
            width: 32px;
            height: 32px;
        }
        
        .logo-img {
            width: 20px;
            height: 20px;
        }
        
        .hero h1 {
            font-size: 1.2rem;
        }
        
        .hero h2 {
            font-size: 0.9rem;
        }
        
        .visitor-stats {
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }
        
        .stat-item {
            font-size: 0.65rem;
        }
    }

    /* ========== LAYANAN WRAP ========== */
.layanan-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.layanan-wrap .section-title {
    text-align: center;
    margin-bottom: 40px;
}

.layanan-wrap .section-title h2 {
    font-size: 28px;
    font-weight: 700;
    color: #0a3d32;
    position: relative;
    display: inline-block;
    padding-bottom: 12px;
}

.layanan-wrap .section-title h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: #f5c542;
    border-radius: 3px;
}

.layanan-wrap .section-title p {
    color: #64748b;
    font-size: 16px;
    margin-top: 8px;
}

/* Layanan Grid */
.layanan-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
}

/* Layanan Card */
.layanan-card {
    background: white;
    border-radius: 16px;
    padding: 30px 25px;
    text-align: center;
    border: 1px solid #e8edf2;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.layanan-card:hover {
    transform: translateY(-8px);
    border-color: #1a5f4b;
    box-shadow: 0 12px 30px rgba(0,0,0,0.08);
}

.layanan-card .layanan-icon {
    width: 70px;
    height: 70px;
    background: #eaf5ed;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    transition: all 0.3s ease;
}

.layanan-card:hover .layanan-icon {
    background: #1a5f4b;
}

.layanan-card:hover .layanan-icon i {
    color: white;
    transform: scale(1.1);
}

.layanan-card .layanan-icon i {
    font-size: 32px;
    color: #1a5f4b;
    transition: all 0.3s ease;
}

.layanan-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: #0a3d32;
    margin-bottom: 10px;
}

.layanan-card p {
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 18px;
}

/* Layanan Link */
.layanan-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1a5f4b;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    padding: 8px 20px;
    background: #eaf5ed;
    border-radius: 30px;
}

.layanan-link:hover {
    background: #1a5f4b;
    color: white;
    gap: 14px;
}

.layanan-link i {
    transition: transform 0.3s ease;
}

.layanan-link:hover i {
    transform: translateX(4px);
}

/* ========== RESPONSIVE LAYANAN ========== */
@media (max-width: 992px) {
    .layanan-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .layanan-wrap {
        padding: 30px 15px;
    }
    
    .layanan-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .layanan-card {
        padding: 25px 20px;
    }
    
    .layanan-card .layanan-icon {
        width: 60px;
        height: 60px;
    }
    
    .layanan-card .layanan-icon i {
        font-size: 28px;
    }
    
    .layanan-card h3 {
        font-size: 16px;
    }
    
    .layanan-card p {
        font-size: 13px;
    }
    
    .layanan-link {
        font-size: 13px;
        padding: 6px 16px;
    }
    
    .layanan-wrap .section-title h2 {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .layanan-card {
        padding: 20px 15px;
    }
    
    .layanan-card .layanan-icon {
        width: 50px;
        height: 50px;
    }
    
    .layanan-card .layanan-icon i {
        font-size: 24px;
    }
    
    .layanan-card h3 {
        font-size: 15px;
    }
    
    .layanan-card p {
        font-size: 12px;
    }
    
    .layanan-link {
        font-size: 12px;
        padding: 5px 14px;
    }
}

/* ========== LAYANAN SCROLL HORIZONTAL MODERN ========== */
.layanan-wrap {
    max-width: 100%;
    padding: 40px 20px;
    position: relative;
    background: #f5f7fa;
}

body.dark-mode .layanan-wrap {
    background: #0f172a;
}

.layanan-wrap .section-title {
    text-align: center;
    margin-bottom: 30px;
}

.layanan-wrap .section-title h2 {
    font-size: 28px;
    font-weight: 700;
    color: #0a3d32;
    position: relative;
    display: inline-block;
    padding-bottom: 12px;
}

body.dark-mode .layanan-wrap .section-title h2 {
    color: white;
}

.layanan-wrap .section-title h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: #f5c542;
    border-radius: 3px;
}

.layanan-wrap .section-title p {
    color: #64748b;
    font-size: 16px;
    margin-top: 8px;
}

body.dark-mode .layanan-wrap .section-title p {
    color: #94a3b8;
}

/* ===== Tombol Navigasi Scroll ===== */
.scroll-nav {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 15px;
    padding-right: 10px;
}

.scroll-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #1a5f4b;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-btn:hover {
    background: #1a5f4b;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(26,95,75,0.3);
}

.scroll-btn:active {
    transform: scale(0.95);
}

.scroll-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

body.dark-mode .scroll-btn {
    background: #1e293b;
    color: #f1f5f9;
}

body.dark-mode .scroll-btn:hover {
    background: #1a5f4b;
    color: white;
}

/* ===== Scroll Wrapper ===== */
.layanan-scroll-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    padding: 10px 0;
}

/* Gradient Fade Effect */
.layanan-scroll-wrapper::before,
.layanan-scroll-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    z-index: 5;
    pointer-events: none;
}

.layanan-scroll-wrapper::before {
    left: 0;
    background: linear-gradient(to right, #f5f7fa, transparent);
}

.layanan-scroll-wrapper::after {
    right: 0;
    background: linear-gradient(to left, #f5f7fa, transparent);
}

body.dark-mode .layanan-scroll-wrapper::before {
    background: linear-gradient(to right, #0f172a, transparent);
}

body.dark-mode .layanan-scroll-wrapper::after {
    background: linear-gradient(to left, #0f172a, transparent);
}

/* ===== Scroll Container ===== */
.layanan-scroll-container {
    display: flex;
    gap: 25px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 20px 25px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    cursor: grab;
}

.layanan-scroll-container:active {
    cursor: grabbing;
}

/* Custom Scrollbar */
.layanan-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.layanan-scroll-container::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.layanan-scroll-container::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #1a5f4b, #f5c542);
    border-radius: 10px;
}

.layanan-scroll-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #0f3b2c, #eab308);
}

body.dark-mode .layanan-scroll-container::-webkit-scrollbar-track {
    background: #1e293b;
}

/* ===== Layanan Card ===== */
.layanan-card {
    min-width: 280px;
    max-width: 300px;
    flex: 0 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px 25px;
    text-align: center;
    border: 1px solid #e8edf2;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
}

.layanan-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1a5f4b, #f5c542);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.layanan-card:hover::before {
    opacity: 1;
}

.layanan-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: #1a5f4b;
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}

body.dark-mode .layanan-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .layanan-card h3 {
    color: #f1f5f9;
}

body.dark-mode .layanan-card p {
    color: #94a3b8;
}

.layanan-card .layanan-icon {
    width: 75px;
    height: 75px;
    background: linear-gradient(135deg, #eaf5ed, #d4e8db);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    transition: all 0.4s ease;
}

body.dark-mode .layanan-card .layanan-icon {
    background: linear-gradient(135deg, #1a5f4b, #0f3b2c);
}

.layanan-card:hover .layanan-icon {
    background: linear-gradient(135deg, #1a5f4b, #0f3b2c);
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 10px 25px rgba(26,95,75,0.3);
}

.layanan-card:hover .layanan-icon i {
    color: white;
    transform: scale(1.1);
}

.layanan-card .layanan-icon i {
    font-size: 34px;
    color: #1a5f4b;
    transition: all 0.4s ease;
}

.layanan-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: #0a3d32;
    margin-bottom: 10px;
    transition: color 0.3s ease;
}

.layanan-card:hover h3 {
    color: #1a5f4b;
}

.layanan-card p {
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 18px;
}

/* ===== Layanan Link ===== */
.layanan-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1a5f4b;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    padding: 8px 20px;
    background: #eaf5ed;
    border-radius: 30px;
}

.layanan-link:hover {
    background: linear-gradient(135deg, #1a5f4b, #0f3b2c);
    color: white;
    gap: 14px;
    box-shadow: 0 4px 15px rgba(26,95,75,0.3);
}

.layanan-link i {
    transition: transform 0.3s ease;
}

.layanan-link:hover i {
    transform: translateX(4px);
}

body.dark-mode .layanan-link {
    background: #1a5f4b;
    color: white;
}

body.dark-mode .layanan-link:hover {
    background: #f5c542;
    color: #0f3b2c;
}

/* ===== Progress Bar Scroll ===== */
.scroll-progress {
    width: 100%;
    max-width: 800px;
    margin: 20px auto 0;
    height: 4px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

body.dark-mode .scroll-progress {
    background: #1e293b;
}

.scroll-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1a5f4b, #f5c542);
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .layanan-card {
        min-width: 250px;
        max-width: 280px;
        padding: 25px 20px;
    }
}

@media (max-width: 768px) {
    .layanan-wrap {
        padding: 30px 15px;
    }
    
    .layanan-card {
        min-width: 220px;
        max-width: 250px;
        padding: 22px 18px;
    }
    
    .layanan-card .layanan-icon {
        width: 60px;
        height: 60px;
    }
    
    .layanan-card .layanan-icon i {
        font-size: 28px;
    }
    
    .layanan-card h3 {
        font-size: 16px;
    }
    
    .layanan-card p {
        font-size: 13px;
    }
    
    .layanan-link {
        font-size: 13px;
        padding: 6px 16px;
    }
    
    .layanan-wrap .section-title h2 {
        font-size: 22px;
    }
    
    .scroll-nav {
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .scroll-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .layanan-scroll-wrapper::before,
    .layanan-scroll-wrapper::after {
        width: 30px;
    }
}

@media (max-width: 480px) {
    .layanan-card {
        min-width: 190px;
        max-width: 220px;
        padding: 18px 15px;
        border-radius: 16px;
    }
    
    .layanan-card .layanan-icon {
        width: 50px;
        height: 50px;
        border-radius: 16px;
    }
    
    .layanan-card .layanan-icon i {
        font-size: 24px;
    }
    
    .layanan-card h3 {
        font-size: 14px;
    }
    
    .layanan-card p {
        font-size: 12px;
        margin-bottom: 14px;
    }
    
    .layanan-link {
        font-size: 12px;
        padding: 5px 14px;
    }
    
    .layanan-scroll-wrapper::before,
    .layanan-scroll-wrapper::after {
        width: 20px;
    }
    
    .scroll-progress {
        max-width: 100%;
        margin: 15px 10px 0;
    }
}
</style>
</head>
<body>
    
<!-- TOP BAR BREAKING NEWS -->
<div class="top-bar">
    
    <div class="breaking-label">
        BREAKING NEWS
    </div>

    <div class="top-marquee">
        <div class="marquee-content">

            <?php
            $query_berita = mysqli_query($koneksi, "SELECT judul, id FROM berita ORDER BY id DESC LIMIT 10");
            $berita_list = [];

            while($row = mysqli_fetch_array($query_berita)){
                $berita_list[] = $row;
            }

            if(count($berita_list) > 0):

                foreach($berita_list as $berita):
            ?>
                <span class="marquee-item">
                    <a href="detail_berita.php?id=<?php echo $berita['id']; ?>">
                        <?php echo htmlspecialchars($berita['judul']); ?>
                    </a>
                    <span class="separator">|</span>
                </span>
            <?php endforeach; ?>

            <?php foreach($berita_list as $berita): ?>
                <span class="marquee-item">
                    <a href="detail_berita.php?id=<?php echo $berita['id']; ?>">
                        <?php echo htmlspecialchars($berita['judul']); ?>
                    </a>
                    <span class="separator">|</span>
                </span>
            <?php endforeach; ?>

            <?php else: ?>

                <span class="marquee-item">
                    Selamat Datang di Website Resmi DPAD Solok Selatan
                    <span class="separator">|</span>
                </span>

                <span class="marquee-item">
                    dpad.solsel@gmail.com
                    <span class="separator">|</span>
                </span>

                <span class="marquee-item">
                    Hubungi: 0812-0000-0000
                    <span class="separator">|</span>
                </span>

            <?php endif; ?>

        </div>
    </div>

</div>
<!-- MAIN HEADER -->
<header class="main-header">
    <div class="container header-content">
        <div class="logo-area">
            <div class="logo-box">
                <?php if(file_exists("img/logo.png")): ?>
                    <img src="img/logo.png" alt="Logo DPAD" class="logo-img">
                <?php else: ?>
                    <i class="fas fa-archive" style="font-size: 28px; color: var(--accent);"></i>
                <?php endif; ?>
            </div>
            <div class="logo-text">
                <h1>DINAS KEARSIPAN<br>KABUPATEN SOLOK SELATAN</h1>
                <span>Dinas Perpustakaan dan Arsip Daerah</span>
            </div>
        </div>

        <div class="mobile-menu-btn" id="menuBtn">
            <i class="fas fa-bars"></i>
        </div>

        <nav class="nav-menu" id="navMenu">
            <a href="#">Beranda</a>
            <div class="dropdown">
                <a href="#" class="dropdown-btn">Profil <i class="fas fa-caret-down"></i></a>
                <div class="dropdown-content">
                    <a href="sejarah.php">Sejarah</a>
                    <a href="visi.php">Visi & Misi</a>
                    <a href="tugas_poko_fungsi.php">Tugas Pokok dan Fungsi</a>
                    <a href="struktur.php">Struktur Organisasi</a>
                    <a href="profil_istansi.php">Profil Instansi</a>
                </div>
            </div>
            <div class="dropdown">
                <a href="#" class="dropdown-btn">Layanan <i class="fas fa-caret-down"></i></a>
                <div class="dropdown-content">
                    <a href="https://perpustakaan.solselkab.go.id/">Perpustakaan</a>
                    <a href="layanan_arsip.php">Kearsipan</a>
                    <a href="layanan_kunjungan.php">Kunjungan</a>
                    <a href="pengaduan.php">Pengaduan Masyarakat</a>
                    <a href="layanan_konsultasi.php">Konsultasi Arsip</a>
                </div>
            </div>
            <a href="berita.php">Berita</a>

            <div class="dropdown">
                <a href="#" class="dropdown-btn">Galeri <i class="fas fa-caret-down"></i></a>
                <div class="dropdown-content">
                    <a href="sejarah_poto.php">Arsip Foto</a>
                    <a href="sejarah_video.php">Video</a>
                </div>
            </div>

          <form class="search-box" action="berita.php" method="GET">
    <input type="text" name="keyword" placeholder="Cari berita..." required>
    <button type="submit">
        <i class="fas fa-search"></i>
    </button>
</form>
            <button class="dark-btn" onclick="toggleDarkMode()" id="themeBtn">
                <i class="fas fa-moon" id="themeIcon"></i>
            </button>
            <a href="admin/login.php" class="login-btn"><i class="fas fa-user-shield"></i> Login</a>
        </nav>
    </div>
</header>

<!-- HERO SECTION WITH AUTO SLIDE BACKGROUND -->
<section class="hero">
    <!-- Swiper Background Slider (Auto Slide) -->
    <div class="swiper hero-swiper">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <img src="img/poto.png" alt="Background 1" onerror="this.src='https://images.unsplash.com/photo-1524995997946-a1c2e315a42f?w=1600'">
            </div>
            <div class="swiper-slide">
                <img src="img/arsip.png" alt="Background 2" onerror="this.src='https://images.unsplash.com/photo-1503676260728-1c00da094a0b?w=1600'">
            </div>
            <div class="swiper-slide">
                <img src="img/pak.jpeg" alt="Background 3" onerror="this.src='https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?w=1600'">
            </div>
            <div class="swiper-slide">
                <img src="img/pak2.jpeg" alt="Background 3" onerror="this.src='https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?w=1600'">
            </div>
        </div>
    </div>
    <div class="container">
        <div class="hero-content" data-aos="fade-up">
            <h1>Selamat Datang di Website <br>Dinas Perpustakaan dan Kearsipan Solok Selatan</h1>
            <h2>Bidang Kearsipan</h2>
            <p>Mewujudkan masyarakat yang cerdas, literat, dan berbudaya melalui pelayanan perpustakaan serta kearsipan modern.</p>
            <div class="btn-group">
                <a href="https://perpustakaan.solselkab.go.id/" class="btn btn-primary">Perpustakaan</a>
                <a href="layanan_arsip.php" class="btn btn-outline">Layanan Arsip</a>
            </div>
            <!-- VISITOR COUNTER OTOMATIS -->
            <div class="visitor-stats">
                <div class="stat-item">
                    <i class="fas fa-users"></i>
                    <span class="number"><?php echo number_format($totalVisitor); ?></span>
                    <span>Total Pengunjung</span>
                </div>
                <div class="stat-item">
                    <i class="fas fa-globe"></i>
                    <span class="number">Online</span>
                    <span>Aktif</span>
                </div>
            </div>
        </div>
    </div>
</section>
<!-- LAYANAN -->
<div class="layanan-wrap">
    <div class="section-title">
        <h2>Layanan Unggulan</h2>
        <p>Pelayanan publik terbaik untuk masyarakat</p>
    </div>

    <!-- Tombol Navigasi Scroll -->
    <div class="scroll-nav">
        <button class="scroll-btn scroll-left" id="scrollLeft">
            <i class="fas fa-chevron-left"></i>
        </button>
        <button class="scroll-btn scroll-right" id="scrollRight">
            <i class="fas fa-chevron-right"></i>
        </button>
    </div>

    <!-- Wrapper untuk scroll horizontal -->
    <div class="layanan-scroll-wrapper">
        <div class="layanan-scroll-container" id="layananScroll">
            <!-- Layanan 1: Perpustakaan -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-book"></i></div>
                <h3>Perpustakaan</h3>
                <p>Layanan koleksi buku dan perpustakaan digital untuk masyarakat.</p>
                <a href="https://perpustakaan.solselkab.go.id/read/166/bidang-kearsipan" class="layanan-link" target="_blank">Kunjungi <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 2: Kearsipan -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-archive"></i></div>
                <h3>Kearsipan</h3>
                <p>Pengelolaan arsip dan dokumen daerah secara tertib dan aman.</p>
                <a href="layanan_arsip.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 3: Kunjungan -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-users"></i></div>
                <h3>Kunjungan</h3>
                <p>Layanan kunjungan edukasi dan studi banding ke perpustakaan.</p>
                <a href="layanan_kunjungan.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 4: Konsultasi -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-comments"></i></div>
                <h3>Konsultasi</h3>
                <p>Konsultasi dan pengaduan layanan publik secara profesional.</p>
                <a href="layanan_konsultasi.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 5: Digitalisasi -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-laptop"></i></div>
                <h3>Digitalisasi Arsip</h3>
                <p>Pengalihan arsip konvensional ke digital untuk kemudahan akses.</p>
                <a href="layanan_digitalisasi.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 6: Bimbingan Teknis -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-chalkboard-user"></i></div>
                <h3>Bimbingan Teknis</h3>
                <p>Pelatihan dan pendampingan pengelolaan arsip bagi aparatur daerah.</p>
                <a href="layanan_bimtek.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 7: Akses Arsip -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-search"></i></div>
                <h3>Akses Arsip</h3>
                <p>Pelayanan akses arsip bagi masyarakat dan peneliti.</p>
                <a href="layanan_akses.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>

            <!-- Layanan 8: Pengaduan -->
            <div class="layanan-card">
                <div class="layanan-icon"><i class="fas fa-headset"></i></div>
                <h3>Pengaduan</h3>
                <p>Layanan pengaduan masyarakat untuk pelayanan publik.</p>
                <a href="pengaduan.php" class="layanan-link">Selengkapnya <i class="fas fa-arrow-right"></i></a>
            </div>
        </div>
    </div>

    <!-- Progress Bar Scroll -->
    <div class="scroll-progress">
        <div class="scroll-progress-bar" id="scrollProgress"></div>
    </div>
</div>

<!-- BERITA -->
<section class="section news-section" id="berita">
    <div class="container">
        <div class="section-title" data-aos="fade-up">
            <h2>Berita Terbaru</h2>
            <p>Informasi terbaru kegiatan</p>
        </div>
        <div class="grid grid-3" id="newsContainer">
            <?php
            $berita = mysqli_query($koneksi, "SELECT * FROM berita ORDER BY id DESC LIMIT 3");
            while($row = mysqli_fetch_array($berita)):
                $gambarArray = explode(',', $row['gambar']);
                $gambarPertama = trim($gambarArray[0]);
            ?>
            <div class="card news-card" data-aos="fade-up">
                <div class="news-image">
                    <?php if(!empty($gambarPertama) && file_exists("img/".$gambarPertama)): ?>
                        <img src="img/<?php echo $gambarPertama; ?>" alt="<?php echo htmlspecialchars($row['judul']); ?>">
                    <?php else: ?>
                        <img src="https://placehold.co/600x400/1a5f4b/white?text=DPAD+News" alt="Default Image">
                    <?php endif; ?>
                </div>
                <div class="news-content">
                    <div class="news-date"><i class="far fa-calendar-alt"></i> <?php echo date('d F Y', strtotime($row['tanggal'])); ?></div>
                    <h3><?php echo htmlspecialchars($row['judul']); ?></h3>
                    <p><?php echo substr(strip_tags($row['isi']), 0, 100); ?>...</p>
                    <a href="detail_berita.php?id=<?php echo $row['id']; ?>" class="read-more">Baca Selengkapnya <i class="fas fa-arrow-right"></i></a>
                </div>
            </div>
            <?php endwhile; ?>
        </div>
    </div>
</section>

<!-- GALERI KEGIATAN (HANYA 3 ITEM SEPERTI BERITA) -->
<section class="section">
    <div class="container">
        <div class="section-title" data-aos="fade-up">
            <h2>Galeri Arsip</h2>
            <p>Dokumentasi kegiatan Arsip sejarah yang ada di Solok Selatan</p>
        </div>
        
        <?php
        // Ambil data arsip foto untuk ditampilkan di galeri (LIMIT 3 seperti berita)
        $query_galeri = mysqli_query($koneksi, "SELECT * FROM arsip_foto ORDER BY id DESC LIMIT 3");
        
        if(mysqli_num_rows($query_galeri) > 0):
        ?>
        <div class="gallery-grid">
            <?php while($row = mysqli_fetch_array($query_galeri)):
                $fotoArray = explode(',', $row['foto']);
                $fotoArray = array_map('trim', $fotoArray);
                $fotoArray = array_filter($fotoArray);
                $fotoPertama = reset($fotoArray);
                $jumlahFoto = count($fotoArray);
                $jsonFoto = json_encode(array_values($fotoArray));
            ?>
            <div class="gallery-item" data-aos="fade-up" data-aos-delay="50"
                 data-foto='<?php echo $jsonFoto; ?>'
                 data-judul="<?php echo htmlspecialchars($row['judul']); ?>"
                 data-deskripsi="<?php echo htmlspecialchars($row['deskripsi']); ?>"
                 data-tahun="<?php echo $row['tahun'] ?: 'Tidak diketahui'; ?>"
                 onclick="openGaleriModal(this)">
                <div class="image-wrapper">
                    <?php if($fotoPertama && file_exists("img/arsip/".$fotoPertama)): ?>
                        <img src="img/arsip/<?php echo $fotoPertama; ?>" alt="<?php echo htmlspecialchars($row['judul']); ?>">
                    <?php else: ?>
                        <img src="https://placehold.co/600x400/1a5f4b/white?text=DPAD+Galeri" alt="Galeri">
                    <?php endif; ?>
                    <?php if($jumlahFoto > 1): ?>
                        <div class="badge-multi">
                            <i class="fas fa-images"></i> <?php echo $jumlahFoto; ?> foto
                        </div>
                    <?php endif; ?>
                </div>
                <div class="gallery-info">
                    <h3><?php echo htmlspecialchars($row['judul']); ?></h3>
                    <div class="tahun">
                        <i class="fas fa-calendar-alt"></i> 
                        <?php echo $row['tahun'] ?: 'Tidak diketahui'; ?>
                    </div>
                    <p><?php echo nl2br(htmlspecialchars(substr($row['deskripsi'], 0, 100))); ?>...</p>
                </div>
            </div>
            <?php endwhile; ?>
        </div>
        
        <!-- Tombol Lihat Semua Arsip -->
        <div class="view-all-container" data-aos="fade-up">
            <a href="sejarah_poto.php" class="btn-view-all">
                <i class="fas fa-images"></i> Lihat Semua Arsip Foto
                <i class="fas fa-arrow-right"></i>
            </a>
        </div>
        
        <?php else: ?>
        <!-- Jika belum ada data -->
        <div class="empty-gallery" data-aos="fade-up">
            <i class="fas fa-camera"></i>
            <h3>Belum Ada Galeri</h3>
            <p>Belum ada dokumentasi kegiatan yang diunggah.</p>
            <?php if(isset($_SESSION['admin'])): ?>
                <a href="admin/arsip_foto.php" class="btn-admin-add">
                    <i class="fas fa-plus"></i> Tambah Galeri
                </a>
            <?php endif; ?>
        </div>
        <?php endif; ?>
    </div>
</section>

<!-- FOOTER PREMIUM -->
<footer class="footer-premium">
    <div class="container">
        <div class="footer-grid">
            <!-- TENTANG KAMI -->
            <div class="footer-col" data-aos="fade-up">
                <div class="footer-logo">
                    <div class="logo-icon">
                        <?php if(file_exists("img/logo.png")): ?>
                            <img src="img/logo.png" style="width:35px; height:35px; object-fit:contain;">
                        <?php else: ?>
                            <i class="fas fa-archive"></i>
                        <?php endif; ?>
                    </div>
                    <div class="logo-text">
                        <h3>Dinas Kearsipan Solok Selatan</h3>
                        <p>Dinas Perpustakaan & Arsip Daerah</p>
                    </div>
                </div>
                <p class="footer-description">
                    Melestarikan sejarah, menjaga arsip, dan membangun peradaban literasi untuk masyarakat Solok Selatan yang cerdas dan berbudaya.
                </p>
                <div class="social-links">
                    <a href="https://www.facebook.com/profile.php?id=61573699960407" class="social-icon social-fb"><i class="fab fa-facebook-f"></i></a>
                    <a href="https://www.instagram.com/arsip_solsel/" class="social-icon social-ig" target="_blank"><i class="fab fa-instagram"></i></a>
                    <a href="https://www.youtube.com/@pustakadpksolsel" class="social-icon social-yt"><i class="fab fa-youtube"></i></a>
                    <a href="https://www.tiktok.com/@solselnews" class="social-icon social-tt"><i class="fab fa-tiktok"></i></a>
                </div>
            </div>

            <!-- MENU CEPAT -->
            <div class="footer-col" data-aos="fade-up" data-aos-delay="100">
                <h3><i class="fas fa-link"></i> Menu Cepat</h3>
                <ul class="footer-menu">
                    <li><a href="dashboard.php"><i class="fas fa-home"></i> Beranda</a></li>
                    <li><a href="profil_istansi.php"><i class="fas fa-building"></i> Profil Instansi</a></li>
                    <li><a href="visi.php"><i class="fas fa-eye"></i> Visi & Misi</a></li>
                    <li><a href="struktur.php"><i class="fas fa-diagram-project"></i> Struktur Organisasi</a></li>
                    <li><a href="berita.php"><i class="fas fa-newspaper"></i> Berita</a></li>
                </ul>
            </div>

            <!-- LAYANAN -->
            <div class="footer-col" data-aos="fade-up" data-aos-delay="200">
                <h3><i class="fas fa-star"></i> Layanan</h3>
                <ul class="footer-menu">
                    <li><a href="https://perpustakaan.solselkab.go.id/read/166/bidang-kearsipan"><i class="fas fa-book"></i> Perpustakaan </a></li>
                    <li><a href="layanan_arsip.php"><i class="fas fa-archive"></i> Kearsipan</a></li>
                    <li><a href="layanan_kunjungan.php"><i class="fas fa-users"></i> Kunjungan Edukasi</a></li>
                    <li><a href="layanan_konsultasi.php"><i class="fas fa-comments"></i> Konsultasi Arsip</a></li>
                    <li><a href="pengaduan.php"><i class="fas fa-headset"></i> Pengaduan Masyarakat</a></li>
                </ul>
            </div>

            <!-- LOKASI & KONTAK -->
            <div class="footer-col" data-aos="fade-up" data-aos-delay="300">
                <h3><i class="fas fa-map-marker-alt"></i> Lokasi & Kontak</h3>
                
                <!-- Google Maps -->
                <div class="map-card">
                    <div class="map-wrapper">
                        <iframe 
                            src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d127628.41027355246!2d101.10841049726561!3d-1.5343267999999959!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x2e2cf506b0697671%3A0x6483adcc85c683cb!2sGedung%20layanan%20perpustakaan%20daerah%20kabupaten%20solok%20selatan!5e0!3m2!1sid!2sid!4v1780452106554!5m2!1sid!2sid" 
                            width="100%" 
                            height="150" 
                            style="border:0; border-radius: 12px;" 
                            allowfullscreen="" 
                            loading="lazy" 
                            referrerpolicy="no-referrer-when-downgrade">
                        </iframe>
                        <div class="map-overlay">
                            <i class="fas fa-map-pin"></i> Lihat Peta
                        </div>
                    </div>
                </div>

                <div class="contact-info">
                    <div class="contact-item">
                        <div class="contact-icon"><i class="fas fa-map-marker-alt"></i></div>
                        <div class="contact-text">
                            <strong>Alamat</strong>
                            <span>Jl. Lubuk Gadang - Simpang Tigo Rimbo Tangah, Sangir, Solok Selatan</span>
                        </div>
                    </div>
                    <div class="contact-item">
                        <div class="contact-icon"><i class="fas fa-phone"></i></div>
                        <div class="contact-text">
                            <strong>Telepon</strong>
                            <span>0812-0000-0000</span>
                        </div>
                    </div>
                    <div class="contact-item">
                        <div class="contact-icon"><i class="fas fa-envelope"></i></div>
                        <div class="contact-text">
                            <strong>Email</strong>
                            <span>pustaka.arsipsolsel@gmail.com</span>
                        </div>
                    </div>
                    <div class="contact-item">
                        <div class="contact-icon"><i class="fas fa-clock"></i></div>
                        <div class="contact-text">
                            <strong>Jam Kerja</strong>
                            <span>Senin - Jumat, 08:00 - 16:00 WIB</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- BOTTOM FOOTER -->
        <div class="footer-bottom">
            <div class="footer-copyright">
                <p>&copy; <?php echo date('Y'); ?> Dinas Perpustakaan dan Arsip Daerah Kabupaten Solok Selatan</p>
                <p>All Rights Reserved | <a>Kebijakan Privasi</a> | <a>Sitemap</a></p>
            </div>
            <div class="footer-credit">
                <p>Sistem Informasi Perpustakaan dan Arsip Daerah</p>
                <div class="visitor-badge">
                    <i class="fas fa-eye"></i> <?php echo number_format($totalVisitor); ?> Pengunjung
                </div>
            </div>
        </div>
        
        <!-- DEVELOPER CREDIT -->
        <div class="dev-credit">
            Developed by <a href="https://www.pnp.ac.id/download/psdku-solok-selatan/" target="_blank">PSDKU Solok Selatan</a>
            <span style="margin: 0 8px; opacity: 0.3;">|</span>
            <span style="opacity: 0.7;">Version 1.0</span>
        </div>
    </div>
</footer>

<!-- Scripts -->
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
<script>
    AOS.init({ duration: 600, once: true });
    
    // ========== LAYANAN SCROLL HORIZONTAL ==========
    const scrollContainer = document.getElementById('layananScroll');
    const scrollLeftBtn = document.getElementById('scrollLeft');
    const scrollRightBtn = document.getElementById('scrollRight');
    const progressBar = document.getElementById('scrollProgress');

    // Fungsi untuk scroll
    function scrollLayanan(direction) {
        const cardWidth = scrollContainer.querySelector('.layanan-card').offsetWidth + 25;
        const scrollAmount = cardWidth * 2;
        
        if (direction === 'left') {
            scrollContainer.scrollBy({ left: -scrollAmount, behavior: 'smooth' });
        } else {
            scrollContainer.scrollBy({ left: scrollAmount, behavior: 'smooth' });
        }
    }

    // Event listener tombol
    scrollLeftBtn.addEventListener('click', () => scrollLayanan('left'));
    scrollRightBtn.addEventListener('click', () => scrollLayanan('right'));

    // Update tombol dan progress saat scroll
    scrollContainer.addEventListener('scroll', function() {
        const maxScroll = this.scrollWidth - this.clientWidth;
        const currentScroll = this.scrollLeft;
        
        // Update progress bar
        const progress = (currentScroll / maxScroll) * 100;
        progressBar.style.width = progress + '%';
        
        // Update tombol
        scrollLeftBtn.classList.toggle('disabled', currentScroll <= 0);
        scrollRightBtn.classList.toggle('disabled', currentScroll >= maxScroll - 5);
    });

    // Inisialisasi tombol
    setTimeout(() => {
        scrollContainer.dispatchEvent(new Event('scroll'));
    }, 100);

    // ========== DRAG TO SCROLL (Mouse & Touch) ==========
    let isDragging = false;
    let startX = 0;
    let startScrollLeft = 0;

    scrollContainer.addEventListener('mousedown', function(e) {
        isDragging = true;
        startX = e.pageX;
        startScrollLeft = this.scrollLeft;
        this.style.cursor = 'grabbing';
    });

    scrollContainer.addEventListener('mouseleave', function() {
        isDragging = false;
        this.style.cursor = 'grab';
    });

    scrollContainer.addEventListener('mouseup', function() {
        isDragging = false;
        this.style.cursor = 'grab';
    });

    scrollContainer.addEventListener('mousemove', function(e) {
        if (!isDragging) return;
        e.preventDefault();
        const x = e.pageX;
        const walk = (x - startX) * 1.5;
        this.scrollLeft = startScrollLeft - walk;
    });

    // Touch support
    scrollContainer.addEventListener('touchstart', function(e) {
        isDragging = true;
        startX = e.touches[0].pageX;
        startScrollLeft = this.scrollLeft;
    });

    scrollContainer.addEventListener('touchmove', function(e) {
        if (!isDragging) return;
        const x = e.touches[0].pageX;
        const walk = (x - startX) * 1.5;
        this.scrollLeft = startScrollLeft - walk;
    });

    scrollContainer.addEventListener('touchend', function() {
        isDragging = false;
    });

    // ========== KEYBOARD SUPPORT ==========
    document.addEventListener('keydown', function(e) {
        if (e.key === 'ArrowLeft') {
            scrollLayanan('left');
            e.preventDefault();
        } else if (e.key === 'ArrowRight') {
            scrollLayanan('right');
            e.preventDefault();
        }
    });

    // ========== SWIPER HERO ==========
    const heroSwiper = new Swiper('.hero-swiper', {
        loop: true,
        autoplay: {
            delay: 4000,
            disableOnInteraction: false,
        },
        effect: 'fade',
        fadeEffect: {
            crossFade: true
        },
        speed: 1000,
    });

    // ========== MOBILE MENU ==========
    const menuBtn = document.getElementById("menuBtn");
    const navMenu = document.getElementById("navMenu");
    menuBtn.addEventListener("click", () => navMenu.classList.toggle("active"));

    // ========== DARK MODE ==========
    function toggleDarkMode() {
        document.body.classList.toggle("dark-mode");
        const icon = document.getElementById("themeIcon");
        if (document.body.classList.contains("dark-mode")) {
            icon.classList.remove("fa-moon");
            icon.classList.add("fa-sun");
            localStorage.setItem("theme", "dark");
        } else {
            icon.classList.remove("fa-sun");
            icon.classList.add("fa-moon");
            localStorage.setItem("theme", "light");
        }
    }

    // Load Dark Mode dari localStorage
    window.onload = function() {
        const theme = localStorage.getItem("theme");
        if (theme === "dark") {
            document.body.classList.add("dark-mode");
            document.getElementById("themeIcon").classList.replace("fa-moon", "fa-sun");
        }
    }

    // ========== GALERI MODAL ==========
    let currentIndex = 0;
    let currentPhotos = [];
    let currentJudul = '';
    let currentDeskripsi = '';
    let currentTahun = '';

    function openGaleriModal(element) {
        const fotoData = element.dataset.foto;
        currentPhotos = JSON.parse(fotoData);
        currentJudul = element.dataset.judul;
        currentDeskripsi = element.dataset.deskripsi;
        currentTahun = element.dataset.tahun;
        currentIndex = 0;
        
        const modal = document.getElementById('galeriModal');
        modal.classList.add('active');
        updateModalImage();
    }

    function closeGaleriModal() {
        document.getElementById('galeriModal').classList.remove('active');
    }

    function changeGaleriPhoto(direction) {
        currentIndex += direction;
        if (currentIndex < 0) currentIndex = currentPhotos.length - 1;
        if (currentIndex >= currentPhotos.length) currentIndex = 0;
        updateModalImage();
    }

    function updateModalImage() {
        const img = document.getElementById('modalImage');
        const caption = document.getElementById('modalCaption');
        const file = currentPhotos[currentIndex];
        
        if (file) {
            img.src = 'img/arsip/' + file;
            caption.innerHTML = `
                <strong>${currentJudul}</strong> 
                <span style="margin:0 10px;opacity:0.5">|</span> 
                ${currentTahun} 
                <span style="margin:0 10px;opacity:0.5">|</span> 
                ${currentIndex + 1} / ${currentPhotos.length}
                <br>
                <span style="font-size:0.8rem;opacity:0.7">${currentDeskripsi}</span>
            `;
        }
    }

    // Keyboard navigasi untuk modal
    document.addEventListener('keydown', function(e) {
        const modal = document.getElementById('galeriModal');
        if (modal.classList.contains('active')) {
            if (e.key === 'Escape') closeGaleriModal();
            if (e.key === 'ArrowLeft') changeGaleriPhoto(-1);
            if (e.key === 'ArrowRight') changeGaleriPhoto(1);
        }
    });

    // Close modal saat klik di luar gambar
    document.getElementById('galeriModal').addEventListener('click', function(e) {
        if (e.target === this) closeGaleriModal();
    });
</script>

<!-- MODAL GALERI -->
<div class="modal-galeri" id="galeriModal">
    <div class="modal-galeri-content">
        <button class="modal-galeri-close" onclick="closeGaleriModal()">×</button>
        <div class="modal-galeri-nav">
            <button onclick="changeGaleriPhoto(-1)">‹</button>
            <button onclick="changeGaleriPhoto(1)">›</button>
        </div>
        <img id="modalImage" src="" alt="Galeri">
        <div class="modal-galeri-caption" id="modalCaption"></div>
    </div>
</div>
</body>
</html>