/* ============================================
   SAFEWORK PTW - MAIN CSS
   Design System & Core Styles
   ============================================ */

:root {
  /* Brand Color Palette */
  --brand-primary: #456DB3;
  /* Deep Blue */
  --brand-primary-dark: #375994;
  --brand-secondary: #D4B995;
  /* Earth Gold */
  --brand-accent: #E63946;
  /* Safety Red (kept for alerts) */

  --brand-gradient: linear-gradient(135deg, #456DB3 0%, #304e82 100%);
  --brand-gradient-light: linear-gradient(135deg, #5b84ce 0%, #456DB3 100%);

  /* Safety Colors (Adjusted for Light Theme) */
  --danger: #D32F2F;
  --danger-dark: #B71C1C;
  --danger-light: #FFEBEE;
  --danger-bg: #FEF2F2;

  --warning: #ED6C02;
  --warning-dark: #E65100;
  --warning-light: #FFF3E0;
  --warning-bg: #FFF7ED;

  --success: #2E7D32;
  --success-dark: #1B5E20;
  --success-light: #E8F5E9;
  --success-bg: #F0FDF4;

  --info: #0288D1;
  --info-dark: #01579B;
  --info-light: #E1F5FE;
  --info-bg: #F0F9FF;

  --purple: #7B1FA2;
  --purple-light: #F3E5F5;

  /* Neutral Palette (Gray -> Warm Gray) */
  --gray-50: #FAFAF9;
  --gray-100: #F5F5F4;
  --gray-200: #E7E5E4;
  --gray-300: #D6D3D1;
  --gray-400: #A8A29E;
  --gray-500: #78716C;
  --gray-600: #57534E;
  --gray-700: #44403C;
  --gray-800: #292524;
  --gray-900: #1C1917;

  /* Backgrounds */
  --bg-app: #EDF1F8;
  /* Light Gray Blue */
  --bg-surface: #FFFFFF;
  /* White */
  --bg-elevated: #FFFFFF;
  /* White */
  --bg-card: #FFFFFF;
  /* White */
  --bg-input: #FFFFFF;
  /* White */
  --bg-hover: #F5F5F4;
  /* Warm Gray 100 */

  /* Text */
  --text-primary: #1C1917;
  /* Warm Gray 900 */
  --text-secondary: #57534E;
  /* Warm Gray 600 */
  --text-muted: #A8A29E;
  /* Warm Gray 400 */
  --text-inverse: #FFFFFF;
  /* White */
  --text-on-brand: #FFFFFF;
  /* White */

  /* Borders */
  --border: #E7E5E4;
  /* Warm Gray 200 */
  --border-strong: #D6D3D1;
  /* Warm Gray 300 */
  --border-focus: #456DB3;
  /* Deep Blue */

  /* Shadows (Subtler for Light Theme) */
  --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-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-brand: 0 4px 14px rgba(69, 109, 179, 0.25);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --nav-height: 60px;
  --bottom-nav-height: 72px;
  --max-width: 480px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--bg-app);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
}

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

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

/* ============================================
   SPLASH SCREEN
   ============================================ */
.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-8);
}

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.logo-icon {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 8px 24px rgba(230, 57, 70, 0.5));
  animation: pulse-logo 2s ease-in-out infinite;
}

@keyframes pulse-logo {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

.splash-text h1 {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.splash-text p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-top: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.splash-loader {
  width: 200px;
  height: 3px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
  animation: loading 1.8s ease-in-out forwards;
}

@keyframes loading {
  0% {
    width: 0%;
  }

  60% {
    width: 80%;
  }

  100% {
    width: 100%;
  }
}

.splash-version {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ============================================
   MAIN APP LAYOUT
   ============================================ */
.main-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  background: var(--bg-app);
}

.main-app.hidden {
  display: none;
}

/* ============================================
   TOP NAVIGATION
   ============================================ */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.nav-logo span {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text-primary);
}

.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-btn:hover,
.nav-btn:active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-btn svg {
  width: 20px;
  height: 20px;
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   USER MENU
   ============================================ */
.user-menu {
  position: fixed;
  top: calc(var(--nav-height) + 8px);
  right: 12px;
  width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu.hidden {
  display: none;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
}

.avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.user-role {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.menu-divider {
  border: none;
  border-top: 1px solid var(--border);
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  text-align: left;
}

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

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: var(--danger-bg);
}

.menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================
   PAGE CONTAINER
   ============================================ */
.page-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--bottom-nav-height);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--bottom-nav-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-2);
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: all var(--transition-fast);
  min-width: 52px;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-item.active {
  color: var(--brand-primary);
}

.bottom-nav-item:hover {
  color: var(--text-secondary);
}

.bottom-nav-item.create-btn {
  color: white;
}

.create-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-brand);
  transition: transform var(--transition-fast);
  margin-top: -20px;
}

.create-icon svg {
  width: 24px;
  height: 24px;
}

.bottom-nav-item.create-btn:active .create-icon {
  transform: scale(0.92);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

.w-full {
  width: 100%;
}

.text-center {
  text-align: center;
}

.font-bold {
  font-weight: 700;
}

.font-semibold {
  font-weight: 600;
}

.text-sm {
  font-size: var(--font-size-sm);
}

.text-xs {
  font-size: var(--font-size-xs);
}

.text-muted {
  color: var(--text-secondary);
}

.mt-2 {
  margin-top: var(--space-2);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mb-4 {
  margin-bottom: var(--space-4);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: calc(var(--max-width) - 32px);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  pointer-events: all;
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.error {
  background: var(--danger);
  color: white;
}

.toast.warning {
  background: var(--warning);
  color: white;
}

.toast.info {
  background: var(--info);
  color: white;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast.fade-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-700);
  border-radius: 2px;
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-sheet {
  width: 100%;
  max-width: var(--max-width);
  background: var(--bg-elevated);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  padding: var(--space-6);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  animation: slideUp 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-600);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-5);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */
.page {
  animation: pageIn 0.25s ease;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   BACK BUTTON
   ============================================ */
.back-btn {
  color: var(--text-secondary);
}

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