:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --accent: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --font-family: 'Cairo', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    color: var(--text-light);
    min-height: 100vh;
    direction: rtl;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 1.25rem;
}

.logo-icon {
    font-size: 2.2rem;
    background: rgba(139, 92, 246, 0.2);
    padding: 0.5rem;
    border-radius: 12px;
}

.brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.family-tag {
    color: var(--info);
    font-size: 0.8rem;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.25), rgba(139, 92, 246, 0.05));
    color: #fff;
    border-right: 4px solid var(--primary);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-title h1 {
    font-size: 1.7rem;
    font-weight: 800;
}

.header-title p {
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    padding: 0.65rem 1.2rem;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4); }

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

.btn-secondary { background: rgba(255, 255, 255, 0.1); color: #fff; }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    background: rgba(139, 92, 246, 0.2);
    color: #d8b4fe;
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    cursor: pointer;
}

.btn-tab {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}

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

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    padding: 1.25rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2.2rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem;
    border-radius: 14px;
}

.stat-info h3 { font-size: 0.9rem; color: var(--text-muted); }
.stat-number { font-size: 1.4rem; font-weight: 800; color: #fff; margin-top: 0.2rem; }
.alert-text { color: var(--warning); }

/* Tab Content */
.tab-content { display: none; }
.tab-content.active { display: block; }

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-highlight {
    border: 1px solid rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.05);
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.75rem;
}

.content-row { display: flex; gap: 1.5rem; }
.flex-1 { flex: 1; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.data-table th, .data-table td {
    padding: 0.85rem 1rem;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.data-table th { color: var(--text-muted); font-weight: 700; }
.data-table tr:hover { background: rgba(255, 255, 255, 0.02); }

/* Badges */
.badge {
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
}
.badge-primary { background: rgba(139, 92, 246, 0.25); color: #c084fc; }
.badge-success { background: rgba(16, 185, 129, 0.25); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.25); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.25); color: #f87171; }
.badge-info { background: rgba(6, 182, 212, 0.25); color: #22d3ee; }
.badge-secondary { background: rgba(255, 255, 255, 0.1); color: #fff; }

.status-badge { padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.8rem; }
.status-badge.online { background: rgba(16, 185, 129, 0.2); color: #34d399; }

.activity-list { display: flex; flex-direction: column; gap: 0.85rem; }
.activity-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.85rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.priority-urgent-border { border-right: 4px solid var(--danger); }
.item-subtext { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Meals Box */
.meal-today-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--card-border);
}
.meal-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.meal-badge { background: rgba(6, 182, 212, 0.2); color: var(--info); padding: 0.2rem 0.6rem; border-radius: 6px; font-size: 0.8rem; font-weight: bold; }
.alert { padding: 0.65rem 0.85rem; border-radius: 8px; margin-top: 0.75rem; font-size: 0.85rem; }
.alert-info { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: #fde047; }

/* Grid layouts */
.tasks-grid, .devices-grid, .meal-days-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.task-card, .device-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.25rem;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal-card {
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    padding: 2rem;
}
.modal-card h3 { margin-bottom: 1.25rem; color: #fff; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.form-row { display: flex; gap: 1rem; }

.input-field {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    font-family: inherit;
}
.input-field:focus { outline: none; border-color: var(--primary); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Lists styling */
.add-item-row { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.lists-items-box { display: flex; flex-direction: column; gap: 0.5rem; }
.list-item-row {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    gap: 0.75rem;
}
.list-item-row.struck { text-decoration: line-through; opacity: 0.5; }
