/* ============================================
   LinkACT - Main Stylesheet
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: rgba(99, 102, 241, 0.08);
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --header-height: 64px;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    --primary-bg: rgba(99, 102, 241, 0.15);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* --- Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo i {
    font-size: 1.5rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.sidebar-nav .nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-top: 16px;
}

.sidebar-nav .nav-label:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    transition: background var(--transition);
    cursor: pointer;
}

.sidebar-user:hover {
    background: var(--bg-secondary);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.875rem;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-username {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-lang {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.lang-link {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.lang-link:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.lang-link.active {
    color: var(--primary);
    background: var(--primary-bg);
}

.lang-sep {
    color: var(--border-color);
    font-size: 0.75rem;
}

/* Inline language switcher (auth & settings) */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-lang {
    position: absolute;
    top: 16px;
    inset-inline-end: 20px;
}

/* --- RTL Support --- */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

@media (max-width: 768px) {
    [dir="rtl"] .main-content {
        margin-right: 0;
    }
}

[dir="rtl"] .sidebar-toggle {
    margin-right: 0;
    margin-left: 12px;
}

[dir="rtl"] .page-header {
    flex-direction: row;
}

[dir="rtl"] .stat-icon {
    margin-left: 16px;
    margin-right: 0;
}

[dir="rtl"] .card-header {
    text-align: right;
}

[dir="rtl"] .d-flex.align-center.gap-3 {
    gap: 8px;
}

[dir="rtl"] .nav-item i {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] .accordion-header h3 i {
    margin-right: 0;
    margin-left: 10px;
}

[dir="rtl"] table th,
[dir="rtl"] table td {
    text-align: right;
}

[dir="rtl"] .auth-card {
    text-align: right;
}

[dir="rtl"] .auth-footer a i {
    margin-right: 0;
    margin-left: 6px;
    transform: scaleX(-1);
}

[dir="rtl"] .btn i {
    margin-right: 0;
    margin-left: 6px;
}

[dir="rtl"] input,
[dir="rtl"] textarea {
    text-align: right;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
}

.page-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.page-body {
    padding: 32px;
    max-width: 1200px;
    overflow-x: hidden;
}

/* --- Cards --- */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon.purple { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.stat-icon.pink { background: rgba(236, 72, 153, 0.1); color: var(--secondary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.stat-info h4 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin: 0;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.error {
    border-color: var(--danger);
}

.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 4px;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 4px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* --- Avatar Upload --- */
.avatar-upload {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.avatar-upload img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--bg-primary);
    box-shadow: var(--shadow);
}

.avatar-upload .upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    cursor: pointer;
}

.avatar-upload:hover .upload-overlay {
    opacity: 1;
}

.avatar-upload .upload-overlay i {
    color: #fff;
    font-size: 1.5rem;
}

/* --- Cover Upload --- */
.cover-upload {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.cover-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-upload .upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    cursor: pointer;
}

.cover-upload:hover .upload-overlay {
    opacity: 1;
}

/* --- Links List --- */
.links-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.link-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition);
    cursor: grab;
}

.link-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.link-item.dragging {
    opacity: 0.5;
}

.link-item.drag-over {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.link-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
}

.link-info {
    flex: 1;
    min-width: 0;
}

.link-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.link-url {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.link-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.link-status.active { background: var(--success); }
.link-status.inactive { background: var(--text-muted); }
.link-status.error { background: var(--danger); }

/* --- Toggle Switch --- */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 12px;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* --- Phone Preview --- */
.phone-preview {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.phone-frame {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.phone-frame > #phonePreview {
    border-radius: inherit;
}

.phone-content {
    padding: 24px 20px;
    min-height: 600px;
    max-height: 700px;
    overflow-y: auto;
}

.phone-header {
    text-align: center;
    margin-bottom: 24px;
}

.phone-cover {
    width: calc(100% + 48px);
    height: 120px;
    object-fit: cover;
    margin: -24px -24px 16px -24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.phone-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--bg-primary);
    margin: -48px auto 12px;
    display: block;
    background: var(--bg-tertiary);
}

.phone-name {
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 2px;
}

.phone-username {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.phone-bio {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    white-space: pre-line;
}

.phone-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.phone-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--transition);
    text-decoration: none;
}

.phone-link:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* --- Auth Pages --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card .logo h1 {
    font-size: 1.75rem;
    color: var(--primary);
    font-weight: 800;
}

.auth-card .logo p {
    color: var(--text-muted);
    margin-top: 4px;
}

.auth-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.auth-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin: 20px 0;
    position: relative;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: var(--border-color);
}

.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* --- Loading --- */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-dots {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotBounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 1rem;
}

.empty-state h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
}

table tr:hover td {
    background: var(--bg-secondary);
}

/* --- Responsive --- */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.charts-grid > .card {
    min-width: 0;
}

.charts-grid-wide {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.charts-grid-wide > .card {
    min-width: 0;
}

.manage-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
}

.card-body {
    overflow: hidden;
}

.chart-wrap {
    position: relative;
    width: 100%;
}

.card-body canvas {
    max-width: 100% !important;
    display: block;
}

@media (max-width: 900px) {
    .charts-grid,
    .charts-grid-wide,
    .manage-grid {
        grid-template-columns: 1fr;
    }
}

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-backdrop.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .page-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-body {
        padding: 16px;
    }

    .auth-card {
        padding: 24px;
    }

    .stat-card {
        padding: 16px;
    }

    .page-body canvas {
        max-height: 200px;
    }

    .stat-info h4 {
        font-size: 1.25rem;
    }
}

/* RTL: mobile sidebar slides from right */
@media (max-width: 768px) {
    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }
    [dir="rtl"] .sidebar.open {
        transform: translateX(0);
    }
}

@media (max-width: 576px) {
    .auth-page {
        padding: 12px;
    }

    .auth-card {
        padding: 20px;
    }

    .page-body {
        padding: 12px;
    }

    .card-body {
        padding: 16px;
    }

    .page-header h2 {
        font-size: 1rem;
    }

    .table-container {
        overflow-x: auto;
    }

    .d-flex.gap-3 {
        gap: 6px;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .accordion-body-inner {
        padding: 0 12px 12px !important;
    }

    .accordion-header {
        padding: 12px 14px !important;
    }



    .page-body > div[style*="grid-template-columns: repeat(5,"] {
        grid-template-columns: repeat(3,1fr) !important;
    }

    .page-body > div[style*="grid-template-columns: repeat(4,"] {
        grid-template-columns: repeat(2,1fr) !important;
    }

    .cover-upload, .avatar-upload {
        width: 100% !important;
    }

    .links-list .link-item {
        flex-wrap: wrap;
        gap: 6px;
    }

    .link-actions {
        width: 100%;
        justify-content: flex-end;
    }

    #previewCard {
        padding: 0 16px 20px !important;
    }
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mt-6 { margin-top: 24px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }

.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }

.w-100 { width: 100%; }

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Icon Picker --- */
.icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    transition: all 0.15s ease;
    font-size: 1.1rem;
    min-height: 60px;
}
.icon-option:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.15);
}
.icon-option i {
    font-size: 1.3rem;
    color: var(--text-primary);
}
.icon-option:hover i {
    color: var(--primary);
}
