/* ==========================================================================
   youent — shared design system (same shapes as original app)
   Gradient header #667eea → #764ba2 · Dark sidebar #2c3e50 · Cards radius 10px
   ========================================================================== */

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f5f5;
  color: #2c3e50;
}

a { text-decoration: none; color: inherit; }

/* ---------- Layout ---------- */
.main-layout { min-height: 100vh; display: flex; flex-direction: column; }
.layout-body { display: flex; flex: 1; overflow: hidden; direction: rtl; }
.main-content { flex: 1; padding: 20px; overflow-y: auto; background-color: #f5f5f5; min-width: 0; }

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 500;
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  max-width: 1400px;
  margin: 0 auto;
}
.app-title { font-size: 20px; font-weight: 600; margin: 0; }
.header-right { display: flex; align-items: center; gap: 20px; }
.user-name { font-size: 14px; font-weight: 500; }
.btn-logout {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
}
.btn-logout:hover { background-color: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }

.user-menu { position: relative; display: inline-block; }
.user-menu-trigger { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.9); color: #333; border-radius: 4px; padding: 8px 12px; font-size: 14px; font-weight: 500; border: none; }
.user-dropdown {
  position: absolute; top: calc(100% + 5px); left: 0; right: auto; min-width: 200px;
  background: white; border: 1px solid #ddd; border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); overflow: hidden; z-index: 1000;
  animation: slideDown 0.2s ease;
}
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; text-align: right; padding: 10px 14px; font-size: 14px;
  color: #333; background: none; border: none; cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: #f5f5f5; }
