/* --- CSS Variables --- */
:root {
    --bg: #faf9f7;
    --bg-elevated: #ffffff;
    --card: #ffffff;
    --border: #e5e3df;
    --border-hover: #d4d1cb;
    --fg: #1a1817;
    --muted: #6b6560;
    --accent: #6366f1;
    --accent-light: #e0e7ff;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --secondary: #14b8a6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --input-bg: #ffffff;
    --pattern-opacity: 0.3;
    --code-bg: #1e1e2e;
    --code-text: #34d399;
}

[data-theme="dark"] {
    --bg: #0a0a0f;
    --bg-elevated: #12121a;
    --card: #16161f;
    --border: #2a2a3a;
    --border-hover: #3a3a4a;
    --fg: #e8e8ed;
    --muted: #6b6b7a;
    --accent: #818cf8;
    --accent-light: rgba(129, 140, 248, 0.15);
    --accent-glow: rgba(129, 140, 248, 0.2);
    --secondary: #2dd4bf;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --input-bg: #0f0f14;
    --pattern-opacity: 0.05;
    --code-bg: #0f0f14;
    --code-text: #34d399;
}

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

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
    line-height: 1.5;
}

/* --- Background --- */
.bg-decoration { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-pattern { position: absolute; inset: 0; background-image: radial-gradient(circle, var(--muted) 1px, transparent 1px); background-size: 24px 24px; opacity: var(--pattern-opacity); }
.gradient-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4; animation: float 20s ease-in-out infinite; }
.orb-1 { width: 500px; height: 500px; background: linear-gradient(135deg, #a5b4fc, #818cf8); top: -150px; right: -100px; }
.orb-2 { width: 400px; height: 400px; background: linear-gradient(135deg, #5eead4, #2dd4bf); bottom: -100px; left: -100px; animation-delay: -5s; }
[data-theme="dark"] .orb-1 { background: var(--accent); opacity: 0.15; }
[data-theme="dark"] .orb-2 { background: var(--secondary); opacity: 0.15; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, 20px) scale(1.05); } }

/* --- Layout --- */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }
.main-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 900px) { .main-grid { grid-template-columns: 1fr 1fr; } }

/* --- Header --- */
header { text-align: center; margin-bottom: 2rem; }
.header-top { display: flex; justify-content: center; margin-bottom: 1rem; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border); background: var(--card); font-size: 14px; color: var(--muted); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
h1 { font-size: 2.5rem; font-weight: 700; letter-spacing: -1px; margin-bottom: 0.5rem; }
h1 span { color: var(--accent); }
.subtitle { color: var(--muted); font-size: 1.1rem; }

/* --- Theme Toggle --- */
.theme-toggle { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 100; width: 48px; height: 48px; border-radius: 50%; background: var(--card); border: 2px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.theme-toggle:hover { transform: rotate(15deg) scale(1.1); border-color: var(--accent); background: var(--accent-light); }
.theme-toggle svg { width: 24px; height: 24px; stroke: var(--fg); fill: none; stroke-width: 2; }

/* --- Panel --- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 1.5rem; box-shadow: 0 4px 24px rgba(0,0,0,0.03); display: flex; flex-direction: column; gap: 1rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.label { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.label svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* --- Input Groups --- */
.input-group { display: flex; flex-direction: column; gap: 0.4rem; }
.input-group label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; color: var(--fg); }
.input-group label svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.input-group label small { color: var(--muted); font-weight: 400; font-size: 0.75rem; }

.input-field { 
    width: 100%; 
    background: var(--input-bg); 
    border: 2px solid var(--border); 
    border-radius: 10px; 
    padding: 12px 14px; 
    font-size: 14px; 
    color: var(--fg); 
    font-family: inherit; 
    transition: all 0.2s; 
}
.input-field:focus { outline: none; border-color: var(--accent); }
.input-field::placeholder { color: var(--muted); opacity: 0.6; }

.select-field {
    width: 100%; 
    background: var(--input-bg); 
    border: 2px solid var(--border); 
    border-radius: 10px; 
    padding: 12px 14px; 
    font-size: 14px; 
    color: var(--fg); 
    font-family: inherit; 
    transition: all 0.2s; 
    cursor: pointer;
}
.select-field:focus { outline: none; border-color: var(--accent); }

.text-area-small { 
    width: 100%; 
    background: var(--input-bg); 
    border: 2px solid var(--border); 
    border-radius: 10px; 
    padding: 12px 14px; 
    font-size: 14px; 
    color: var(--fg); 
    resize: none; 
    font-family: inherit; 
    transition: all 0.2s; 
}
.text-area-small:focus { outline: none; border-color: var(--accent); }
.text-area-small::placeholder { color: var(--muted); opacity: 0.6; }

