:root {
    --bg: #0f172a;
    --card: #1e293b;
    --border: #334155;
    --fg: #f8fafc;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --error: #f43f5e;
}

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

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.bg-pattern {
    position: fixed; inset: 0;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(56, 189, 248, 0.05) 0%, transparent 40%);
    pointer-events: none; z-index: 0;
}

nav {
    position: relative; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.5rem 5%;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
}

.logo { display: flex; align-items: center; gap: 1.99rem; font-size: 1.99rem; font-weight: 700; }
.logo-icon {
    width: 40px; height: 40px; background: transparent;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    color: var(--bg); box-shadow: none;
}

main {
    position: relative; z-index: 10;
    max-width: 1100px; margin: 0 auto; padding: 3rem 1.5rem;
}

header { text-align: center; margin-bottom: 3rem; }
header h1 { font-size: clamp(2rem, 5vw, 3rem); margin-bottom: 0.5rem; line-height: 1.2; }
.accent { color: var(--accent); }
header p { color: var(--muted); font-size: 1.1rem; }

.container-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .container-grid { grid-template-columns: 1fr; }
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 2rem;
}

.card h2 {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.5rem; font-size: 1.25rem;
}

.icon-box {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent); display: flex; align-items: center; justify-content: center;
}

.input-group { margin-bottom: 1.25rem; }
.input-group label { display: block; font-size: 0.875rem; margin-bottom: 0.5rem; font-weight: 500; }
.req { color: var(--error); }

input[type="text"], input[type="url"], textarea {
    width: 100%; padding: 0.875rem 1rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    color: var(--fg); font-family: inherit; transition: all 0.2s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1); }

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

/* File Upload Styles */
.file-upload-box {
    display: block; padding: 1.5rem;
    border: 2px dashed var(--border); border-radius: 10px;
    text-align: center; cursor: pointer; transition: all 0.2s;
    position: relative; min-height: 150px;
}
.file-upload-box:hover { border-color: var(--accent); background: rgba(56, 189, 248, 0.05); }
.upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; color: var(--muted); }

.image-preview-container {
    position: relative; width: 100%; height: 100%;
}
.image-preview-container img {
    max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;
}
.remove-img-btn {
    position: absolute; top: -10px; right: -10px;
    width: 24px; height: 24px; background: var(--error); color: white;
    border: 2px solid var(--card); border-radius: 50%;
    cursor: pointer; font-weight: bold; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.remove-img-btn:hover { transform: scale(1.1); }

/* Custom Select Style */
.select-input {
    width: 100%; padding: 0.875rem 1rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    color: var(--fg); font-family: inherit; font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}
.select-input:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

/* Play Icon Option (UPDATED MARGIN) */
.play-icon-option {
    margin-top: 1.5rem;    /* Jarak atas ditambah */
    margin-bottom: 1.5rem; /* Jarak bawah ditambah */
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0;
}
.play-icon-option input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }
.play-icon-option label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.9rem; color: var(--fg); }
.play-icon-option svg { color: var(--muted); }

.btn-primary {
    width: 100%; padding: 1rem;
    background: var(--accent);
    color: var(--bg); font-weight: 700; font-size: 1rem;
    border: none; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(56, 189, 248, 0.3); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

/* Preview Section */
.social-preview {
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
    background: var(--bg);
}
.preview-img-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; 
    background: var(--card);
    overflow: hidden;
}

.preview-img-container img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: none;
}

.img-placeholder {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: var(--border);
}

/* Red Bar Overlay */
.red-bar-overlay {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 6px;
    background: rgba(0, 0, 0, 0.3);
    display: none; 
    z-index: 2;
}
.red-bar-overlay::after {
    content: '';
    position: absolute; left: 0; top: 0;
    width: 35%; height: 100%;
    background: #FF0000;
}

/* Play Icon Overlay di UI Preview */
.preview-img-container.has-play-icon::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 50px; height: 50px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    z-index: 3;
}
.preview-img-container.has-play-icon::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-40%, -50%);
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 18px solid white;
    z-index: 4;
    margin-left: 4px;
}

