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

:root {
    --primary-bg: #f4f6f8;
    --text-color: #333;
    --card-bg: #fff;
    --line-color: #ddd;
    --accent-yellow: #f1c40f;
    --accent-orange: #e67e22;
    --accent-teal: #1abc9c;
    --accent-purple: #9b59b6;
    --accent-green: #2ecc71;
    --form-bg: #ffffff;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-color);
    padding-bottom: 350px; /* Space for the sticky form */
}

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

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5rem;
    text-transform: uppercase;
}

.subtitle {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 50px;
    font-size: 1.2rem;
}

/* Timeline Styles */
.timeline {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.timeline::after {
    content: '';
    position: absolute;
    width: 6px;
    background-color: var(--line-color);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -3px;
    border-radius: 3px;
}

.timeline-event {
    padding: 10px 40px;
    position: relative;
    background-color: inherit;
    width: 50%;
}

.timeline-event.left {
    left: 0;
}

.timeline-event.right {
    left: 50%;
}

/* Dot on the timeline */
.timeline-event::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    right: -10px;
    background-color: white;
    border: 4px solid var(--accent-yellow);
    top: 30px;
    border-radius: 50%;
    z-index: 1;
}

.timeline-event.right::after {
    left: -10px;
}

/* Cycle colors for dots based on nth-child */
.timeline-event:nth-child(1)::after { border-color: var(--accent-yellow); }
.timeline-event:nth-child(2)::after { border-color: var(--accent-orange); }
.timeline-event:nth-child(3)::after { border-color: var(--accent-teal); }
.timeline-event:nth-child(4)::after { border-color: var(--accent-purple); }
.timeline-event:nth-child(5)::after { border-color: var(--accent-green); }

/* Year display next to dot */
.year-display {
    position: absolute;
    top: 25px;
    font-weight: bold;
    font-size: 1.5rem;
    color: #7f8c8d;
}

.timeline-event.left .year-display {
    right: -70px;
    transform: rotate(-90deg);
}

.timeline-event.right .year-display {
    left: -70px;
    transform: rotate(-90deg);
}

/* Content Card */
.content {
    padding: 20px;
    background-color: var(--accent-yellow);
    position: relative;
    border-radius: 8px;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.content:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.timeline-event:nth-child(1) .content { background-color: var(--accent-yellow); }
.timeline-event:nth-child(2) .content { background-color: var(--accent-orange); }
.timeline-event:nth-child(3) .content { background-color: var(--accent-teal); }
.timeline-event:nth-child(4) .content { background-color: var(--accent-purple); }
.timeline-event:nth-child(5) .content { background-color: var(--accent-green); }

/* Triangle pointing to line */
.content::before {
    content: " ";
    height: 0;
    position: absolute;
    top: 26px;
    width: 0;
    z-index: 1;
    border: medium solid white;
}

.timeline-event.left .content::before {
    right: -10px;
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent var(--accent-yellow);
}

.timeline-event.right .content::before {
    left: -10px;
    border-width: 10px 10px 10px 0;
    border-color: transparent var(--accent-orange) transparent transparent;
}

/* Make triangle colors match */
.timeline-event:nth-child(1).left .content::before { border-color: transparent transparent transparent var(--accent-yellow); }
.timeline-event:nth-child(2).right .content::before { border-color: transparent var(--accent-orange) transparent transparent; }
.timeline-event:nth-child(3).left .content::before { border-color: transparent transparent transparent var(--accent-teal); }
.timeline-event:nth-child(4).right .content::before { border-color: transparent var(--accent-purple) transparent transparent; }
.timeline-event:nth-child(5).left .content::before { border-color: transparent transparent transparent var(--accent-green); }


.content h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    margin-top: 0;
}

.content p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 15px;
}

.media-container {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.media-container img {
    max-width: 100%;
    border-radius: 4px;
}

.btn-evidence {
    display: inline-block;
    padding: 8px 12px;
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-evidence:hover {
    background: rgba(255,255,255,0.4);
}

/* Sticky Bottom Form */
.sticky-form-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--form-bg);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    padding: 20px;
    border-top: 1px solid #eee;
}

.form-wrapper {
    max-width: 1000px;
    margin: 0 auto;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.form-header h3 {
    color: #2c3e50;
    font-size: 1.2rem;
    margin: 0;
}

#form-close-mobile {
    display: none;
    font-size: 1.5rem;
    color: #e74c3c;
    font-weight: bold;
    cursor: pointer;
}

form {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr auto;
    gap: 15px;
    align-items: start;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #555;
    font-weight: 600;
}

input[type="date"],
textarea,
input[type="file"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}

textarea {
    resize: none;
    height: 42px;
}

button[type="submit"] {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    height: 42px;
    align-self: end;
    transition: background-color 0.2s;
}

button[type="submit"]:hover {
    background-color: #2980b9;
}

