/* Cairo Font Import */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eeeffe;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark-bg: #0f172a;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --main-bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 80px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Cairo', sans-serif;
}

body {
  direction: rtl;
  background-color: var(--main-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* App Container */
#app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Styles (Right Side) */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 100;
  transition: var(--transition);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  white-space: nowrap;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.brand-text {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.2px;
  opacity: 1;
  transition: var(--transition);
}

.sidebar.collapsed .brand-text {
  opacity: 0;
  width: 0;
  display: none;
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 16px;
}

.toggle-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* Sidebar Menu */
.sidebar-menu {
  padding: 16px 12px;
  list-style: none;
  flex-grow: 1;
  overflow-y: auto;
}

.menu-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 12px 16px 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.sidebar.collapsed .menu-category {
  display: none;
}

.menu-item {
  margin-bottom: 6px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
  cursor: pointer;
}

.menu-link i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.menu-link:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.menu-link.active {
  background: linear-gradient(90deg, var(--primary) 0%, rgba(79, 70, 229, 0.8) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.menu-badge {
  margin-right: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.menu-badge.danger {
  background: var(--danger);
}

.sidebar.collapsed .menu-link span,
.sidebar.collapsed .menu-badge {
  display: none;
}

/* User Footer in Sidebar */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  overflow: hidden;
  white-space: nowrap;
}

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

.user-role {
  font-size: 0.75rem;
  color: var(--text-light);
}

.sidebar.collapsed .user-info {
  display: none;
}

/* Main Content Wrapper (Left Side) */
.main-wrapper {
  margin-right: var(--sidebar-width);
  width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.main-wrapper.expanded {
  margin-right: var(--sidebar-collapsed-width);
  width: calc(100vw - var(--sidebar-collapsed-width));
}

/* Top Header Bar */
.top-header {
  height: 72px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.header-title-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-main);
  cursor: pointer;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-box input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background-color: #f1f5f9;
  font-size: 0.9rem;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-box i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  color: var(--text-muted);
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

/* Page Content View Area */
.content-area {
  padding: 32px;
  flex-grow: 1;
}

.view-section {
  display: none;
  animation: fadeIn 0.4s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom Banner Slot */
.content-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.content-banner::after {
  content: '';
  position: absolute;
  left: -50px;
  bottom: -50px;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  pointer-events: none;
}

.banner-text h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
  font-weight: 700;
}

.banner-text p {
  color: #c7d2fe;
  font-size: 0.92rem;
}

.slot-notice {
  background: rgba(255, 255, 255, 0.12);
  border: 1px dashed rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #e0e7ff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grid & Metrics Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

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

.stat-info h4 {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.stat-info .value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

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

.stat-icon.primary { background: #eeeffe; color: var(--primary); }
.stat-icon.success { background: #d1fae5; color: var(--success); }
.stat-icon.warning { background: #fef3c7; color: var(--warning); }
.stat-icon.danger { background: #fee2e2; color: var(--danger); }

/* Custom Container / Card Box */
.custom-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h3 i {
  color: var(--primary);
}

.card-body {
  padding: 24px;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.custom-table th {
  background-color: #f8fafc;
  padding: 14px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-main);
}

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

.custom-table tr:hover {
  background-color: #f1f5f9;
}

/* Status Badges */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-block;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  transition: var(--transition);
  background: #fff;
}

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

/* Modal Overlay & Full Page Modal Layout */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  padding: 12px;
}

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

.modal-box {
  background: #fff;
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: var(--transition);
}

/* Full Screen Studio Modal Layout (98vw x 96vh) */
.modal-box.full-page-modal {
  max-width: 98vw;
  width: 98vw;
  height: 96vh;
  max-height: 96vh;
  border-radius: var(--radius-lg);
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 28px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: #e2e8f0;
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-box.full-page-modal .modal-body {
  padding: 20px 28px;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  background: #f8fafc;
  flex-shrink: 0;
}

/* Drag and Drop Zone */
.drop-zone {
  border: 2px dashed #10b981;
  background: #f0fdf4;
  border-radius: var(--radius-md);
  padding: 18px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
}

.drop-zone:hover, .drop-zone.drag-over {
  background: #dcfce7;
  border-color: #059669;
}

.drop-zone i {
  font-size: 2.2rem;
  color: #10b981;
  margin-bottom: 6px;
}

/* Full Page Split View Grid */
.full-page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  height: 100%;
}

@media (max-width: 1080px) {
  .full-page-grid {
    grid-template-columns: 1fr;
  }
}

/* PDF Document Visual Preview Card & Document Canvas */
.invoice-preview-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  font-size: 0.85rem;
  color: #1e293b;
  min-height: 100%;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.preview-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f172a;
}

.preview-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.82rem;
}

.preview-table th, .preview-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  text-align: right;
}

.preview-table th {
  background: #e2e8f0;
  font-weight: 700;
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-main);
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
}

/* Responsive queries */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    width: 260px;
  }
  .main-wrapper,
  .main-wrapper.expanded {
    margin-right: 0;
    width: 100vw;
  }
  .mobile-toggle {
    display: block;
  }
}
