/* 
   =========================================
   Project: Ghanaim (غنمي) - Premium Revamp
   Version: 2.0
   Design: Modern Premium Rural
   =========================================
*/

/* ===== Design Tokens & System ===== */
:root {
  /* Color Palette - Premium Rural */
  --emerald:        #064e3b;
  --emerald-light:  #059669;
  --emerald-glow:   rgba(16, 185, 129, 0.15);
  --wheat:          #d97706;
  --wheat-soft:     #fef3c7;
  --slate:          #1e293b;
  --slate-light:    #64748b;
  --bg-main:        #f8fafc;
  --bg-card:        rgba(255, 255, 255, 0.85);
  --bg-glass:       rgba(255, 255, 255, 0.7);
  
  /* Indicators */
  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;

  /* Shadows & Effects */
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-premium: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --glass-border:   1px solid rgba(255, 255, 255, 0.4);
  
  /* Layout */
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      20px;
  --radius-xl:      32px;
  --nav-h:          72px;
  --header-h:       64px;
  --sidebar-w:      260px;
  --font-main:      'Tajawal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== Base Styles ===== */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Font is loaded via index.html link */

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: var(--bg-main);
  color: var(--slate);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-emerald {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ===== Auth Screen (Premium Glassmorphism) ===== */
#screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, var(--emerald), #022c22);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-bg::before, .login-bg::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: var(--emerald-light);
  filter: blur(100px);
  opacity: 0.1;
  z-index: 0;
}

.login-bg::before { top: -200px; right: -200px; }
.login-bg::after { bottom: -200px; left: -200px; }

.login-container {
  width: 100%;
  max-width: 400px;
  z-index: 10;
  animation: fadeInScale 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-brand {
  text-align: center;
  margin-bottom: 40px;
  color: white;
}

.login-icon {
  font-size: 56px;
  margin-bottom: 12px;
  display: block;
}

.login-brand h1 {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -1px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.login-brand p {
  opacity: 0.7;
  font-size: 16px;
  font-weight: 500;
}

.login-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--glass-border);
  padding: 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-premium);
}

.login-card h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 32px;
  text-align: center;
}

.input-group {
  margin-bottom: 20px;
  position: relative;
}

.input-group i {
  position: absolute;
  right: 18px; top: 50%;
  transform: translateY(-50%);
  color: var(--slate-light);
  font-size: 18px;
}

.input-group input {
  width: 100%;
  padding: 16px 52px 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.9);
  font-family: var(--font-main);
  font-size: 16px;
  outline: none;
  transition: all 0.3s;
}

.input-group input:focus {
  border-color: var(--emerald-light);
  box-shadow: 0 0 0 4px var(--emerald-glow);
}

.text-profit { color: var(--success) !important; }
.text-loss   { color: var(--danger) !important; }

.btn-login {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--emerald), var(--emerald-light));
  color: white;
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(5, 150, 105, 0.3);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex; align-items: center; justify-content: center; gap: 12px;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(5, 150, 105, 0.4);
}

.btn-login:active { transform: translateY(0); }

/* ===== Main App Shell ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (Hidden on Mobile, Sticky on Desktop) */
.sidebar {
  width: var(--sidebar-w);
  background: white;
  border-left: 1px solid rgba(0,0,0,0.05);
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0; height: 100vh;
  z-index: 100;
  transition: all 0.3s;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 32px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 24px;
}

.sidebar-logo {
  font-size: 28px;
  background: var(--emerald-glow);
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
}

.sidebar-brand h2 {
  font-size: 22px;
  font-weight: 900;
  color: var(--emerald);
}

.nav-list { list-style: none; flex: 1; }

.nav-item { margin-bottom: 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  color: var(--slate-light);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-link i, .nav-link .nav-sheep {
  font-size: 20px;
}

.nav-link:hover {
  background: var(--bg-main);
  color: var(--emerald);
}

.nav-active {
  background: var(--emerald-glow) !important;
  color: var(--emerald) !important;
}

.btn-add-floating {
  background: var(--emerald);
  color: white;
  border: none;
  padding: 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer;
  margin-top: 24px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
  transition: all 0.3s;
}

.btn-add-floating:hover {
  background: var(--emerald-light);
  transform: scale(1.02);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0; z-index: 90;
}

.page-title-main {
  font-size: 20px;
  font-weight: 800;
  color: var(--slate);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: var(--slate-light);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

#content {
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* View Components */
.view {
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dashboard Widgets */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.widget-card {
  background: white;
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 160px;
  border: 1px solid rgba(0,0,0,0.02);
}

.widget-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
}

.wc-1 .widget-icon { background: rgba(5, 150, 105, 0.1); color: var(--emerald); }
.wc-2 .widget-icon { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.wc-3 .widget-icon { background: rgba(217, 119, 6, 0.1); color: var(--wheat); }
.wc-4 .widget-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

.widget-val {
  font-size: 28px;
  font-weight: 900;
  margin-bottom: 4px;
  color: var(--slate);
  letter-spacing: -1px;
  line-height: 1.2;
}

.widget-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Sheep Cards Grid */
.sheep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.sheep-premium-card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0,0,0,0.03);
  cursor: pointer;
  position: relative;
}

.sheep-premium-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-premium);
  border-color: var(--emerald-light);
}

