@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@600;700;800&family=Tajawal:wght@400;500;700&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg-base:        #0F1117;
  --bg-surface:     #1A1D27;
  --bg-elevated:    #222637;
  --bg-input:       #2A2F45;
  
  --accent-primary:  #4F8EF7;
  --accent-success:  #34D399;
  --accent-warning:  #FBBF24;
  --accent-danger:   #F87171;
  --accent-info:     #818CF8;
  --accent-whatsapp: #25D366;
  
  --text-primary:    #F1F5F9;
  --text-secondary:  #94A3B8;
  --text-muted:      #475569;
  
  --border-subtle:   #2A2F45;
  --border-default:  #374151;
  --border-focus:    #4F8EF7;
  
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;
  
  --font-display: 'Cairo', sans-serif;
  --font-body:    'Tajawal', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  font-family: inherit;
  user-select: none;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  direction: rtl;
  overflow-x: hidden;
  height: 100vh;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  outline: none;
}

button {
  cursor: pointer;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Layout Wrapper */
.app-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-col: column;
  flex-direction: column;
  padding: 24px 16px;
  height: 100%;
  flex-shrink: 0;
}

.sidebar-header {
  margin-bottom: 32px;
  padding: 0 8px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: rgba(79, 142, 247, 0.1);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1.2;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.sidebar-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin-bottom: 24px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.user-avatar {
  position: relative;
}

.user-avatar img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1px solid rgba(79, 142, 247, 0.2);
}

.user-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background-color: var(--accent-success);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role {
  font-size: 11px;
  color: var(--accent-primary);
  font-weight: 500;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
  margin-top: 24px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: rgba(79, 142, 247, 0.1);
  color: var(--accent-primary);
  border-right: 4px solid var(--accent-primary);
  padding-right: 12px; /* Adjust padding for border */
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  margin-top: auto;
}

.btn-logout {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--accent-danger);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition-fast);
  background: none;
  text-align: right;
}

.btn-logout:hover {
  background-color: rgba(248, 113, 113, 0.1);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  height: 100%;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

.content-container {
  max-width: 1280px;
  margin: 0 auto;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 40px;
}

.top-bar h2 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--accent-primary);
}

.top-bar p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.date-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Grids */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Stat Cards */
.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 24px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 140px;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.stat-icon {
  padding: 8px;
  background-color: rgba(79, 142, 247, 0.1);
  color: var(--accent-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.warning {
  background-color: rgba(251, 191, 36, 0.1);
  color: var(--accent-warning);
}

.stat-icon.success {
  background-color: rgba(52, 211, 153, 0.1);
  color: var(--accent-success);
}

.stat-icon.danger {
  background-color: rgba(248, 113, 113, 0.1);
  color: var(--accent-danger);
}

.stat-trend {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.stat-trend.up {
  color: var(--accent-success);
  background-color: rgba(52, 211, 153, 0.1);
}

.stat-trend.alert {
  color: var(--accent-warning);
  background-color: rgba(251, 191, 36, 0.1);
}

.stat-body {
  margin-top: 12px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition-fast);
  cursor: pointer;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: white;
}
.btn-primary:hover {
  background-color: #3b7ad6;
}

.btn-secondary {
  background-color: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover {
  background-color: var(--bg-input);
}

.btn-danger {
  background-color: rgba(248, 113, 113, 0.15);
  color: var(--accent-danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.btn-danger:hover {
  background-color: rgba(248, 113, 113, 0.25);
}

.btn-success {
  background-color: rgba(52, 211, 153, 0.15);
  color: var(--accent-success);
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.btn-success:hover {
  background-color: rgba(52, 211, 153, 0.25);
}

.btn-warning {
  background-color: rgba(251, 191, 36, 0.15);
  color: var(--accent-warning);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.btn-warning:hover {
  background-color: rgba(251, 191, 36, 0.25);
}

.btn-whatsapp {
  background-color: rgba(37, 211, 102, 0.15);
  color: var(--accent-whatsapp);
  border: 1px solid rgba(37, 211, 102, 0.3);
}
.btn-whatsapp:hover {
  background-color: rgba(37, 211, 102, 0.25);
}

/* Inputs & Form Fields */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-field {
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  width: 100%;
  transition: var(--transition-fast);
}

.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(79, 142, 247, 0.2);
}

.form-row {
  display: flex;
  gap: 16px;
}
.form-row .form-group {
  flex: 1;
}

/* Tables */
.table-container {
  overflow-x: auto;
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13px;
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background-color: rgba(52, 211, 153, 0.15);
  color: var(--accent-success);
}

.badge-warning {
  background-color: rgba(251, 191, 36, 0.15);
  color: var(--accent-warning);
}

.badge-danger {
  background-color: rgba(248, 113, 113, 0.15);
  color: var(--accent-danger);
}

.badge-info {
  background-color: rgba(129, 140, 248, 0.15);
  color: var(--accent-info);
}

/* Customer Search Page Layout */
.search-wrapper {
  position: relative;
  width: 100%;
  margin-bottom: 24px;
}

.search-input-container {
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

.search-input {
  width: 100%;
  height: 52px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 14px 48px 14px 16px; /* Extra padding on right for search icon */
  color: var(--text-primary);
  font-size: 16px;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 4px 20px rgba(79, 142, 247, 0.15);
}

/* Autocomplete Dropdown List */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 100%;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}

.autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition-fast);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.active {
  background-color: rgba(79, 142, 247, 0.1);
}

.autocomplete-name {
  font-weight: 600;
  color: var(--text-primary);
}

.autocomplete-phone {
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 8px;
}

.autocomplete-badge {
  font-size: 11px;
}

/* Customer Card Details */
.customer-profile-card {
  border-right: 4px solid var(--accent-primary);
}

.customer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.customer-name-lg {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.customer-phone-lg {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.customer-balance-box {
  text-align: left;
}

.balance-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.balance-val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
}

.balance-val.debt {
  color: var(--accent-danger);
}

.balance-val.credit {
  color: var(--accent-success);
}

.balance-val.clear {
  color: var(--text-secondary);
}

.customer-details-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 13px;
  font-weight: 500;
}

/* Actions Bar */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

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

.modal-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay.show .modal-container {
  transform: translateY(0);
}

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

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: slideUp 0.3s ease;
  transition: opacity 0.3s ease;
}

.toast.success {
  border-right: 4px solid var(--accent-success);
}

.toast.error {
  border-right: 4px solid var(--accent-danger);
}

.toast.info {
  border-right: 4px solid var(--accent-info);
}

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

/* Profit Unlock Style */
.blur-financials {
  filter: blur(10px);
  user-select: none;
  pointer-events: none;
}

.unlock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(26, 29, 39, 0.4);
  backdrop-filter: blur(4px);
  z-index: 5;
}

/* Tabs */
.tabs-container {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Login Page Custom Style */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  background-color: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 420px;
}
