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

:root {
    /* Premium Light Theme Tokens */
    --bg-primary: #ffffff;
    --bg-body: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-sidebar: rgba(255, 255, 255, 0.85);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary-gradient: linear-gradient(135deg, #4f46e5, #9333ea);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --border-color: rgba(226, 232, 240, 0.6);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --blur: blur(12px);
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
}

[data-theme="dark"] {
    /* Premium Dark Theme Tokens */
    --bg-primary: #1e293b;
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-sidebar: rgba(15, 23, 42, 0.85);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --border-color: rgba(51, 65, 85, 0.6);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    --input-bg: #1e293b;
    --input-border: #334155;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-body);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { font-weight: 700; margin-bottom: 0.5rem; color: var(--text-main); }
p { margin-bottom: 1rem; color: var(--text-main); font-weight: 400; }
a { color: var(--primary-color); text-decoration: none; transition: color 0.3s; }
a:hover { color: var(--primary-hover); text-decoration: none; }

/* Layout Grid */
.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
}



/* Glassmorphism Components */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

/* Sidebar */
.mobile-header { display: none; }
.sidebar {
    position: sticky;
    top: 2rem;
    height: calc(100vh - 4rem);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    background: var(--bg-sidebar);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
    z-index: 10;
}
.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
    text-align: center;
}
.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}
.nav-links li a {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.3s ease;
}
.nav-links li a:hover, .nav-links li a.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    transform: translateX(-5px);
}
.user-widget {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--primary-gradient);
    color: white;
}
.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; border-radius: var(--radius-sm); }

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Filter Pills */
.category-filters {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}
.category-filters::-webkit-scrollbar { height: 0; }
.cat-pill {
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.3s ease;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    color: var(--text-muted);
}
.cat-pill:hover, .cat-pill.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Post Cards */
.post-card {
    background: var(--bg-card);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem; /* مسافة بين البوستات */
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 0.5s forwards ease-out;
}
.post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--glass-shadow);
}
.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.post-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.badge-solved {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}
.mark-solved-btn {
    background: transparent;
    color: var(--success-color);
    border: 1px solid var(--success-color);
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 30px;
    transition: all 0.3s;
}
.mark-solved-btn:hover {
    background: var(--success-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

/* Likes */
.like-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.like-btn:hover {
    transform: scale(1.1);
    color: var(--danger-color);
}
.like-btn.liked {
    color: var(--danger-color);
}
.like-btn.liked span.icon {
    animation: popLike 0.4s;
}
@keyframes popLike {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Forms and Inputs */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: var(--text-main); }
.form-control {
    width: 100%;
    padding: 1rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background: var(--bg-body);
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 1px solid var(--border-color);
    max-height: 90vh;
    overflow-y: auto;
}
.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}
.close-modal {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s;
}
.close-modal:hover { background: var(--danger-color); color: white; border-color: var(--danger-color); }

/* Comments Section */
.comments-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.comment {
    background: rgba(0,0,0,0.02);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}
[data-theme="dark"] .comment { background: rgba(255,255,255,0.02); }
.comment-accepted {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

/* Animations */
@keyframes slideUp {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.text-danger { color: var(--danger-color); }
.text-center { text-align: center; }
.hidden { display: none !important; }
.mb-3 { margin-bottom: 1rem; }

/* Media & Lightbox */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}
.media-thumbnail {
    width: 100%;
    height: 180px;
    border-radius: var(--radius-md);
    cursor: pointer;
    object-fit: cover;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}
.media-thumbnail:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.lightbox-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s;
}
.lightbox-overlay.active { opacity: 1; visibility: visible; }
.lightbox-content {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.lightbox-overlay.active .lightbox-content { transform: scale(1); }
.lightbox-close {
    position: absolute;
    top: 20px; right: 30px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    background: none; 
    border: none;
    transition: transform 0.3s;
}
.lightbox-close:hover { transform: rotate(90deg) scale(1.1); }

/* Admin Table Styling */
.admin-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 1.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--blur);
}
.users-table-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    backdrop-filter: var(--blur);
    overflow: hidden;
    overflow-x: auto;
}
.users-table {
    width: 100%;
    border-collapse: collapse;
}
.users-table th {
    background: rgba(0,0,0,0.03);
    padding: 1.2rem;
    text-align: right;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 2px solid var(--border-color);
}
[data-theme="dark"] .users-table th { background: rgba(255,255,255,0.03); }
.users-table td {
    padding: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.users-table tr:hover td { background: rgba(99, 102, 241, 0.02); }
.users-table tr:last-child td { border-bottom: none; }

.permissions-box {
    display: none;
    margin-top: 0.8rem;
    padding: 1rem;
    background: var(--input-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--input-border);
    animation: slideUp 0.3s ease-out;
}
.permissions-box.active { display: block; }
.perm-label {
    margin-left: 1rem;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
}
.perm-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.record-btn-pulse {
    animation: pulse 1.5s infinite;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; padding: 1rem; }
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: var(--bg-card);
        backdrop-filter: var(--blur);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 1rem 1.5rem;
        margin-bottom: 1rem;
        box-shadow: var(--card-shadow);
    }
    .sidebar {
        display: none !important;
        position: relative !important;
        height: auto !important;
        top: 0 !important;
        margin-bottom: 1rem;
        z-index: 100;
    }
    .sidebar.active {
        display: flex !important;
        animation: slideUp 0.3s ease-out;
    }
}

/* Videos in Posts */
.post-video {
    max-height: 250px !important;
    max-width: 100%;
    width: auto !important;
    display: block;
    margin: 0.5rem auto;
    object-fit: contain;
    border-radius: var(--radius-md);
    background: #000;
}

/* Embed Container */
.embed-container {
    margin: 1rem auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    max-width: 450px;
    padding-bottom: 253px; /* roughly 16:9 for 450px width */
    background: #000;
}
.embed-container iframe, .embed-container object, .embed-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Horizontal Comment Media */
.comment-media-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.comment-media-row img, 
.comment-media-row video {
    max-height: 120px;
    max-width: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* Accepted Solution Comment Highlight */
.comment-solution-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 0.5rem;
    display: inline-block;
    box-shadow: 0 2px 5px rgba(16, 185, 129, 0.3);
}

/* Post Links */
.post-links-list {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.post-link-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    padding: 0.4rem 1rem;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.post-link-item:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* WhatsApp Button Redesign */
.btn-whatsapp {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-whatsapp:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4);
    color: white;
}
