/* =====================================================
   نظام إدارة شركة التأمين - ملف CSS الرئيسي
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

/* ========== المتغيرات الجذرية ========== */
:root {
  --primary: #f08b22;
  /* Logo Orange */
  --primary-light: #f5a24b;
  --primary-darker: #d17316;
  --accent: #8d9296;
  /* Logo Grey */
  --success: #2e7d32;
  --danger: #c62828;
  --warning: #f57f17;
  --info: #0277bd;
  --secondary: #6b7278;

  --bg-app: #f5f6f8;
  --bg-card: #ffffff;
  --bg-sidebar: #303438;
  /* Dark Grey Sidebar */
  --sidebar-width: 270px;
  --navbar-height: 60px;

  --text-main: #2b3035;
  --text-muted: #6c757d;
  --border-color: #dde3ea;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, .12);
  --shadow-lg: 0 8px 35px rgba(0, 0, 0, .18);

  --transition: all 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Reset & Base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ========== Navbar ========== */
.ins-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  z-index: 1040;
  background: linear-gradient(90deg, var(--primary-darker) 0%, var(--primary) 100%);
  box-shadow: 0 2px 15px rgba(13, 71, 161, .35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

.navbar-logo {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: white;
}

.sidebar-toggle {
  opacity: .8;
  transition: var(--transition);
}

.sidebar-toggle:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* ========== Sidebar ========== */
.ins-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  z-index: 1035;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.ins-sidebar.collapsed {
  transform: translateX(100%);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  min-height: var(--navbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: white;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.nav-group-label {
  padding: 0.6rem 1.25rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.7rem 1.25rem;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  border-radius: 0;
  transition: var(--transition);
  font-size: 0.92rem;
  position: relative;
}

.nav-item-link i {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.nav-item-link:hover {
  color: white;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item-link.active {
  color: white;
  background: linear-gradient(90deg, rgba(30, 136, 229, 0.25) 0%, rgba(30, 136, 229, 0.05) 100%);
  border-right: 3px solid var(--primary-light);
}

.sidebar-sync-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
}

.sync-dot-sm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #66bb6a;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

.sync-dot-sm.offline {
  background: #ef5350;
  animation: none;
}

.btn-sync-now {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6);
  border-radius: 7px;
  padding: 3px 8px;
  transition: var(--transition);
}

.btn-sync-now:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.btn-sync-now.spinning i {
  animation: spin 1s linear infinite;
}

/* ========== Main Wrapper ========== */
.main-wrapper {
  padding-top: var(--navbar-height);
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  transition: var(--transition);
}

.main-wrapper.sidebar-closed {
  margin-right: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1030;
}

/* ========== Cards ========== */
.ins-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.ins-card-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.ins-card-header h5 {
  font-weight: 700;
  margin: 0;
  font-size: 1rem;
  color: var(--text-main);
}

.ins-card-body {
  padding: 1.4rem;
}

/* ========== Stats Cards ========== */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.stat-icon.blue {
  background: rgba(21, 101, 192, .1);
  color: var(--primary-light);
}

.stat-icon.green {
  background: rgba(46, 125, 50, .1);
  color: #43a047;
}

.stat-icon.orange {
  background: rgba(245, 127, 23, .1);
  color: #fb8c00;
}

.stat-icon.red {
  background: rgba(198, 40, 40, .1);
  color: #e53935;
}

.stat-icon.teal {
  background: rgba(0, 172, 193, .1);
  color: var(--accent);
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-change {
  font-size: 0.8rem;
  margin-top: 4px;
}

.stat-change.up {
  color: #43a047;
}

.stat-change.down {
  color: #e53935;
}

/* ========== Tables ========== */
.ins-table-wrapper {
  overflow-x: auto;
}

.ins-table {
  width: 100%;
  border-collapse: collapse;
}

.ins-table thead th {
  background: #f5f8fb;
  padding: 0.8rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  text-align: right;
}

.ins-table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
  font-size: 0.9rem;
}

.ins-table tbody tr:hover {
  background: #f8fafc;
}

.ins-table tbody tr:last-child td {
  border-bottom: none;
}

/* ========== Forms ========== */
.form-control,
.form-select {
  border-radius: var(--radius-sm) !important;
  border-color: var(--border-color) !important;
  font-size: 0.92rem;
  transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 3px rgba(30, 136, 229, .15) !important;
}

.form-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.input-group-text {
  background: #f5f8fb;
  border-color: var(--border-color);
  color: var(--text-muted);
}

/* ========== Buttons ========== */
.btn {
  border-radius: var(--radius-sm) !important;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary)) !important;
  border: none !important;
}

.btn-primary:hover {
  box-shadow: 0 4px 15px rgba(30, 136, 229, .4);
  transform: translateY(-1px);
}

.btn-sm {
  font-size: 0.8rem !important;
}

/* ========== Badges ========== */
.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: .38em .72em;
  border-radius: 6px;
}

/* ========== Page Header ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.page-header h4 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.page-breadcrumb {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========== Sync Status Badge ========== */
.sync-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  cursor: default;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #66bb6a;
  animation: pulse 2s infinite;
}

.sync-dot.offline {
  background: #ef5350;
  animation: none;
}

.sync-dot.syncing {
  background: #ffa726;
  animation: pulse .6s infinite;
}

/* ========== Animations ========== */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.35s ease forwards;
}

/* ========== User Menu ========== */
.user-menu-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 10px !important;
  padding: 5px 12px !important;
  transition: var(--transition);
}

.user-menu-btn:hover {
  background: rgba(255, 255, 255, 0.18) !important;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--primary-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ========== Alert Custom ========== */
.alert {
  border-radius: var(--radius-sm) !important;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ========== Search Filter Box ========== */
.filter-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  margin-bottom: 1.2rem;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3.5rem;
  opacity: .3;
  display: block;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.95rem;
  margin: 0;
}

/* ========== Progress bar ========== */
.progress {
  border-radius: 20px !important;
  height: 8px !important;
}

.progress-bar {
  border-radius: 20px !important;
}

/* ========== Print ========== */
@media print {

  .ins-sidebar,
  .ins-navbar,
  .no-print {
    display: none !important;
  }

  .main-wrapper {
    margin-right: 0 !important;
    padding-top: 0 !important;
  }

  body {
    background: white !important;
  }
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .main-wrapper {
    margin-right: 0;
  }

  .ins-sidebar {
    transform: translateX(100%);
  }

  .ins-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
  }
}