:root {
  --primary: #1e3a8a;
  --primary-hover: #3b82f6;
  --success: #10b981;
  --success-hover: #059669;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --border: rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-fab: 0 8px 20px rgba(30, 58, 138, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.7;
  transition: direction 0.3s;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
}

.container {
  width: 100%;
  max-width: 850px;
  margin: 0 auto;
  padding-left: 20px !important;
  padding-right: 20px !important;
}

.navbar {
  background: linear-gradient(90deg, var(--primary) 0%, #3730a3 100%);
  padding: 0.6rem 0;
  color: white;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-content { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 0.6rem; }
/* Increased Logo Size to retain SVG details */
.brand-logo { width: clamp(32px, 8vw, 38px); height: auto; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: clamp(1.1rem, 4vw, 1.25rem); font-weight: 800; line-height: 1.1; letter-spacing: 0.2px; }
.brand-slogan { font-size: 0.7rem; font-weight: 500; opacity: 0.85; margin-top: 2px; }

.nav-menu { display: flex; align-items: center; gap: 0.8rem; }
.nav-links { display: flex; align-items: center; gap: 0.8rem; }
.nav-links a { color: white; text-decoration: none; font-weight: 600; font-size: 0.85rem; transition: opacity 0.2s; }
.nav-links a:hover { opacity: 0.8; }
.btn-lang { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); color: white; padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 0.8rem; transition: background 0.2s; }
.menu-toggle { display: none; background: transparent; border: none; color: white; cursor: pointer; padding: 0.4rem; }

.main-content { padding: 1.5rem 0 4rem; }
.view { display: none; animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

h2 { font-size: clamp(1.2rem, 4.5vw, 1.4rem); margin-bottom: 0.1rem; font-weight: 800; letter-spacing: -0.3px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.5rem; }
.page-header p.text-muted { font-size: 0.85rem; margin-top: 0.2rem; }
.section-title { margin-top: 1.5rem; margin-bottom: 1rem; font-size: 1.15rem; font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.auth-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; max-width: 400px; margin: 0 auto; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.card:active { transform: scale(0.97); box-shadow: var(--shadow-sm); }
.card h3 { font-size: 1.1rem; margin-bottom: 0.3rem; font-weight: 700; }
.card p { font-size: 0.9rem; line-height: 1.6; color: var(--text-dark); margin-bottom: 0.8rem; }
.bg-light { background: #f8fafc; }
.max-w-lg { max-width: 500px; margin: 0 auto; }

input, textarea, select, .custom-select {
  width: 100%; 
  padding: 0.6rem 0.8rem; 
  margin-bottom: 1rem; 
  border: 1px solid #cbd5e1; 
  border-radius: var(--radius-md); 
  font-size: 1rem; 
  background: var(--bg-card);
  min-height: 44px; 
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.1); }

.search-bar { display: flex; flex-direction: column; gap: 0.8rem; margin-bottom: 1.5rem; }
.search-input { margin-bottom: 0; }
.search-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.8rem; }
.search-filters select { margin-bottom: 0; font-size: 0.9rem; }

.btn {
  padding: 0.6rem 1rem; 
  border-radius: var(--radius-md); 
  font-weight: 600; 
  font-size: 0.9rem;
  cursor: pointer; 
  border: none; 
  text-align: center;
  min-height: 44px;
  transition: transform 0.15s ease, opacity 0.2s ease, background-color 0.2s ease;
}
.btn:active { transform: scale(0.95); opacity: 0.9; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: transparent; border: 1px solid #cbd5e1; color: var(--text-dark); }
.w-100 { width: 100%; }
.action-group { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.action-group .btn { flex: 1; }

.badge-container { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 0.4rem; 
  align-items: center; 
  margin-bottom: 0.8rem; 
}
.badge {
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
  padding: 0.25rem 0.6rem; 
  background: #e2e8f0; 
  color: #334155; 
  border-radius: 12px; 
  font-size: 0.75rem; 
  font-weight: 600; 
  line-height: 1.2; 
  margin: 0; 
}

.workspace-list { display: flex; flex-direction: column; gap: 1rem; }
.applicant-card {
  border-inline-start: 4px solid var(--primary);
  padding: 1rem; 
  background: var(--bg-main);
  margin-top: 0.5rem; 
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.fab { display: none; }

@media (max-width: 768px) {
  .brand-slogan { display: none; }
  .menu-toggle { display: block; }
  .desktop-btn { display: none !important; }
  
  .fab.visible {
    display: flex; position: fixed;
    bottom: max(1.5rem, env(safe-area-inset-bottom)); right: 20px;
    width: 56px; height: 56px; border-radius: 50%;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow-fab); z-index: 90; padding: 0;
  }
  [dir="rtl"] .fab.visible { right: auto; left: 20px; }

  .nav-menu {
    display: none; flex-direction: column; position: absolute;
    top: 100%; left: 0; right: 0; background: var(--primary);
    padding: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .nav-menu.active { display: flex; }
  .nav-links { flex-direction: column; width: 100%; gap: 0.5rem; }
  .nav-links a, .nav-links button { width: 100%; text-align: center; padding: 0.8rem; border-radius: var(--radius-sm); background: rgba(255,255,255,0.05); }
  .btn-lang { width: 100%; margin: 0.5rem 0 0 0; padding: 0.8rem; }

  .modal {
    display: none; position: fixed; top:0; left:0; width:100%; height:100%; 
    background:rgba(15, 23, 42, 0.5); backdrop-filter: blur(3px); 
    align-items: flex-end; justify-content: center; z-index:1000;
  }
  .modal.active { display: flex; }
  .modal-content {
    width: 100%; background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 1.5rem 20px calc(1.5rem + env(safe-area-inset-bottom));
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .action-group { flex-direction: column-reverse; gap: 0.5rem; }
}

@media (min-width: 769px) {
  .modal {
    display: none; position: fixed; top:0; left:0; width:100%; height:100%; 
    background:rgba(15, 23, 42, 0.5); backdrop-filter: blur(3px); 
    align-items: center; justify-content: center; z-index:1000; padding: 1rem;
  }
  .modal.active { display: flex; }
  .modal-content { width: 100%; max-width: 400px; border-radius: var(--radius-lg); padding: 1.5rem; animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes popIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  
  .auth-grid { grid-template-columns: 1fr 1fr; max-width: 750px; }
  .search-bar { flex-direction: row; }
  .search-input { flex: 2; }
  .search-filters { flex: 1.2; }
}

.toast-container { position: fixed; bottom: max(1.5rem, env(safe-area-inset-bottom)); right: 20px; display: flex; flex-direction: column; gap: 0.5rem; z-index: 2000; }
[dir="rtl"] .toast-container { right: auto; left: 20px; }
.toast { min-width: 220px; padding: 0.8rem 1rem; border-radius: var(--radius-sm); color: white; font-weight: 600; box-shadow: var(--shadow-md); font-size: 0.85rem; }
.toast.success { background: var(--success); }
.toast.error { background: #dc2626; }