.user-role-tag { font-size: 11px; color: #777; display: block; text-align: right; padding: 6px 14px; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: 250px;
  background-color: #2c3e50;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}
.sidebar-nav { padding: 20px 0; }
.nav-item {
  display: flex;
  align-items: center;
  padding: 13px 25px;
  color: #ecf0f1;
  transition: background-color 0.3s;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  font-weight: 500;
}
.nav-item:hover { background-color: #34495e; }
.nav-item.active { background-color: #3498db; border-right: 4px solid #2980b9; }
.nav-icon { font-size: 19px; width: 24px; text-align: center; }
.nav-text { font-size: 15px; font-weight: 500; flex: 1; }
.nav-arrow { font-size: 12px; transition: transform 0.3s ease; }
.nav-group-title.expanded .nav-arrow { transform: rotate(-180deg); }
.nav-group-items { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; background-color: #243444; }
.nav-group-items.show { max-height: 600px; transition: max-height 0.4s ease-in; }
.sub-item { padding-right: 45px; font-size: 14px; }
.sidebar-section-title {
  padding: 15px 25px 5px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #7f8c9b;
  text-transform: uppercase;
}

/* ---------- Cards / page container ---------- */
.page-container { min-height: 100%; background-color: transparent; padding: 20px; }
.page-content {
  background: white;
  border-radius: 10px;
  max-width: 1200px;
  margin: 0 auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 1px solid #dee2e6;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 10px 10px 0 0;
  gap: 10px;
  flex-wrap: wrap;
}
.page-title { font-size: 24px; margin: 0; color: white; font-weight: 600; }
.page-subtitle { font-size: 13px; opacity: .85; margin-top: 4px; }
.page-body { padding: 30px; }
.page-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 30px;
  border-top: 1px solid #dee2e6;
  background-color: #f8f9fa;
  border-radius: 0 0 10px 10px;
  flex-wrap: wrap;
}

.btn-back {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s;
}
.btn-back:hover { background: rgba(255, 255, 255, 0.3); transform: translateX(-2px); }

/* ---------- Sections & forms ---------- */
.info-section { margin-bottom: 30px; }
.section-title {
  font-size: 18px;
  color: #2c3e50;
  margin: 0;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f8f9fa;
}
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 10px; flex-wrap: wrap; }
.items-count {
  background: #667eea;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 15px;
}
.items-actions { display: flex; align-items: center; gap: 10px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.form-group { display: flex; flex-direction: column; }
.form-group label { font-weight: 600; color: #2c3e50; margin-bottom: 8px; font-size: 14px; }
.form-control {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
  transition: border-color 0.3s;
  font-family: inherit;
  width: 100%;
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }
.form-control:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.form-control:disabled, .form-control[readonly] { background-color: #f8f9fa; cursor: not-allowed; }
.form-control::placeholder { color: #adb5bd; font-style: italic; }
.required { color: #dc3545; margin-left: 4px; }
.help-text { font-size: 12px; color: #6c757d; margin-top: 5px; }

/* Error states */
.has-error .form-control { border-color: #dc3545; animation: shake 0.4s ease-in-out; }
.has-error .form-control:focus { border-color: #dc3545; box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1); }
.error-message { display: block; color: #dc3545; font-size: 12px; margin-top: 5px; font-weight: 500; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* ---------- Tables ---------- */
.items-table {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #dee2e6;
}
.items-table table { width: 100%; border-collapse: collapse; }
.items-table th,
.items-table td { padding: 12px 15px; text-align: right; border-bottom: 1px solid #dee2e6; }
.items-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #2c3e50;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.items-table tbody tr { transition: background-color 0.2s; }
.items-table tbody tr:hover { background-color: #f8f9fa; }
.items-table tbody tr:last-child td { border-bottom: none; }
.item-name { font-weight: 500; color: #2c3e50; }
.total-cell { font-weight: 600; color: #667eea; }
.items-table tfoot td {
  font-weight: 600;
  background-color: #f8f9fa;
  border-bottom: none;
  padding: 15px;
  font-size: 15px;
}
.text-muted-cell { color: #999; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  background-color: #e3f2fd;
  color: #1976d2;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background-color: #e8f5e9; color: #2e7d32; }
.badge-danger { background-color: #ffebee; color: #c62828; }
.badge-warning { background-color: #fff8e1; color: #f57f17; }
.badge-secondary { background-color: #eceff1; color: #546e7a; }
.badge-purple { background-color: #ede7f6; color: #5e35b1; }

.empty-items { text-align: center; padding: 60px 20px; color: #7f8c8d; }
.empty-items p { margin: 0; font-size: 16px; }

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  font-family: inherit;
  line-height: 1.4;
}
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 4px; }
.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4); }
.btn-success { background-color: #28a745; color: white; }
.btn-success:hover { background-color: #218838; transform: translateY(-1px); }
.btn-validate { background: linear-gradient(135deg, #28a745 0%, #20c997 100%); color: white; }
.btn-validate:hover { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4); }
.btn-secondary { background-color: #6c757d; color: white; }
.btn-secondary:hover { background-color: #5a6268; transform: translateY(-1px); }
.btn-danger { background-color: #dc3545; color: white; }
.btn-danger:hover { background-color: #c82333; transform: translateY(-1px); }
.btn-warning { background-color: #f39c12; color: white; }
.btn-warning:hover { background-color: #e67e22; transform: translateY(-1px); }
.btn-outline { background: white; color: #667eea; border: 1px solid #667eea; }
.btn-outline:hover { background: #f4f6ff; }
.btn-add-item {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}
.btn-add-item:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  transition: transform 0.2s;
  text-decoration: none;
  display: inline-block;
}
.btn-icon:hover { transform: scale(1.2); }

/* ---------- Filter bar / toolbar ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar .form-control { max-width: 320px; }
.toolbar form { display: contents; }

/* ---------- Metadata ---------- */
.metadata-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid #dee2e6; }
.metadata-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; }
.metadata-item { display: flex; align-items: center; gap: 10px; }
.metadata-label { font-weight: 600; color: #6c757d; font-size: 13px; }
.metadata-value { color: #2c3e50; font-size: 13px; }

/* ---------- Dashboard stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.stat-card {
  background: white;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: transform 0.3s, box-shadow 0.3s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; flex-shrink: 0;
  background: linear-gradient(135deg, #667eea33 0%, #764ba233 100%);
}
.stat-value { font-size: 22px; font-weight: 700; color: #2c3e50; }
.stat-label { font-size: 13px; color: #6c757d; margin-top: 2px; }

.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.quick-link {
  background: white; border-radius: 10px; padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); text-align: center;
  transition: all 0.3s; display: block;
}
.quick-link:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(102, 126, 234, 0.25); }
.quick-link .ql-icon { font-size: 30px; margin-bottom: 8px; }
.quick-link .ql-text { font-weight: 600; font-size: 14px; color: #2c3e50; }

.progress-track { background: #edf0f5; border-radius: 8px; height: 12px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transition: width 0.6s ease;
}
.progress-fill.over { background: linear-gradient(135deg, #dc3545 0%, #e67e22 100%); }

/* ---------- Flash messages ---------- */
.flash-messages { position: fixed; top: 80px; left: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.flash {
  padding: 14px 22px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  animation: slideDown 0.25s ease;
  max-width: 380px;
}
.flash-success { background: #27ae60; }
.flash-error { background: #e74c3c; }
.flash-info { background: #3498db; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}
.login-card-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-align: center;
  padding: 30px 20px;
}
.login-card-header h1 { font-size: 22px; font-weight: 700; }
.login-card-header p { font-size: 13px; opacity: 0.85; margin-top: 6px; }
.login-card-body { padding: 30px; }
.login-card-body .form-group { margin-bottom: 18px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #555; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; }
.login-hint { margin-top: 18px; text-align: center; font-size: 12px; color: #999; }

/* ---------- Permissions matrix ---------- */
.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: right; }
.perm-check { width: 18px; height: 18px; accent-color: #667eea; cursor: pointer; }
.role-pill {
  display: inline-block; padding: 3px 10px; margin: 2px;
  border-radius: 12px; font-size: 11px; font-weight: 600;
  background: #ede7f6; color: #5e35b1;
}

/* ---------- Pagination ---------- */
.pagination-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 10px; flex-wrap: wrap; }
.pagination-links nav ul { display: flex; gap: 5px; list-style: none; }
.page-link-btn {
  padding: 7px 13px; border-radius: 6px; border: 1px solid #dee2e6;
  font-size: 13px; color: #495057; background: white; display: block;
}
.page-link-btn.active { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-color: transparent; }
.page-link-btn:hover:not(.active):not(span) { background: #f8f9fa; }
.page-link-btn.disabled { opacity: .5; pointer-events: none; }

/* ---------- Modal (confirm delete) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 3000; padding: 20px;
}
.modal-box {
  background: white; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  width: 100%; max-width: 420px; overflow: hidden; animation: slideDown .2s ease;
}
.modal-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 16px 22px; font-weight: 600; }
.modal-body { padding: 24px 22px; font-size: 14px; color: #444; line-height: 1.7; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; background: #f8f9fa; border-top: 1px solid #dee2e6; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .main-content { padding: 10px; }
  .layout-body { flex-direction: column-reverse; }
  .app-sidebar { width: 100%; box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1); order: 2; }
  .sidebar-nav { display: flex; flex-wrap: wrap; padding: 8px 4px; gap: 2px; }
  .nav-item { padding: 10px 12px; font-size: 13px; gap: 6px; }
  .sub-item { padding-right: 20px; }
  .nav-group-items, .nav-arrow { display: none !important; }
  .page-container { padding: 10px; }
  .page-body { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .header-content { padding: 12px 16px; }
  .user-name { display: none; }
}