.card-img-wrapper {
  height: 200px;
  position: relative;
  background: #f1f5f9;
}

.card-img-wrapper img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.card-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px;
}

.status-badge {
  position: absolute;
  top: 16px; left: 16px;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.status-for-sale { background: rgba(16, 185, 129, 0.9); }
.status-reserved { background: rgba(245, 158, 11, 0.9); }
.status-sold     { background: rgba(100, 116, 139, 0.9); }

.card-content {
  padding: 20px;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--slate);
}

.card-price {
  font-size: 18px;
  font-weight: 900;
  color: var(--emerald);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.meta-chip {
  background: #f8fafc;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-light);
  border: 1px solid #e2e8f0;
}

/* Forms (Premium Look) */
.form-container {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  gap: 32px;
}

.form-segment {
  background: white;
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.segment-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 24px;
  display: flex; align-items: center; gap: 10px;
  color: var(--emerald);
}

.form-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-field { margin-bottom: 24px; }
.form-field:last-child { margin-bottom: 0; }

.form-field label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--slate);
}

.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 14px 18px;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  transition: all 0.2s;
  background: #fcfdfe;
}

.form-field input:focus {
  border-color: var(--emerald-light);
  box-shadow: 0 0 0 4px var(--emerald-glow);
  background: white;
}

.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  background: #f8fafc;
}

.upload-area:hover {
  border-color: var(--emerald-light);
  background: var(--emerald-glow);
}

.upload-icon { font-size: 40px; color: var(--slate-light); margin-bottom: 12px; }

/* Modal Design (Premium) */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeInScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 600px;
  border-radius: var(--radius-xl);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-premium);
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid #f1f5f9;
  display: flex; justify-content: space-between;
  align-items: center;
  position: sticky; top: 0; background: white; z-index: 10;
}

.modal-title-text { font-size: 20px; font-weight: 900; }

.modal-close-btn {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  background: #f1f5f9; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.modal-body { padding: 32px; }

/* Mobile Navigation (Floating Bottom Bar) */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .top-bar { padding: 0 20px; }
  #content { padding: 20px; }
  
  .bottom-nav-mobile {
    position: fixed; bottom: 16px; left: 16px; right: 16px;
    height: var(--nav-h);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: var(--glass-border);
    border-radius: var(--radius-xl);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 1000;
    box-shadow: var(--shadow-premium);
  }
  
  .nav-btn-mobile {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    background: none; border: none;
    color: var(--slate-light);
    font-family: inherit; font-size: 11px; font-weight: 700;
    cursor: pointer; position: relative;
    padding: 8px;
  }
  
  .nav-btn-mobile.active { color: var(--emerald); }
  .nav-btn-mobile i, .nav-btn-mobile .nav-sheep { font-size: 22px; }
  
  .nav-btn-add {
    width: 60px; height: 60px;
    background: var(--emerald);
    color: white !important;
    border-radius: 50%;
    margin-top: -40px;
    box-shadow: 0 8px 16px rgba(5, 150, 105, 0.3);
    border: 4px solid var(--bg-main);
  }
  
  .nav-btn-add i { font-size: 28px !important; }

  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .form-row-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .top-bar { justify-content: flex-end; }
  .page-title-main { display: none; }
}

/* Toast Notification (Premium) */
.toast-premium {
  position: fixed;
  bottom: 100px;
  left: 50%; transform: translateX(-50%);
  background: var(--slate);
  color: white;
  padding: 14px 28px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-premium);
  display: flex; align-items: center; gap: 12px;
  animation: toastIn 3s ease forwards;
}

@keyframes toastIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  90% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Analytics Premium Styles */
.analytics-header {
  margin-bottom: 32px;
  background: linear-gradient(135deg, var(--emerald), #022c22);
  padding: 40px;
  border-radius: var(--radius-lg);
  color: white;
  box-shadow: var(--shadow-lg);
}

.analytics-header h2 { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.analytics-header p { opacity: 0.8; font-weight: 500; }

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 24px;
}

.premium-analysis-card {
  background: white;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0,0,0,0.03);
}

.premium-analysis-card h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.analysis-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px dashed #f1f5f9;
  animation: fadeInUp 0.4s ease forwards;
}

.analysis-row:last-child { border-bottom: none; }

.row-info { display: flex; flex-direction: column; gap: 2px; }
.row-label { font-weight: 800; color: var(--slate); font-size: 15px; }
.row-sub { font-size: 12px; color: var(--slate-light); font-weight: 600; }
.row-val { font-weight: 900; font-size: 16px; }

#da-whatsapp {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#da-whatsapp:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

@media (max-width: 640px) {
  .analytics-header { padding: 30px 20px; }
  .analytics-grid { grid-template-columns: 1fr; }
}
