: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: 20px; font-size: 1.5rem; 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: 700px; margin: 0 auto; padding: 3rem 1.5rem 1rem;
}

header { text-align: center; margin-bottom: 2rem; }
header h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 0.5rem; line-height: 1.2; }
.accent { color: var(--accent); }
header p { color: var(--muted); font-size: 1rem; }

.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.25rem; font-size: 1.15rem;
}

.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 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"], 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: 200px; font-family: 'Space Grotesk', monospace; line-height: 1.5; }

/* 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;
}

/* ==================== PROGRESS BAR ==================== */
.progress-container {
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 3px;
}

/* ==================== 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; }

/* ==================== BULK RESULT LIST ==================== */
.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; }

.bulk-links-list {
    display: flex; flex-direction: column; gap: 0.5rem;
    max-height: 400px; 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 { 
    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; }

/* ==================== HISTORY HEADER & ACTIONS ==================== */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-wrap: wrap;
    gap: 10px;
}
.history-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--fg);
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 15px;
}
.history-header-left {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.btn-history-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-history-action:hover {
    background: rgba(255,255,255,0.1);
    color: var(--fg);
    border-color: rgba(255,255,255,0.2);
}
.btn-history-action.loading svg {
    animation: spin 1s linear infinite;
}
.btn-delete-all:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* ==================== TOAST ==================== */
.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);
    }
}

.loader {
    animation: spin 1s linear infinite;
}