:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f1f5f9;
    --bg-sidebar: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

body.rtl { direction: rtl; }

/* Layout Structure */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 950;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 2.5rem;
}

.brand-icon { color: var(--primary); }

.sidebar-nav {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav a, .sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-nav a:hover, .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-active);
}

.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.logout-link:hover { color: var(--danger); }

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

body.rtl .main-content { margin-left: 0; margin-right: var(--sidebar-width); }
body.rtl .sidebar { left: auto; right: 0; }

[data-lucide] {
    width: 20px;
    height: 20px;
}

.top-bar {
    height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.content-body {
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Dashboard Elements */
h1 { font-size: 1.875rem; font-weight: 800; margin-bottom: 2rem; letter-spacing: -0.025em; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 { font-size: 0.875rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-info p { font-size: 1.75rem; font-weight: 800; color: var(--text-main); line-height: 1; margin-top: 0.25rem; }

/* Components */
.card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.table-responsive { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; padding: 1rem; text-align: left; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); }
body.rtl th { text-align: right; }
td { padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; color: var(--text-main); }
tr:hover td { background: #f8fafc; }

.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: #f8fafc; border-color: var(--secondary); }

.form-group { margin-bottom: 1.5rem; }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; }
input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: inherit;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }

/* Utility Styles */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }

/* Mobile Menu Button */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: none;
    padding: 0.5rem;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.btn-icon:hover {
    background: var(--bg-main);
}

/* Subscription Status Highlights */
.expired-row td { 
    background-color: #fee2e2 !important; 
    color: #991b1b !important;
}

.expiring-soon td { 
    background-color: #fff1f2 !important;
    border-bottom: 1px solid #fecaca !important;
    color: #991b1b !important;
}

/* Media Queries */
@media (max-width: 1024px) {
    :root { --sidebar-width: 220px; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 260px; left: 0; }
    body.rtl .sidebar { transform: translateX(100%); left: auto; right: 0; }
    .sidebar.mobile-open, body.rtl .sidebar.mobile-open { transform: translateX(0); }
    .main-content, body.rtl .main-content { margin: 0; }
    .btn-icon { display: flex; }
    .stats-grid { grid-template-columns: 1fr; }
    .top-bar { padding: 0 1rem; }
    .content-body { padding: 1.5rem 1rem; }
}

@media print {
    .sidebar, .top-bar, .no-print { display: none !important; }
    .main-content { margin: 0 !important; }
    .app-layout { display: block; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
