@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    /* ألوان أكثر عصرية */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-body: #f9fafb;
    --surface: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --radius: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

/* 1. Navbar (Dashboard) */
.navbar {
    background: var(--surface);
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}
.brand {
    font-weight: 800;
    font-size: 1.4rem;
    color: var(--text-main);
    letter-spacing: -0.5px;
    white-space: nowrap; /* منع انكسار الشعار */
}
.badge {
    background: #e0e7ff;
    color: var(--primary);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 6px;
    vertical-align: middle;
    font-weight: 700;
}

/* User Actions Grouping */
.user-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f3f4f6;
    padding: 5px;
    border-radius: 50px;
    border: 1px solid var(--border);
}

.nav-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid #fff;
    display: block;
}

.btn-logout {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    color: var(--text-muted);
    text-decoration: none;
    transition: 0.2s;
    border: 1px solid transparent;
}
.btn-logout:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #fecaca;
}

/* Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 40px;
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
    align-items: start;
}

/* Cards Design */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.card-header h3 {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--text-main);
}

/* Modern Inputs */
.input-wrapper { margin-bottom: 15px; }
.input-wrapper label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.input-group { position: relative; }
.input-group i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 0.9rem;
}
.input-group input {
    width: 100%;
    padding: 14px 45px 14px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    transition: 0.2s;
    background: #f9fafb;
    font-size: 0.95rem;
    color: var(--text-main);
}
.input-group input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.btn {
    padding: 14px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3);
}
.btn-block { width: 100%; }

/* Links List Area */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.count-badge {
    background: #e0e7ff;
    color: var(--primary);
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 50px;
    margin-right: 5px;
}
.btn-preview {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 50px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-preview:hover { background: #f9fafb; border-color: #d1d5db; }

/* --- Link Items (تم إصلاح مشكلة التمدد هنا) --- */
.link-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.2s;
    position: relative;
    overflow: hidden;
    width: 100%;       /* إضافة: عرض كامل */
    max-width: 100%;   /* إضافة: لا يتجاوز الحدود */
    box-sizing: border-box;
}

.link-item::before {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--border);
    transition: 0.2s;
}
.link-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #d1d5db;
}
.link-item:hover::before { background: var(--primary); }

.drag-handle {
    color: #d1d5db;
    cursor: grab;
    padding: 10px;
    flex-shrink: 0; /* منع الانكماش */
}
.drag-handle:hover { color: var(--text-muted); }

/* --- الحاوية المرنة للنصوص --- */
.link-content {
    flex: 1;
    min-width: 0; /* الحل السحري: يسمح بالتقلص */
    width: 0;     /* الحل السحري: دعم إضافي للمتصفحات */
    overflow: hidden;
}

/* السطر الأول (العنوان) */
.link-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    width: 100%;
    min-width: 0;
}

.link-content strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--text-main);

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* الرابط (URL) */
.link-content a {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* وضع ... */
    max-width: 100%;

    color: #888;
    font-size: 0.85rem;
    text-decoration: none;
    margin-top: 2px;
    direction: ltr;
    text-align: right;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 36px; height: 36px;
    border-radius: 8px;
    color: var(--text-muted);
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* منع الانكماش */
}
.btn-icon.delete:hover { background: var(--danger-bg); color: var(--danger); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
    background: var(--surface);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
}
.empty-state i { font-size: 2rem; margin-bottom: 15px; color: #d1d5db; }

/* Mobile Responsive For Dashboard */
@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; gap: 20px; margin-top: 20px; }
    .add-card { position: static; order: 1; }
    .links-section { order: 2; }
    .navbar .container { padding: 0 15px; }
}


/* --- Landing Page Styles (تم إصلاح الهيدر هنا) --- */

.landing-nav {
    background: #fff;
    padding: 15px 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 10;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    flex-wrap: nowrap; /* مهم جداً: يمنع تكسر السطر */
}

/* حاوية الأزرار في الهيدر */
.nav-buttons {
    display: flex;
    align-items: center;
    gap: 10px; /* مسافة ثابتة */
    flex-shrink: 0; /* منع الانكماش */
}

/* تنسيق أزرار الهيدر */
.landing-nav .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
    white-space: nowrap; /* يمنع النص من الانكسار */
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
}

.btn-outline {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: var(--text-main);
    /* margin-left أزيلت واستبدلت بـ gap في الحاوية */
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 120px 20px 60px;
    position: relative;
    overflow: hidden;
}
.hero-content {
    max-width: 700px;
    z-index: 2;
}
.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 20px;
    background: -webkit-linear-gradient(45deg, #111827, #4f46e5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-content p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    line-height: 1.6;
}
.btn-large {
    padding: 16px 40px;
    font-size: 1.1rem;
    border-radius: 50px;
}
.users-count {
    display: block;
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Features Grid */
.features-section {
    padding: 80px 20px;
    background: #fff;
}
.section-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 50px;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    max-width: 1100px;
    margin: 0 auto;
}
.feature-card {
    background: #f9fafb;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    transition: 0.3s;
}
.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.icon-box {
    width: 60px;
    height: 60px;
    background: #e0e7ff;
    color: var(--primary);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 20px;
}
.feature-card h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

/* Footer */
.landing-footer {
    text-align: center;
    padding: 40px;
    background: #f9fafb;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

/* --- Mobile Fixes for Landing Page --- */
@media (max-width: 768px) {
    .nav-container { padding: 0 15px; }

    .brand { font-size: 1.2rem; }

    .nav-buttons { gap: 6px; }

    /* تصغير الأزرار في الجوال */
    .landing-nav .btn {
        padding: 0 12px;
        font-size: 0.8rem;
        height: 34px;
    }

    .hero-content h1 { font-size: 2.5rem; }
    .hero-section { min-height: auto; padding-bottom: 60px; }

    /* إخفاء كلمة لوحة التحكم والإبقاء على الأيقونة في الجوال */
    .hide-mobile { display: none; }
}