/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --bg:              #f8f9fb;
  --surface:         #ffffff;
  --border:          #e8eaed;
  --primary:         #1a3a5c;
  --primary-light:   #e8f0fe;
  --text-primary:    #1c1e21;
  --text-secondary:  #6b7280;
  --success:         #16a34a;
  --warning:         #d97706;
  --danger:          #dc2626;
  --radius:          12px;
  --shadow:          0 1px 4px rgba(0, 0, 0, 0.08);

  --font-family:     'IBM Plex Sans Arabic', sans-serif;
  --font-size-base:  15px;
  --spacing:         8px;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  direction: rtl;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

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

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 calc(var(--spacing) * 3);
  height: 56px;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.app-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.app-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--spacing) * 3);
}

/* Print container — hidden on screen, shown by print.css during window.print() */
#print-report {
  display: none;
}

/* ============================================================
   Login Screen — Phase 4 Visual Polish
   ============================================================ */

/* Entrance animation for each element */
@keyframes login-rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Full-screen dark-blue container */
#login-screen {
  position: fixed;
  inset: 0;
  /* Layered background: subtle radial glow over solid primary */
  background:
    radial-gradient(ellipse 600px 400px at 50% 35%, rgba(255,255,255,0.06) 0%, transparent 70%),
    #1a3a5c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  direction: rtl;
  z-index: 9999;
  padding: calc(var(--spacing) * 3);
  /* Entrance fade-in for the whole screen */
  animation: login-rise 0.4s ease both;
}

/* App name — large and prominent */
.login-logo {
  font-size: 64px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -2px;
  line-height: 1;
  animation: login-rise 0.4s 0.05s ease both;
}

/* Subtle divider line below the name */
.login-logo::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  margin: 14px auto 0;
}

.login-subtitle {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  max-width: 220px;
  line-height: 1.6;
  animation: login-rise 0.4s 0.10s ease both;
}

/* Google sign-in button */
.login-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  color: #1c1e21;
  border: none;
  border-radius: 14px;
  padding: 15px 32px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  margin-top: 12px;
  min-width: 240px;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0,0,0,0.15);
  animation: login-rise 0.4s 0.18s ease both;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.login-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Loading state — button shows spinner */
.login-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

.login-btn .login-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e0e0e0;
  border-top-color: #1a3a5c;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

/* Error banner */
.login-error {
  background: rgba(220, 38, 38, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 10px;
  padding: 11px 22px;
  font-size: 13px;
  text-align: center;
  max-width: 280px;
  line-height: 1.5;
  animation: login-rise 0.25s ease both;
}

/* "هذه الأداة خاصة ومقفلة" */
.login-footer {
  position: absolute;
  bottom: max(32px, env(safe-area-inset-bottom, 32px));
  font-size: 12px;
  color: rgba(255, 255, 255, 0.22);
  letter-spacing: 0.3px;
  animation: login-rise 0.4s 0.25s ease both;
}

/* ============================================================
   Sign-Out Button (in app header)
   ============================================================ */
#signout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;   /* pushes to the end (left) in RTL */
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

#signout-btn:hover {
  background: #fff0f0;
  border-color: var(--danger);
  color: var(--danger);
}

#signout-btn svg {
  flex-shrink: 0;
}

/* ============================================================
   Typography
   ============================================================ */
.section-heading {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: calc(var(--spacing) * 2);
}

.placeholder-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
}