.char-counter {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 600px) {
    .input-row { grid-template-columns: 1fr; }
}

/* --- Options Section --- */
.options-section { background: var(--bg); border-radius: 12px; padding: 1rem; }
.option-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem; }

/* --- Preview Tabs --- */
.preview-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 4px;
    border-radius: 10px;
}
.tab-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active { background: var(--accent); color: white; }

/* --- Preview Container --- */
.preview-container { margin-bottom: 1rem; }

/* Facebook Preview */
.preview-card.facebook {
    background: white;
    border: 1px solid #dadde1;
    border-radius: 8px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.preview-image {
    width: 100%;
    height: 160px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}
.preview-image svg {
    width: 48px;
    height: 48px;
    stroke: #ccc;
    fill: none;
}
.preview-content {
    padding: 12px;
    background: #f2f3f5;
}
.preview-url {
    font-size: 12px;
    color: #65676b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.preview-title {
    font-size: 16px;
    font-weight: 600;
    color: #1c1e21;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.preview-desc {
    font-size: 14px;
    color: #65676b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Twitter Preview */
.preview-card.twitter {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 16px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.twitter-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
}
.twitter-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
}
.twitter-user-info { flex: 1; }
.twitter-name { font-size: 14px; font-weight: 700; color: #14171a; }
.twitter-handle { font-size: 13px; color: #657786; }
.twitter-card-large {
    border: 1px solid #e1e8ed;
    border-radius: 12px;
    margin: 0 12px 12px;
    overflow: hidden;
}
.twitter-image {
    width: 100%;
    height: 140px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}
.twitter-image svg { width: 40px; height: 40px; stroke: #ccc; fill: none; }
.twitter-content { padding: 12px; }
.twitter-title {
    font-size: 15px;
    font-weight: 700;
    color: #14171a;
    margin-bottom: 4px;
}
.twitter-desc {
    font-size: 14px;
    color: #657786;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.twitter-link { font-size: 13px; color: #657786; }

/* LinkedIn Preview */
.preview-card.linkedin {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.linkedin-image {
    width: 100%;
    height: 140px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}
.linkedin-image svg { width: 40px; height: 40px; stroke: #ccc; fill: none; }
.linkedin-content { padding: 12px; }
.linkedin-title {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    margin-bottom: 4px;
}
.linkedin-domain { font-size: 13px; color: #666; }

/* --- Code Output --- */
.results-header { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-top: 0.5rem; margin-bottom: 0.5rem; }
.code-output {
    background: var(--code-bg);
    border-radius: 12px;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--code-text);
}
.code-output code {
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- Stats Row --- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 1rem; }
.stat-box { background: var(--bg); border-radius: 12px; padding: 12px; text-align: center; }
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 1.1rem; font-weight: 700; font-family: 'JetBrains Mono', monospace; margin-top: 4px; color: var(--fg); }
.stat-value.warning { color: var(--warning); }
.stat-value.success { color: var(--success); }
.stat-value.danger { color: var(--danger); }
.stat-value.secondary { color: var(--secondary); }

/* --- Buttons --- */
.actions-row { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }

.btn-action { 
    flex: 1; 
    min-width: 200px; 
    padding: 14px; 
    background: var(--accent); 
    color: white; 
    border: none; 
    border-radius: 12px; 
    font-weight: 600; 
    font-size: 1rem; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    transition: all 0.2s; 
    font-family: inherit;
}
.btn-action svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-action:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--accent-glow); filter: brightness(1.05); }

.btn-secondary { 
    padding: 14px 24px; 
    background: var(--bg); 
    color: var(--fg); 
    border: 2px solid var(--border); 
    border-radius: 12px; 
    font-weight: 600; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    transition: all 0.2s; 
    font-family: inherit;
}
.btn-secondary svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-report { 
    padding: 14px 24px; 
    background: var(--secondary); 
    color: white; 
    border: none; 
    border-radius: 12px; 
    font-weight: 600; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    transition: all 0.2s; 
    font-family: inherit;
}
.btn-report svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-report:hover { filter: brightness(1.1); }

/* --- Toast --- */
.toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--card); border: 1px solid var(--accent); padding: 1rem 1.5rem; border-radius: 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); transform: translateY(100px); opacity: 0; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 1001; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast svg { width: 20px; height: 20px; stroke: var(--accent); fill: none; flex-shrink: 0; }

/* Utility */
.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.6s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    .actions-row { flex-direction: column; }
    .btn-action, .btn-secondary, .btn-report { width: 100%; min-width: auto; }
    .toast { left: 1rem; right: 1rem; bottom: 1rem; }
    .preview-tabs { flex-wrap: wrap; }
}
