: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;
}

/* ==================== MODE TOGGLE ==================== */
.mode-toggle {
    display: flex;
    background: var(--bg);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}
.mode-btn {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--muted);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}
.mode-btn.active {
    background: var(--accent);
    color: var(--bg);
}
.mode-btn:not(.active):hover {
    color: var(--fg);
    background: rgba(255,255,255,0.05);
}

/* ==================== INPUT FIELDS ==================== */
.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; }

/* URL Count Badge */
.url-count {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    transition: color 0.2s;
}

/* 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 */
.play-icon-option {
    margin-top: 1.5rem; margin-bottom: 1.5rem;
    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); }

/* ==================== PROGRESS BAR ==================== */
.progress-container {
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 2px;
}

/* ==================== BUTTONS ==================== */
.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 SECTION ==================== */
.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); }

/* ==================== BULK RESULT LIST ==================== */
.bulk-links-list {
    display: flex; flex-direction: column; gap: 0.5rem;
    max-height: 280px; overflow-y: auto;
    padding-right: 4px;
}
.bulk-links-list::-webkit-scrollbar { width: 4px; }
.bulk-links-list::-webkit-scrollbar-track { background: transparent; }
.bulk-links-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.bulk-link-item {
    display: flex; align-items: center; gap: 0.5rem;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}
.bulk-link-item:nth-child(1) { animation-delay: 0.05s; }
.bulk-link-item:nth-child(2) { animation-delay: 0.1s; }
.bulk-link-item:nth-child(3) { animation-delay: 0.15s; }
.bulk-link-item:nth-child(4) { animation-delay: 0.2s; }
.bulk-link-item:nth-child(5) { animation-delay: 0.25s; }
.bulk-link-item:nth-child(6) { animation-delay: 0.3s; }
.bulk-link-item:nth-child(7) { animation-delay: 0.35s; }
.bulk-link-item:nth-child(8) { animation-delay: 0.4s; }
.bulk-link-item:nth-child(9) { animation-delay: 0.45s; }
.bulk-link-item:nth-child(10) { animation-delay: 0.5s; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bulk-link-num {
    width: 26px; height: 26px;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent); border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.bulk-link-item input {
    flex: 1; background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 0.5rem 0.75rem; color: var(--fg);
    font-family: 'Space Grotesk', monospace; font-size: 0.82rem;
}

/* Failed Items */
.bulk-failed {
    margin-top: 1rem; padding-top: 1rem;
    border-top: 1px solid rgba(244, 63, 94, 0.2);
}
.failed-label {
    color: var(--error) !important;
    font-size: 0.85rem !important;
    margin-bottom: 0.5rem !important;
}
.bulk-failed-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 0.5rem; background: rgba(244, 63, 94, 0.05);
    border-radius: 6px; margin-bottom: 0.4rem;
    font-size: 0.82rem;
}
.failed-url {
    color: var(--muted);
    word-break: break-all;
    font-family: monospace;
}
.failed-reason {
    color: var(--error);
    font-weight: 600;
}

/* ==================== 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;
    opacity: 0; visibility: hidden;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
.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; }

.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;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== VIEWS 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 ==================== */
.history-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;
}
.history-header h2 { margin: 0; }

.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; }
.btn-refresh.loading svg { animation: spin 0.8s linear infinite; }