.alert {
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 4px;
    text-align: center;
}
.alert-success { background-color: #d4edda; color: #155724; }
.alert-danger { background-color: #f8d7da; color: #721c24; }

/* Mobile FAB Button */
#mobile-add-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--accent-orange);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 999;
    cursor: pointer;
}

/* ========================================
   MOBILE LAYOUT — CENTERED TIMELINE
   Layar HP ~400px. Kalkulasi per elemen:
   ┌─────────────────────────────────────┐
   │  BOX KIRI  │ LINE │  BOX KANAN     │
   │  ~46%      │ 2px  │  ~46%          │
   │  ~184px    │      │  ~184px        │
   └─────────────────────────────────────┘
   - Garis   : 2px, left:50%
   - Dot      : 10px, center di garis
   - Box kiri : width 46%, padding-right 14px
   - Box kanan: width 46%, padding-left 14px
   - Font tanggal  : 0.78rem bold
   - Font deskripsi: 0.7rem
   - Tombol Edit/Hapus: ikon-only, 0.6rem
   ======================================== */
@media screen and (max-width: 768px) {

    /* Container */
    .container {
        padding: 15px 4px;
    }
    h1 { font-size: 1.2rem; }
    .subtitle { font-size: 0.8rem; margin-bottom: 18px; }

    /* Timeline full-width */
    .timeline { max-width: 100%; }

    /* Garis tetap di tengah */
    .timeline::after {
        left: 50%;
        width: 2px;
        margin-left: -1px;
    }

    /* Semua event: tetap 50%, alternating kiri-kanan */
    .timeline-event       { width: 50%; padding: 6px 14px 6px 6px; }
    .timeline-event.left  { left: 0;   padding: 6px 14px 6px 6px; }
    .timeline-event.right { left: 50%; padding: 6px 6px 6px 14px; }

    /* Dot: 10px, center pada garis */
    .timeline-event::after {
        width: 10px; height: 10px;
        right: -5px; top: 16px;
        border-width: 2px;
    }
    .timeline-event.right::after {
        left: -5px; right: auto;
    }

    /* Sembunyikan label tahun vertikal (info tahun ada di dalam h2) */
    .year-display { display: none !important; }

    /* Box konten: padding rapat */
    .content {
        padding: 7px 8px;
        border-radius: 6px;
        overflow: hidden;
    }

    /* Tombol Edit/Hapus di bagian bawah box, mobile */
    .action-buttons {
        margin-top: 8px;
        padding-top: 6px;
        gap: 5px;
    }
    .btn-action {
        padding: 4px 9px;
        font-size: 0.7rem;
        border-radius: 4px;
        line-height: 1.4;
    }

    .content h2 {
        font-size: 0.78rem;
        font-weight: 700;
        margin: 0 0 3px 0;
        line-height: 1.25;
        word-break: break-word;
    }

    /* Deskripsi */
    .content p {
        font-size: 0.68rem;
        line-height: 1.35;
        margin-bottom: 6px;
        word-break: break-word;
    }

    /* Foto: 1 per baris agar tidak sempit */
    .photo-grid {
        flex-direction: column;
        gap: 4px;
    }
    .photo-grid img {
        width: 100%;
        height: 70px;
        object-fit: cover;
        border-radius: 4px;
    }

    /* Tombol bukti PDF */
    .btn-evidence {
        display: block;
        font-size: 0.65rem;
        padding: 5px 6px;
        text-align: center;
        word-break: break-word;
        line-height: 1.3;
    }

    /* Segitiga kiri (kanan dari center) */
    .timeline-event.left .content::before {
        right: -8px; top: 14px;
        border-width: 6px 0 6px 8px;
    }
    /* Segitiga kanan (kiri dari center) */
    .timeline-event.right .content::before {
        left: -8px; right: auto; top: 14px;
        border-width: 6px 8px 6px 0;
    }

    /* Form: 1 kolom */
    form { grid-template-columns: 1fr; }

    /* FAB & form mobile */
    .sticky-form-container { display: none; }
    #mobile-add-btn { display: block; }

    .sticky-form-container.mobile-active {
        display: block;
        position: fixed;
        height: 100dvh; top: 0;
        overflow-y: auto;
        padding: 30px 20px;
        background: #fff;
        z-index: 1001;
    }
    #form-close-mobile { display: block; }

    body { padding-bottom: 80px; }
}

/* Modal / Lightbox Styles */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.92);
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 60px; /* ruang untuk close button */
}

.modal.active {
    display: flex;
}

/* Zoom control bar — pill melayang di atas konten */
#zoom-controls {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.25);
}

#zoom-controls button {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 32px; height: 32px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}

#zoom-controls button:hover {
    background: rgba(255,255,255,0.45);
}

/* Garis pemisah antara +/- dan preset */
.zoom-divider {
    width: 1px;
    height: 22px;
    background: rgba(255,255,255,0.35);
    margin: 0 4px;
}

/* Tombol preset zoom: 50%, 75%, 100%, 150% */
.zoom-preset {
    width: auto !important;
    border-radius: 20px !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    font-weight: 600;
    letter-spacing: 0.02em;
    height: 32px;
    white-space: nowrap;
}

/* Tombol preset yang sedang aktif */
.zoom-preset.active {
    background: rgba(255,255,255,0.6) !important;
    color: #222 !important;
}

#zoom-label {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

.modal-content {
    position: relative;
    width: 100%;
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 2001;
}

.close-modal:hover {
    color: var(--accent-orange);
}

/* Flipbook Styles */
#flipbook-container {
    width: 800px;
    height: 600px;
    background-color: transparent;
    display: none; /* hidden by default, shown when PDF is loaded */
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.page {
    background-color: #fff;
    border: solid 1px #ccc;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.page canvas {
    width: 100%;
    height: 100%;
}

.loading-text {
    color: white;
    font-size: 1.5rem;
    display: none;
}

/* Photo Grid */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.photo-grid img {
    max-width: 150px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    transition: transform 0.2s;
}

.photo-grid img:hover {
    transform: scale(1.05);
}

/* Action Buttons — section tersendiri di bagian bawah box */
.action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.35);
}

.btn-action {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
    text-decoration: none;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.6);
}

.btn-delete:hover {
    background: rgba(231, 76, 60, 0.8);
}

.btn-cancel {
    background-color: #95a5a6 !important;
    display: none;
}
.btn-cancel:hover {
    background-color: #7f8c8d !important;
}
