/** 
 * Base App Reset and Variables 
 */
:root {
    --bg-base: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-full: 9999px;
    --font-primary: 'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-primary); background-color: var(--bg-base); color: var(--text-main); overflow: hidden; height: 100vh; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.justify-center { justify-content: center; }

/* Layout */
.app-container { display: flex; height: 100vh; }

/* Editor Sidebar */
.editor-sidebar {
    width: 360px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.editor-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.editor-header h1 { font-size: 1.25rem; font-weight: 700; }
.logo-icon { color: var(--primary); }

.editor-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    overflow-x: auto;
}
.tab-btn {
    padding: 1rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content-area {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.tab-pane { display: none; flex-direction: column; gap: 1.5rem; }
.tab-pane.active { display: flex; }

/* Form Elements */
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
input[type="text"], input[type="url"], input[type="email"], textarea {
    width: 100%; padding: 0.75rem;
    background-color: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main); font-family: var(--font-primary);
    transition: border-color 0.2s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }

.section-title { font-size: 1rem; font-weight: 600; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem;}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1rem; border: none; border-radius: var(--radius-sm);
    font-family: var(--font-primary); font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-danger { background-color: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background-color: var(--danger); color: white; }

/* Social Inputs */
.social-inputs-grid { display: flex; flex-direction: column; gap: 0.75rem; }
.social-input { display: flex; align-items: center; gap: 0.75rem; }
.social-input i { width: 20px; color: var(--text-muted); }

/* Link Editor Items */
.links-list { display: flex; flex-direction: column; gap: 1rem; }
.link-editor-item {
    background-color: var(--bg-surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex; gap: 1rem; align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
.link-editor-item.sortable-ghost { opacity: 0.4; }
.drag-handle { cursor: grab; color: var(--text-muted); display: flex; align-items: center; }
.drag-handle:active { cursor: grabbing; }
.link-editor-content { flex-grow: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.link-editor-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.link-editor-actions button {
    background: transparent; border: none; color: var(--text-muted); cursor: pointer;
    padding: 0.25rem; border-radius: var(--radius-sm); transition: all 0.2s;
}
.link-editor-actions button:hover { background-color: rgba(255,255,255,0.1); color: var(--text-main); }
.link-editor-actions .delete-link-btn:hover { color: var(--danger); }
.link-editor-item.inactive { opacity: 0.5; }

/* Themes Grid */
.themes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.theme-card {
    padding: 1rem; border: 2px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-surface-hover); color: var(--text-main); font-weight: 500;
    cursor: pointer; text-align: center; transition: all 0.2s;
}
.theme-card:hover { border-color: var(--text-muted); }
.theme-card.active { border-color: var(--primary); background-color: rgba(59, 130, 246, 0.1); }

/* Analytics */
.analytics-item { display: flex; justify-content: space-between; padding: 0.75rem; border-bottom: 1px solid var(--border-color); font-size: 0.875rem;}
.analytics-item:last-child { border-bottom: none; }
.clicks-badge { background-color: var(--primary); color: white; padding: 0.1rem 0.5rem; border-radius: 99px; font-weight: 600;}

/* Preview Area */
.preview-area {
    flex-grow: 1;
    background-color: #000;
    background-image: radial-gradient(circle at center, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.preview-controls {
    margin-top: 1.5rem;
    display: flex; gap: 0.5rem;
    background-color: var(--bg-surface);
    padding: 0.5rem; border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}
.device-toggle {
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.device-toggle:hover { color: var(--text-main); }
.device-toggle.active { background-color: var(--bg-surface-hover); color: var(--primary); }

.device-frame {
    margin-top: 2rem; margin-bottom: 2rem;
    width: 375px; height: 812px; /* Mobile Default */
    border-radius: 40px; border: 12px solid #222;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden; background-color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.device-frame.desktop {
    width: 100%; height: 100%; max-width: none;
    border-radius: 0; border: none; margin: 0;
}

/* ========================================================= */
/* BIO PAGE CORE STRUCTURE (For export parsing)              */
/* ========================================================= */
.bio-page {
    width: 100%; height: 100%; overflow-y: auto; position: relative;
    font-family: 'Inter', sans-serif;
    color: var(--t-text, #111);
    background: var(--t-bg, #f3f4f6);
}

.bio-background {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1;
    background-image: var(--bg-image, none);
    background-size: cover; background-position: center; background-repeat: no-repeat;
    opacity: 1; transition: all 0.3s;
}
.bio-background::after {
    content: ''; position: absolute; inset: 0;
    backdrop-filter: var(--bg-blur, none);
    background-color: var(--bg-overlay, transparent);
}

.bio-content {
    position: relative; z-index: 2; padding: 3rem 1.5rem;
    max-width: 680px; margin: 0 auto;
    display: flex; flex-direction: column; align-items: center;
    min-height: 100%;
}

.bio-header { text-align: center; margin-bottom: 2rem; width: 100%;}
.bio-avatar {
    width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
    margin: 0 auto 1rem auto; display: block;
    border: var(--t-avatar-border, 2px solid transparent);
}
.bio-name { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.5rem; }
.bio-description { font-size: 0.95rem; line-height: 1.5; opacity: 0.9; margin-bottom: 1.5rem; white-space: pre-wrap;}

.bio-socials { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }
.bio-social-link {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 50%;
    color: var(--t-text, #111); transition: all 0.2s;
    background: var(--t-card-bg, transparent);
    border: var(--t-card-border, 1px solid rgba(0,0,0,0.1));
}
.bio-social-link:hover { transform: translateY(-2px); opacity: 0.8; }

.bio-links { display: flex; flex-direction: column; gap: 1rem; width: 100%; }
.bio-link-btn {
    display: flex; align-items: center; justify-content: center; padding: 1rem 1.5rem;
    width: 100%; text-decoration: none; font-weight: 600; font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: var(--t-card-bg, #fff);
    color: var(--t-text, #111);
    border: var(--t-card-border, none);
    border-radius: var(--t-radius, 8px);
    box-shadow: var(--t-shadow, 0 1px 3px rgba(0,0,0,0.1));
    position: relative; overflow: hidden;
}
.bio-link-btn:hover { transform: scale(1.02); box-shadow: var(--t-shadow-hover, 0 4px 6px rgba(0,0,0,0.1)); }

.bio-footer { margin-top: auto; padding-top: 3rem; text-align: center; }
.watermark { font-size: 0.75rem; text-decoration: none; opacity: 0.5; color: var(--t-text, #111); font-weight: 600;}

/* ========================================================= */
/* THEMES CONFIGURATION                                      */
/* ========================================================= */
.theme-light { --t-bg: #f9fafb; --t-text: #111827; --t-card-bg: #ffffff; --t-card-border: 1px solid #e5e7eb; --t-radius: 12px; --t-shadow: 0 1px 2px rgba(0,0,0,0.05); --t-shadow-hover: 0 4px 6px rgba(0,0,0,0.05); }
.theme-dark { --t-bg: #111827; --t-text: #f9fafb; --t-card-bg: #1f2937; --t-card-border: 1px solid #374151; --t-radius: 12px; --t-shadow: 0 4px 6px rgba(0,0,0,0.3); --t-shadow-hover: 0 10px 15px rgba(0,0,0,0.3); }
.theme-glass { --t-bg: linear-gradient(135deg, #c4b5fd, #fca5a5); --t-text: #1f2937; --t-card-bg: rgba(255, 255, 255, 0.4); --t-card-border: 1px solid rgba(255, 255, 255, 0.5); --t-radius: 24px; --t-shadow: 0 8px 32px rgba(31, 38, 135, 0.1); --t-shadow-hover: 0 8px 32px rgba(31, 38, 135, 0.2); backdrop-filter: blur(10px); }
.theme-glass .bio-link-btn { backdrop-filter: blur(10px); }
.theme-glass .bio-social-link { backdrop-filter: blur(10px); }
.theme-mesh { --t-bg: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%); background-color: #0f0c29; --t-text: #fff; --t-card-bg: rgba(255,255,255,0.05); --t-card-border: 1px solid rgba(255,255,255,0.1); --t-radius: 100px; --t-shadow: none; --t-shadow-hover: 0 0 20px rgba(255,255,255,0.2); }
.theme-mesh .bio-link-btn { backdrop-filter: blur(20px); }
.theme-sunset { --t-bg: linear-gradient(180deg, #FF7E5F, #FEB47B); --t-text: #fff; --t-card-bg: rgba(0,0,0,0.2); --t-card-border: 2px solid transparent; --t-radius: 0px; --t-shadow: 4px 4px 0px rgba(0,0,0,0.3); --t-shadow-hover: 6px 6px 0px rgba(0,0,0,0.4); }
.theme-sunset .bio-link-btn:hover { transform: translate(-2px, -2px); }
.theme-midnight { --t-bg: #000000; --t-text: #eaeaea; --t-card-bg: #000000; --t-card-border: 1px solid #333; --t-radius: 8px; --t-shadow: none; --t-shadow-hover: inset 0 0 0 1px #fff; }
.theme-cyber { --t-bg: #0f021f; --t-text: #0ff; --t-card-bg: transparent; --t-card-border: 1px solid #f0f; --t-radius: 0px; --t-shadow: 0 0 10px rgba(255,0,255,0.2); --t-shadow-hover: inset 0 0 20px rgba(255,0,255,0.5); font-family: 'Courier New', monospace; --t-avatar-border: 2px solid #0ff;}
.theme-forest { --t-bg: #132a13; --t-text: #ecf39e; --t-card-bg: #31572c; --t-card-border: 1px solid #4f772d; --t-radius: 16px; --t-shadow: inset 0 2px 4px rgba(255,255,255,0.1); --t-shadow-hover: inset 0 4px 8px rgba(255,255,255,0.2); }
.theme-ocean { --t-bg: linear-gradient(to right, #00c6ff, #0072ff); --t-text: #fff; --t-card-bg: #ffffff; --t-text-override: #0072ff; --t-card-border: none; --t-radius: 40px; --t-shadow: 0 10px 20px rgba(0,0,0,0.2); --t-shadow-hover: 0 15px 30px rgba(0,0,0,0.3); }
.theme-ocean .bio-link-btn { color: var(--t-text-override); }
.theme-ocean .bio-social-link { color: var(--t-text-override); }
.theme-pastel { --t-bg: #fdfd96; --t-text: #555; --t-card-bg: #ffb7b2; --t-card-border: 4px solid #fff; --t-radius: 20px; --t-shadow: 0 4px 0px rgba(0,0,0,0.1); --t-shadow-hover: 0 6px 0px rgba(0,0,0,0.15); }
.theme-pastel .bio-link-btn { font-weight: 800; }

/* Responsive */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .editor-sidebar { width: 100%; height: 50vh; border-right: none; border-bottom: 1px solid var(--border-color); }
    .preview-area { height: 50vh; }
    .device-frame { margin-top: 1rem; margin-bottom: 0; width: 100%; height: 100%; border-radius: 0; border: none; }
    .preview-controls { display: none; }
}
