:root {
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --primary: #3b82f6;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    
    /* Platform Colors */
    --fb: #1877F2;
    --ig: #E4405F;
    --tiktok: #000000;
    --x: #14171A;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }

body { background-color: var(--bg-body); color: var(--text-dark); padding: 20px; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* HEADER */
header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 20px; 
    flex-shrink: 0; 
    flex-wrap: wrap; /* Supaya tak pecah di mobile */
    gap: 15px;
}
h1 { font-size: 1.5rem; font-weight: 700; color: #111; margin: 0; }

.header-right {
    display: flex;
    align-items: center;
    gap: 15px; /* Jarak antara Stats dengan Bulan */
}
.controls button { padding: 8px 16px; border: 1px solid var(--border); background: var(--bg-card); cursor: pointer; border-radius: 6px; font-weight: 500; transition: 0.2s; }
.controls button:hover { background: #e5e7eb; }
#currentMonthDisplay { margin: 0 15px; font-weight: 600; font-size: 1.1rem; }

/* MAIN LAYOUT (Split View) */
.app-container { display: flex; gap: 20px; flex: 1; overflow: hidden; }

/* LEFT: PHONE PREVIEW */
.preview-pane {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.phone-mockup {
    width: 100%;
    height: 100%;
    background: #fff;
    border: 12px solid #2d2d2d;
    border-radius: 35px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.phone-header {
    background: #fff;
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}
.phone-header span { font-weight: 700; font-size: 1rem; }
.view-toggles button { background: none; border: none; cursor: pointer; color: #ccc; font-size: 1.1rem; padding: 4px 8px; transition: 0.2s; }
.view-toggles button.active { color: var(--primary); }

.phone-content {
    flex: 1;
    overflow-y: auto;
    background: #fafafa;
    padding-bottom: 20px;
}
.phone-content::-webkit-scrollbar { width: 0px; background: transparent; } /* Hide scrollbar for cleaner look */

/* --- FEED VIEW STYLES --- */
.feed-item {
    background: #fff;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}
.feed-header { padding: 10px; display: flex; align-items: center; gap: 10px; }
.feed-avatar { width: 32px; height: 32px; border-radius: 50%; background: #ddd; }
.feed-user { font-weight: 600; font-size: 0.9rem; }
.feed-img { width: 100%; height: auto; display: block; min-height: 200px; background: #eee; object-fit: cover; }
.feed-actions { padding: 10px; display: flex; gap: 15px; font-size: 1.2rem; }
.feed-caption { padding: 0 10px 15px 10px; font-size: 0.9rem; line-height: 1.4; }
.feed-date { color: #999; font-size: 0.75rem; margin-top: 5px; display: block; text-transform: uppercase; }
.platform-badge { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; color: white; margin-left: auto; }

/* --- GRID VIEW STYLES (NEW) --- */
.phone-content.grid-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    background: #fff;
    align-content: start;
}
.grid-item {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5; /* TUKAR KEPADA 4:5 (Instagram Portrait) */
    background: #eee;
    overflow: hidden;
    cursor: pointer;
}
.grid-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.grid-item:hover img { transform: scale(1.05); }
/* Placeholder for posts with no image in grid view */
.grid-item.no-image { display: flex; justify-content: center; align-items: center; color: #ccc; font-size: 1.5rem; flex-direction: column; gap: 5px; }
.grid-item-type-icon { position: absolute; top: 8px; right: 8px; color: white; text-shadow: 0 1px 3px rgba(0,0,0,0.6); font-size: 0.9rem; }
/* PREVIEW DONE INDICATORS */
.grid-done-icon { 
    position: absolute; top: 5px; left: 5px; 
    background: #10b981; color: white; 
    width: 22px; height: 22px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 0.75rem; z-index: 5; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.feed-done-icon { color: #10b981; margin-left: auto; margin-right: 8px; font-size: 1.2rem; }


/* RIGHT: CALENDAR GRID */
.calendar-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-card); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); }

.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: #f9fafb; border-bottom: 1px solid var(--border); }
.weekdays div { padding: 12px; text-align: center; font-weight: 600; color: var(--text-light); font-size: 0.85rem; letter-spacing: 0.5px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; overflow-y: auto; }

.day-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 100px; padding: 8px; position: relative; transition: background 0.2s; background: #fff; }
.day-cell:hover { background-color: #f8fafc; }
.day-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.day-number { font-weight: 600; font-size: 0.9rem; color: var(--text-light); }
.add-btn { opacity: 0; cursor: pointer; color: var(--primary); font-size: 1.2rem; border: none; background: none; transition: 0.2s; }
.day-cell:hover .add-btn { opacity: 1; }

/* POST CARDS (Mini) */
.post-card { background: white; border: 1px solid #e2e8f0; border-left: 3px solid transparent; border-radius: 4px; padding: 4px; margin-bottom: 4px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,0.05); font-size: 0.75rem; display: flex; gap: 6px; align-items: center; transition: transform 0.1s; }
.post-card:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.post-card:active { cursor: grabbing; }
.post-card img { width: 24px; height: 24px; object-fit: cover; border-radius: 3px; background: #eee; flex-shrink: 0; }
/* DONE STATUS STYLES */
.post-card.done { background-color: #dcfce7; border-color: #86efac; } /* Light Green */
/* LABEL TAG STYLE */
.post-label { 
    display: inline-block; 
    font-size: 0.65rem; 
    background-color: #e0f2fe; 
    color: #0369a1; 
    padding: 1px 6px; 
    border-radius: 4px; 
    font-weight: 600;
    margin-bottom: 3px;
    text-transform: uppercase;
}
.post-card.done .post-label { background-color: #fff; color: #15803d; border: 1px solid #bbf7d0; }
.post-card.done .post-info { color: #166534; font-weight: 600; }
.status-btn { 
    border: none; background: none; cursor: pointer; color: #cbd5e1; 
    font-size: 1rem; padding: 0 4px; transition: 0.2s;
}
.status-btn:hover { color: #10b981; }
.post-card.done .status-btn { color: #15803d; }
.post-info { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* MODAL */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(2px); }
.modal.active { display: flex; }
.modal-content { 
    background: var(--bg-card); 
    width: 450px; 
    max-width: 90%; 
    padding: 20px; /* Kurangkan padding sikit */
    border-radius: 12px; 
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); 
    
    /* Ini memastikan modal boleh scroll jika terlalu tinggi */
    max-height: 90vh; 
    overflow-y: auto; 
}
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9rem; }
.form-control { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* DRAG DROP ZONE (Compact) */
.drop-zone { border: 2px dashed var(--border); padding: 10px; text-align: center; border-radius: 6px; cursor: pointer; transition: 0.2s; color: var(--text-light); font-size: 0.85rem; }
.drop-zone:hover, .drop-zone.highlight { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
/* GANTI KOD .preview-img TADI DENGAN BLOK INI: */

/* --- MODAL PREVIEW GRID --- */
.preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px; /* Jarakkan sikit */
    margin-top: 10px;
    justify-content: center;
}

/* Wrapper untuk setiap gambar */
.preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    cursor: grab; /* Tunjuk tangan terbuka */
    transition: transform 0.2s, opacity 0.2s;
}

.preview-item:active {
    cursor: grabbing; /* Tunjuk tangan menggenggam bila klik */
}

/* Style bila gambar sedang ditarik */
.preview-item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
    border: 2px dashed #3b82f6;
}

.preview-thumb {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Butang X kecil di bucu */
.btn-delete-single {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    transition: 0.2s;
}
.btn-delete-single:hover {
    transform: scale(1.1);
    background: #dc2626;
}
.btn-clear-img {
    margin-top: 10px;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
}

/* --- FEED SLIDER (CAROUSEL) --- */
.slider-container {
    width: 100%;
    overflow-x: auto;
    display: flex;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    align-items: center; /* PENTING: Supaya gambar tak distorted jika saiz beza */
}
.slider-container::-webkit-scrollbar { 
    display: none; /* Chrome/Safari hide scrollbar */
}

.slider-item {
    min-width: 100%; /* Pastikan satu gambar penuh lebar */
    scroll-snap-align: start;
    position: relative;
}

.slider-img {
    width: 100%;
    height: auto; /* Auto height untuk support 1:1, 4:5 dan 9:16 */
    display: block;
    object-fit: cover; 
    /* Naikkan limit tinggi supaya 9:16 muat cantik dalam preview */
    max-height: 750px; 
    background: #f0f0f0;
}

/* Indicator Bulat Kecil (Dots) di atas gambar */
.slider-indicator {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 5;
}
.dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
}
.dot.active {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Multiple Icon Overlay */
.multiple-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

/* Slider Navigation Buttons (Panah Kiri/Kanan) */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.7); /* Putih lutsinar */
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: 0.2s;
    backdrop-filter: blur(2px);
}
.slider-btn:hover { background: #fff; transform: translateY(-50%) scale(1.1); }
.slider-btn:active { transform: translateY(-50%) scale(0.95); }

.slider-btn.prev { left: 10px; }
.slider-btn.next { right: 10px; }

.btn-group { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #e5e7eb; color: var(--text-dark); }
.btn-danger { background: #fee2e2; color: #ef4444; margin-right: auto; }

/* Responsive */
@media (max-width: 1024px) {
    .app-container { flex-direction: column-reverse; overflow-y: auto; }
    .preview-pane { width: 100%; height: 500px; }
    .phone-mockup { border-width: 0; border-radius: 12px; }
    .calendar-container { min-height: 500px; }
}
@media (max-width: 768px) {
    .weekdays div { font-size: 0.7rem; padding: 5px; }
    .calendar-grid { grid-template-columns: 1fr; } 
    .day-cell { min-height: auto; }
}
/* --- LOGIN PAGE STYLES (PREMIUM) --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    font-family: 'Inter', sans-serif;
}

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

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-header {
    margin-bottom: 30px;
}

.login-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 15px auto;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1f2937;
    margin-bottom: 5px;
}

.login-subtitle {
    color: #6b7280;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    display: block;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.form-control:focus {
    border-color: #3b82f6;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -5px rgba(37, 99, 235, 0.5);
}

.btn-login:active {
    transform: translateY(0);
}

.alert-error {
    background: #fef2f2;
    color: #ef4444;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    border: 1px solid #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Style Button Logout di Header Utama (Kekal) */
.btn-logout {
    display: inline-block;
    padding: 8px 12px;
    margin-left: 10px;
    border: 1px solid #fee2e2;
    background: #fff;
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: 0.2s;
}
.btn-logout:hover { background: #fee2e2; }

/* --- DASHBOARD STATS (COMPACT ROW) --- */
.dashboard-stats {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stat-item {
    display: flex;
    align-items: center; /* Susun label & nombor sebaris */
    gap: 6px;
    padding: 6px 12px; /* Padding mirip button bulan */
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid transparent;
    height: 38px; /* Paksa tinggi sama dengan button controls */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    margin: 0;
    opacity: 0.9;
}

.stat-value {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
}

/* Warna Tema Statistik */
.stat-item.total { background-color: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.stat-item.done { background-color: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.stat-item.pending { background-color: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* Responsive Mobile */
@media (max-width: 768px) {
    header { flex-direction: column; align-items: flex-start; }
    .header-right { width: 100%; flex-direction: column-reverse; align-items: stretch; }
    .dashboard-stats { justify-content: space-between; }
    .stat-item { flex: 1; justify-content: center; }
    .controls { justify-content: space-between; width: 100%; }
}