:root {
    --primary: #0D9488;
    --primary-dark: #0F766E;
    --primary-light: #CCFBF1;
    --accent: #F59E0B;
    --bg-body: #F3F4F6;
    --bg-sidebar: #111827;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --font-main: 'Plus Jakarta Sans', sans-serif;
    --font-arabic: 'Amiri', serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    display: flex;
    background-color: var(--bg-body);
    height: 100vh;
    overflow: hidden;
}

/* Sidebar & Layout */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: 0.3s;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #1F2937;
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-menu {
    list-style: none;
    padding: 20px 10px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #9CA3AF;
    text-decoration: none;
    border-radius: var(--radius);
    transition: 0.2s;
    cursor: pointer;
    margin-bottom: 5px;
}

.nav-link:hover,
.nav-link.active {
    background-color: #374151;
    color: var(--primary);
}

.nav-link i {
    font-size: 1.2rem;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #1F2937;
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.content-padding {
    padding: 30px;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-info h3 {
    font-size: 2rem;
    color: var(--text-main);
    margin-bottom: 5px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Activity */
.activity-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #F3F4F6;
}

.act-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.act-add {
    background: #DCFCE7;
    color: #166534;
}

.act-edit {
    background: #FEF3C7;
    color: #D97706;
}

.act-del {
    background: #FEE2E2;
    color: #DC2626;
}

.act-details h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.act-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.act-time {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-left: auto;
    white-space: nowrap;
}

/* Tables & UI Elements */
.table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-header {
    padding: 20px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.table-tools {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-box {
    position: relative;
}

.search-input {
    padding: 10px 10px 10px 35px;
    border: 1px solid #D1D5DB;
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
    width: 250px;
    transition: 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 16px 20px;
    text-align: center;
    border-bottom: 1px solid #F3F4F6;
    font-size: 0.9rem;
    vertical-align: middle;
}

th {
    background: #F9FAFB;
    font-weight: 600;
    color: #4B5563;
}

tr:hover {
    background: #F9FAFB;
}

.arabic-text,
.arabic-text * {
    font-family: 'Amiri', serif !important;
    font-size: 1.4rem;
    color: var(--text-main);
    direction: rtl;
    font-weight: 400;
    /* Regular */
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-cat {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge-role-super {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-role-admin {
    background: #F3F4F6;
    color: #374151;
}

.truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}

.btn-edit {
    background: #FEF3C7;
    color: #D97706;
}

.btn-delete {
    background: #FEE2E2;
    color: #DC2626;
}

/* Pagination */
.pagination-container {
    padding: 15px 20px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 5px;
}

.page-btn {
    border: 1px solid #D1D5DB;
    background: white;
    color: var(--text-main);
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
    text-decoration: none;
}

.page-btn:hover:not(:disabled) {
    background: #F3F4F6;
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: white;
    width: 600px;
    max-width: 90%;
    border-radius: 12px;
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    font-family: var(--font-main);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-cancel {
    background: white;
    border: 1px solid #D1D5DB;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
}

.hidden-section {
    display: none;
}

/* Responsive Design */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        height: 100%;
        z-index: 50;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .main-content {
        width: 100%;
    }

    #sidebar-toggle {
        display: flex !important;
    }

    .top-bar {
        padding: 15px;
    }

    .content-padding {
        padding: 15px;
    }

    .page-title {
        font-size: 1rem;
    }

    /* Adjust Modal width on mobile */
    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }

    .form-group {
        width: 100% !important;
    }

    /* Stack grid columns in modal */
    .modal-content .form-group {
        /* This ensures grid items stack */
    }

    /* Override grid layout in modal for mobile */
    #modal-ayat .modal-content div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Hide some table columns on very small screens if needed, 
       but overflow-x handles it. */

    /* Adjust text sizes */
    .stat-info h3 {
        font-size: 1.5rem;
    }

    /* Table Header fixes for mobile */
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .table-tools {
        width: 100%;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .search-input {
        width: 100%;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
    }
}