/* ======================================================
   NASIYE-INVOICE SYSTEM - CUSTOM CSS
   ====================================================== */

:root {
  --primary-color: #4f46e5;
  --bg-main: #f8fafc;
  --sidebar-bg: #111827;
  --sidebar-active: #4f46e5;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-dark);
  display: flex;
  min-height: 100vh;
}

/* ======================================================
   SIDEBAR STYLING
   ====================================================== */
.sidebar {
  width: 250px;
  background-color: #3a0439;
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 100;
}

.sidebar .brand {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.sidebar-menu a {
  color: #94a3b8;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  transition: all 0.25s ease-in-out;
  position: relative;
}

/* Hover Effect */
.sidebar-menu a:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(3px);
}

/* Active State Design */
.sidebar-menu a.active {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* Active Indicator Bar (Dhinaca Bidix) */
.sidebar-menu a.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 20%;
  height: 60%;
  width: 4px;
  background-color: #38bdf8;
  border-radius: 0 4px 4px 0;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: #c5cacf;
  text-align: center;
}

/* ======================================================
   MAIN CONTENT & FIXED HEADER LAYOUT
   ====================================================== */
.main-content {
  margin-left: 250px;
  flex: 1;
  padding: 0 12px 12px 12px; /* Dusha ka 0px si uu header-ku dusha toos ugu dhago */
  width: calc(100% - 250px);
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  background: #E1E5E3;
  padding: 16px 24px;
  border-radius: 0 0 12px 12px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.top-header h1 {
  font-size: 20px;
  color: var(--text-dark);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background-color: #e0e7ff;
  color: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

/* ======================================================
   SUMMARY GRID & CARDS
   ====================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
}

.text-danger { color: #e11d48; }
.text-success { color: #059669; }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.icon-red { background-color: #ffe4e6; }
.icon-green { background-color: #d1fae5; }
.icon-purple { background-color: #e0e7ff; }

/* ======================================================
   TABLE CONTAINER & BADGES
   ====================================================== */
.content-card {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.btn-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}

/* Custom Table */
.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.custom-table th {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.badge-type {
  background-color: #fef3c7;
  color: #b45309;
}

.badge-paid {
  background-color: #d1fae5;
  color: #047857;
}

.badge-unpaid {
  background-color: #ffe4e6;
  color: #be123c;
}

/* ======================================================
   RESPONSIVE FIX (MOBILE & TABLET)
   ====================================================== */
@media (max-width: 1023px) {
  
  .sidebar {
    width: 70px !important;
    min-width: 70px !important;
    padding: 20px 0 !important;
  }

  .sidebar .brand {
    justify-content: center !important;
    margin-bottom: 24px !important;
    font-size: 22px !important;
  }

  .sidebar-menu a {
    justify-content: center !important;
    padding: 12px 0 !important;
    font-size: 20px !important;
  }

  .sidebar-menu a.active::before {
    display: none; /* Ka saar bar-ka marka ay moobayl tahay */
  }

  .sidebar .brand-text,
  .sidebar .menu-text,
  .sidebar-footer {
    display: none !important;
  }

  .main-content {
    margin-left: 70px !important;
    width: calc(100% - 70px) !important;
    padding: 0 12px 12px 12px !important;
  }

  .main-content > *,
  .main-content div,
  main > div {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  .top-header {
    padding: 12px 16px !important;
    margin-bottom: 16px !important;
  }

  /* 3 Card ee hal row lagu soo koobay marka ay shaashadu yar tahay */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }

  .stat-card {
    padding: 10px 8px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    text-align: left;
  }

  .stat-card .label {
    font-size: 10px !important;
    line-height: 1.1;
    margin-bottom: 4px;
  }

  .stat-card .value {
    font-size: 15px !important;
  }

  .stat-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
    margin-top: 6px;
  }
}

/* Style-ka Global Loader-ka */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.95); /* Background yar oo daah-furan */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 99999; /* Wuxuu ka kor marayaa wax kasta */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Spinner Animation (Wareega) */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e2e8f0;
    border-top: 5px solid #4f46e5; /* Midabka loader-ka */
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#page-loader p {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    font-family: sans-serif;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fasalka lagu qarinayo marka uu bogga load-garoobo */
.loader-hidden {
    opacity: 0;
    visibility: hidden;
}