.preview-content { padding: 1rem; }
.preview-domain { font-size: 0.75rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 0.25rem; }
.preview-content h3 { font-size: 1.1rem; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-content p { font-size: 0.9rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.result-box { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.result-box label { font-size: 0.875rem; color: var(--muted); display: block; margin-bottom: 0.5rem; }
.copy-group { display: flex; gap: 0.5rem; }
.copy-group input { flex: 1; background: var(--card); }
.btn-copy {
    padding: 0 1.25rem; background: rgba(56, 189, 248, 0.1); color: var(--accent);
    border: 1px solid transparent; border-radius: 10px; cursor: pointer;
    display: flex; align-items: center; gap: 0.5rem; font-weight: 600;
    transition: all 0.2s;
}
.btn-copy:hover { background: rgba(56, 189, 248, 0.2); }

/* History Section */
.history-grid { display: grid; gap: 1rem; }
.history-item {
    background: var(--bg); border: 1px solid var(--border);
    padding: 1rem; border-radius: 10px;
    display: flex; flex-direction: column; gap: 0.5rem;
    transition: all 0.2s;
}
.history-item:hover { border-color: var(--accent); }
.history-url { font-family: monospace; color: var(--accent); font-size: 0.9rem; word-break: break-all; }
.history-meta { font-size: 0.85rem; color: var(--muted); }
.history-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.btn-action { flex: 1; padding: 0.5rem; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.85rem; transition: opacity 0.2s; }
.btn-copy-small { background: rgba(56, 189, 248, 0.1); color: var(--accent); }
.btn-copy-small:hover { background: rgba(56, 189, 248, 0.2); }
.btn-delete { background: rgba(244, 63, 94, 0.1); color: var(--error); }
.btn-delete:hover { background: rgba(244, 63, 94, 0.2); }

.empty-state { text-align: center; color: var(--muted); padding: 2rem 0; }

.hidden { display: none !important; }

.toast {
    position: fixed; bottom: 20px; right: 20px;
    background: var(--card); border: 1px solid var(--accent);
    padding: 1rem 1.5rem; border-radius: 10px; display: flex; align-items: center; gap: 0.75rem;
    transform: translateX(150%); transition: transform 0.4s ease; z-index: 999;
    color: var(--accent); font-weight: 500;
}
.toast.show { transform: translateX(0); }
/* AUTH SYSTEM */
.auth-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #0f172a;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    /* AWALNYA DISEMBUNYIKAN DI SINI */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

/* Class hidden untuk menghilangkan setelah sukses login */
.auth-overlay.hidden { 
    opacity: 0 !important; 
    visibility: hidden !important; 
    pointer-events: none !important;
}

.auth-card {
    background: #1e293b;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
    border: 1px solid #334155;
    transition: all 0.3s ease;
}
.auth-card h2 { color: #fff; margin: 15px 0 0.5rem 0; font-size: 1.5rem; }
.auth-card p { color: #94a3b8; font-size: 0.9rem; margin-bottom: 1.5rem; }
.auth-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #fff;
    box-sizing: border-box;
    font-family: inherit;
}
.auth-card input:focus { outline: none; border-color: #3b82f6; }
.auth-error { 
    color: #f87171 !important; 
    display: none; 
    margin-top: 15px !important; 
    margin-bottom: 0 !important;
    font-size: 0.85rem !important; 
}
.auth-logo { margin-bottom: 1rem; }

/* ANIMASI SPINNER BESAR SAAT SUKSES */
.auth-success-anim {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}
.auth-spinner-large {
    width: 45px;
    height: 45px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Pastikan keyframe spin ada (kalau belum ada di CSS lama) */
@keyframes spin { 
    to { transform: rotate(360deg); } 
}

/* VIEWS COUNTER BADGE */
.history-stats {
    margin: 6px 0 2px 0;
    font-size: 0.8rem;
}
.views-badge {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.views-badge::before {
    content: '👁';
    font-size: 0.8rem;
}

/* HISTORY HEADER & REFRESH BUTTON */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.history-header h2 { margin: 0; } /* Reset margin h2 biar rapi */

.btn-refresh {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #334155;
    color: #94a3b8;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: #3b82f6;
}

/* Animasi Spin saat loading refresh */
.btn-refresh.loading svg {
    animation: spin 0.8s linear infinite;
}