:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --success: #4cc9f0;
    --warning: #f72585;
    --light: #f8f9fa;
    --dark: #212529;
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --header-bg: #ffffff;
    --sidebar-bg: #343a40;
    --sidebar-text: #ffffff;
    --sidebar-hover: #495057;
}

.dark-mode {
    --bg-color: #121212;
    --text-color: #e6e6e6;
    --card-bg: #1e1e1e;
    --border-color: #2d2d2d;
    --header-bg: #1e1e1e;
    --sidebar-bg: #1a1a1a;
    --sidebar-text: #e6e6e6;
    --sidebar-hover: #2d2d2d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.container {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

/* الشريط الجانبي */
.sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 0;
    height: 100vh;
    position: fixed;
    width: 250px;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-header h2 {
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.sidebar-menu li {
    padding: 10px 20px;
    margin: 5px 0;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
}

.sidebar-menu li:hover {
    background-color: var(--sidebar-hover);
}

.sidebar-menu li.active {
    background-color: var(--primary);
    border-right: 4px solid var(--warning);
}

.sidebar-menu i {
    margin-left: 10px;
    width: 20px;
    text-align: center;
}

/* المحتوى الرئيسي */
.main-content {
    padding: 20px;
    grid-column: 2;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--header-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border-radius: 8px;
}

.header h1 {
    font-size: 1.8rem;
    color: var(--primary);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
}

/* بطاقات الإحصائيات */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card i {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.stat-card h3 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.stat-card p {
    color: var(--text-color);
    opacity: 0.8;
}

.users-card { border-top: 4px solid #4361ee; }
.users-card i { color: #4361ee; }

.posts-card { border-top: 4px solid #4cc9f0; }
.posts-card i { color: #4cc9f0; }

.comments-card { border-top: 4px solid #f72585; }
.comments-card i { color: #f72585; }

/* محتوى التبويبات */
.tab-content {
    display: none;
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    border-radius: 20px;
    padding: 5px 15px;
    width: 300px;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-color);
    width: 100%;
    padding: 8px;
}

/* الجداول */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

th, td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-color);
    font-weight: bold;
}

tr:hover {
    background-color: var(--bg-color);
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin: 0 5px;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s;
}

.view-btn { color: #4361ee; }
.edit-btn { color: #4cc9f0; }
.delete-btn { color: #f72585; }
.favorite-btn { color: #ffc107; }

.action-btn:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

/* النماذج */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--secondary);
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* التعليقات */
.comments-section {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--bg-color);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.comment {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.comment:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-weight: bold;
}

.comment-email {
    color: var(--primary);
    font-size: 0.9rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* Responsive design */
@media (max-width: 992px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }
    
    .main-content {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .search-box {
        width: 100%;
        margin-top: 10px;
    }
    
    .tab-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 95%;
        padding: 15px;
    }
}

/* responsive table container - let DataTables handle scrolling/alignment */
.table-container {
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-top: 10px;
}

.table-container table {
    width: 100%;
    table-layout: auto; /* allow natural column sizing */
    border-collapse: collapse;
}

/* when DataTables adds its scroll wrapper, restrict body height here */
.table-container .dataTables_scrollBody {
    max-height: 60vh !important;
}

.table-container table th,
.table-container table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}
