/* ============================================================
   TAQA Enterprise OS — style.css v4
   ============================================================ */

/* ===== CSS VARIABLES ===== */
:root {
  --primary:    #005459;
  --primary-light: #00737a;
  --secondary:  #E87722;
  --success:    #059669;
  --danger:     #DC2626;
  --warning:    #D97706;
  --info:       #2563EB;
  --bg:         #F1F5F9;
  --surface:    #FFFFFF;
  --surface2:   #F8FAFC;
  --text:       #1E293B;
  --text2:      #475569;
  --text3:      #94A3B8;
  --border:     #E2E8F0;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:     8px;
  --radius-lg:  12px;
  --sidebar-w:  260px;
  --topbar-h:   56px;
  --transition: all .2s ease;
}
[data-theme="dark"] {
  --bg:       #0F172A;
  --surface:  #1E293B;
  --surface2: #0F172A;
  --text:     #F1F5F9;
  --text2:    #CBD5E1;
  --text3:    #64748B;
  --border:   #334155;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ===== LOGIN ===== */
#loginScreen {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, #00737a 50%, #E87722 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  overflow: hidden;
}
.login-title    { font-size: 26px; font-weight: 900; color: var(--primary); letter-spacing: 1px; }
.login-subtitle { font-size: 13px; color: var(--text3); margin-bottom: 24px; }
.login-lang-btns { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; }
.login-lang-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text3);
  font-size: 12px;
  font-weight: 600;
  transition: var(--transition);
}
.login-lang-btn.active,
.login-lang-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== APP SHELL ===== */
#appShell { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .3s ease;
  z-index: 100;
}
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sidebar-logo-text { color: #fff; font-size: 18px; font-weight: 900; line-height: 1; }
.sidebar-logo-sub  { color: rgba(255,255,255,.6); font-size: 10px; margin-top: 2px; }
.sidebar-user {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
.sidebar-user-inner { display: flex; align-items: center; gap: 10px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }
.nav-section {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: right;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 700; border-right: 3px solid var(--secondary); }
[dir="ltr"] .nav-item.active { border-right: none; border-left: 3px solid var(--secondary); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-badge {
  margin-right: auto;
  background: var(--secondary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
[dir="ltr"] .nav-badge { margin-right: 0; margin-left: auto; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

/* ===== MAIN AREA ===== */
#mainArea { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
#sidebarToggleBtn { display: none; }
#pageContent {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
#pageContent::-webkit-scrollbar { width: 6px; }
#pageContent::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--primary); }
.card-body { padding: 20px; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 10px; }
.page-title i { color: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-light); border-color: var(--primary-light); }
.btn-secondary{ background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-secondary:hover { filter: brightness(1.1); }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-outline  { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-outline:hover { background: var(--surface2); border-color: var(--text3); }
.btn-icon     { background: transparent; border: none; color: var(--text3); padding: 6px; border-radius: var(--radius); }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-sm       { padding: 5px 12px; font-size: 12px; }
.btn-lg       { padding: 12px 24px; font-size: 15px; }
.w-full       { width: 100%; }

/* ===== FORMS ===== */
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,84,89,.1); }
.form-control::placeholder { color: var(--text3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.required { color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ===== TABLE ===== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead tr { background: var(--surface2); }
.data-table th {
  padding: 10px 14px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text3);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
[dir="ltr"] .data-table th { text-align: left; }
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text2);
}
.data-table tbody tr:hover { background: var(--surface2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success   { background: #D1FAE5; color: #065F46; }
.badge-danger    { background: #FEE2E2; color: #991B1B; }
.badge-warning   { background: #FEF3C7; color: #92400E; }
.badge-info      { background: #DBEAFE; color: #1E40AF; }
.badge-secondary { background: var(--surface2); color: var(--text3); border: 1px solid var(--border); }

/* ===== LIST ITEMS ===== */
.list-items { }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface2); }

/* ===== AVATAR ===== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(.95) translateY(-10px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.modal-body  { padding: 20px; }
.modal-footer{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  justify-content: flex-end;
}
[dir="rtl"] .modal-footer { justify-content: flex-start; }

/* ===== TOAST ===== */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
[dir="rtl"] #toastContainer { right: auto; left: 20px; }
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 220px;
  max-width: 320px;
  animation: toastIn .3s ease;
  transition: opacity .3s;
}
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.alert-info    { background: #DBEAFE; color: #1E40AF; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-warning { background: #FEF3C7; color: #92400E; }
.alert-danger  { background: #FEE2E2; color: #991B1B; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ===== MISC ===== */
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
code   { font-family: 'Courier New', monospace; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  #sidebarToggleBtn { display: flex !important; }
  #sidebar {
    position: fixed;
    top: 0;
    right: 0;
    transform: translateX(100%);
    height: 100vh;
  }
  [dir="ltr"] #sidebar { right: auto; left: 0; transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid   { grid-template-columns: 1fr; }
  #pageContent { padding: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .modal-box  { max-height: 95vh; }
}
