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

:root {
    --primary: #4f46e5;      /* Indigo */
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --accent: #b45309;       /* Gold/Amber */
    --accent-light: #fef3c7;
    --success: #059669;      /* Emerald */
    --success-light: #d1fae5;
    --danger: #dc2626;       /* Red */
    --danger-light: #fee2e2;
    --warning: #d97706;      /* Orange */
    --warning-light: #fef3c7;
    --dark: #0f172a;         /* Slate 900 */
    --dark-light: #1e293b;   /* Slate 800 */
    --light: #f8fafc;        /* Slate 50 */
    --bg-main: #f1f5f9;      /* Slate 100 */
    --gray: #64748b;         /* Slate 500 */
    --gray-light: #cbd5e1;   /* Slate 300 */
    --border: #e2e8f0;       /* Slate 200 */
    --white: #ffffff;
    --font-family: 'Tajawal', sans-serif;
    --radius-sm: 8px;
    --radius: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(226, 232, 240, 0.8);
}

/* Global Reset & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--dark);
    direction: rtl;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background-color: var(--white);
    color: var(--dark);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: var(--light);
    transform: translateY(-2px);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background-color: #b91c1c;
    transform: translateY(-2px);
}

.btn-success {
    background-color: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background-color: #047857;
    transform: translateY(-2px);
}

/* Auth Layout */
.auth-container {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
                radial-gradient(circle at bottom left, rgba(217, 119, 6, 0.1), transparent 40%);
}

.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
}

.auth-subtitle {
    color: var(--gray);
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--dark-light);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: var(--font-family);
    font-size: 0.95rem;
    background-color: var(--white);
    color: var(--dark);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

input[type="date"], input[type="datetime-local"] {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    direction: rtl;
    text-align: right;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--gray);
}

.form-checkbox input {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

.error-message {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 6px;
}

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-danger {
    background-color: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.alert-success {
    background-color: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(5, 150, 105, 0.15);
}

/* Dashboard Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: 280px;
    background-color: var(--dark);
    color: var(--white);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    right: 0;
    top: 0;
    z-index: 100;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    transition: var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--dark-light);
}

.sidebar-logo span {
    color: #818cf8; /* Light Indigo */
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: #94a3b8; /* Slate 400 */
    font-weight: 500;
    font-size: 0.95rem;
}

.sidebar-item.active a,
.sidebar-item a:hover {
    color: var(--white);
    background-color: var(--dark-light);
}

.sidebar-item.active a {
    border-right: 4px solid #818cf8;
}

.sidebar-user {
    padding-top: 20px;
    border-top: 1px solid var(--dark-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 44px;
    height: 44px;
    background-color: #818cf8;
    color: var(--dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Main Content Area */
.app-content {
    flex-grow: 1;
    margin-right: 280px;
    padding: 40px;
    background-color: var(--bg-main);
    min-height: 100vh;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--gray);
}

/* Cards & Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
    background-color: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stats Card */
.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background-color: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background-color: var(--success-light);
    color: var(--success);
}

.stat-icon.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

.stat-icon.danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    font-weight: 500;
}

/* Lists and Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 0.95rem;
}

th {
    padding: 14px 16px;
    font-weight: 600;
    color: var(--gray);
    border-bottom: 2px solid var(--border);
    font-size: 0.85rem;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    color: var(--dark-light);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: var(--light);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-success { background-color: var(--success-light); color: var(--success); }
.badge-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }

/* Quick Actions & Widgets */
.action-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background-color: var(--light);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.action-item:hover {
    border-color: var(--primary);
    background-color: var(--white);
}

.action-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.action-time {
    font-size: 0.75rem;
    color: var(--gray);
}

/* Form Styles inside Main Panel */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.text-area {
    width: 100%;
    min-height: 120px;
    resize: vertical;
}

/* Modal Simple Style */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    padding: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray);
    border: none;
    background: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 1024px) {
    .app-sidebar {
        width: 80px;
        padding: 16px 8px;
    }
    .sidebar-logo span,
    .sidebar-item span,
    .sidebar-user .user-details,
    .sidebar-user form {
        display: none;
    }
    .sidebar-logo {
        justify-content: center;
        margin-bottom: 24px;
        padding-bottom: 16px;
    }
    .sidebar-item a {
        justify-content: center;
        padding: 12px;
    }
    .app-content {
        margin-right: 80px;
        padding: 24px;
    }
}

@media (max-width: 640px) {
    .app-content {
        padding: 16px;
    }
    .header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}
