/* ==========================================================================
   MOBILE-FIRST GLOBAL RESET & ENHANCEMENTS
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  background-color: var(--bg-dark);
  font-size: 16px;
  font-optical-sizing: auto;
  height: 100%;
}

body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
  width: 100%;
  padding-top: 60px; /* Space for fixed header */
}

/* Fix for iOS viewport height issues */
@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
}

/* ==========================================================================
   ENHANCED THEME VARIABLES WITH GRADIENTS & DEPTH
   ========================================================================== */
:root {
  --bg-dark: #0a0a0a;
  --bg-darker: #000000;
  --bg-card: #1e1e1e;
  --accent: #ff0038;
  --accent-hover: #ff1a4d;
  --accent-glow: rgba(255, 0, 56, 0.4);
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --error: #ff0038;
  --success: #4bb543;
  --warning: #f8961e;
  --info: #43aa8b;
  --border: #333;
  --glow: 0 0 20px rgba(255, 0, 56, 0.3);
  --glow-strong: 0 0 30px rgba(255, 0, 56, 0.5);
  --font-heading: 'Montserrat', sans-serif;
  --font-body: 'Inter', sans-serif;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);
  
  /* Enhanced Gradients */
  --gradient-primary: linear-gradient(135deg, #ff0038 0%, #ff1a4d 100%);
  --gradient-dark: linear-gradient(135deg, #0a0a0a 0%, #000000 100%);
  --gradient-card: linear-gradient(145deg, #1e1e1e 0%, #252525 100%);
  --gradient-glow: radial-gradient(circle at center, rgba(255, 0, 56, 0.15) 0%, transparent 70%);
  
  /* Glass Morphism */
  --glass-bg: rgba(30, 30, 30, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  
  /* Animations */
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ==========================================================================
   HR MODULE THEME EXTENSION
   ========================================================================== */
.module-hr {
  --hr-accent: #00c4ff;
  --hr-accent-hover: #33d6ff;
  --hr-accent-glow: rgba(0, 196, 255, 0.4);
  --hr-gradient-primary: linear-gradient(135deg, #00c4ff 0%, #33d6ff 100%);
  --hr-glass-bg: rgba(20, 30, 40, 0.7);
  --hr-glass-border: rgba(255, 255, 255, 0.08);
  --hr-avatar-shadow: 0 0 15px rgba(0, 196, 255, 0.3);
  --hr-success: #2ecc71;
  --hr-warning: #f39c12;
  --hr-error: #e74c3c;
}

/* ==========================================================================
   ENHANCED LIGHT THEME
   ========================================================================== */
:root[data-theme="light"] {
  --bg-dark: #fdfdfd;
  --bg-darker: #f5f5f5;
  --bg-card: #ffffff;
  --text-primary: #111111;
  --text-secondary: #444444;
  --border: #ddd;
  --glow: 0 0 20px rgba(255, 0, 56, 0.15);
  --gradient-card: linear-gradient(145deg, #ffffff 0%, #f8f8f8 100%);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   ENHANCED BASE STYLES WITH MODERN EFFECTS
   ========================================================================== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 0, 56, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255, 0, 56, 0.05) 0%, transparent 50%),
    linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
  z-index: -2;
  pointer-events: none;
  animation: backgroundShift 20s ease-in-out infinite alternate;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.03) 1px, transparent 0);
  background-size: 40px 40px;
  z-index: -1;
  pointer-events: none;
}

@keyframes backgroundShift {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.1) rotate(1deg); }
}

/* ==========================================================================
   MOBILE-FIRST PREMIUM CONTAINERS
   ========================================================================== */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 1rem;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--ease-smooth);
}

.container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-glow);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  pointer-events: none;
}

.container:active {
  transform: translateY(-1px);
  border-color: rgba(255, 0, 56, 0.3);
}

.container:active::before {
  opacity: 0.5;
}

.container::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent,
    rgba(255, 0, 56, 0.05),
    rgba(255, 0, 56, 0.025),
    transparent,
    transparent
  );
  animation: conicRotate 20s linear infinite;
  z-index: -1;
  opacity: 0.3;
  pointer-events: none;
}

@keyframes conicRotate {
  0% { transform: rotate(0deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1.2); }
}

/* ==========================================================================
   MOBILE-FIRST PREMIUM HEADINGS
   ========================================================================== */
h1 {
  text-align: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.75rem;
  margin: 0 0 1.5rem;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  position: relative;
  display: block;
  width: 100%;
  line-height: 1.2;
}

h1::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: 2px;
  animation: linePulse 3s ease-in-out infinite;
}

@keyframes linePulse {
  0%, 100% { width: 50px; opacity: 1; }
  50% { width: 70px; opacity: 0.8; }
}

/* ==========================================================================
   MOBILE-FIRST PREMIUM FLASHES & ALERTS
   ========================================================================== */
.flash {
  width: 100%;
  background: linear-gradient(135deg, rgba(75, 181, 67, 0.15) 0%, rgba(75, 181, 67, 0.05) 100%);
  color: var(--text-primary);
  padding: 0.875rem 1rem;
  text-align: center;
  margin: 0 0 1rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  border-left: 3px solid var(--success);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  animation: slideInDown 0.4s var(--ease-bounce);
}

.flash::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--success);
  animation: progressBar 3s ease-in-out;
}

@keyframes slideInDown {
  0% { 
    opacity: 0; 
    transform: translateY(-10px);
  }
  100% { 
    opacity: 1; 
    transform: translateY(0);
  }
}

@keyframes progressBar {
  0% { width: 0%; }
  100% { width: 100%; }
}

/* ==========================================================================
   MOBILE-FIRST FORM CONTROLS
   ========================================================================== */
form.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0 0 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1.25rem;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
  width: 100%;
}

input[type="file"],
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 16px; /* Prevents zoom on iOS */
  font-family: var(--font-body);
  transition: all 0.2s var(--ease-smooth);
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.4;
}

input[type="file"] {
  padding: 0.5rem;
}

input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  background: var(--gradient-primary);
  color: #000;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-right: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="file"]::file-selector-button:active,
input[type="file"]::-webkit-file-upload-button:active {
  transform: translateY(0);
  box-shadow: var(--glow);
}

input[type="text"]:active,
input[type="email"]:active,
input[type="number"]:active,
input[type="date"]:active,
textarea:active,
select:active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 0, 56, 0.1);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 0, 56, 0.15);
}

/* ==========================================================================
   MOBILE-FIRST SELECT STYLES
   ========================================================================== */
select {
  padding: 0.875rem 2.5rem 0.875rem 1rem;
  background: var(--bg-darker) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23ff0038' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") no-repeat right 0.75rem center / 1.25em 1.25em;
  cursor: pointer;
}

/* ==========================================================================
   MOBILE-FIRST PREMIUM BUTTONS
   ========================================================================== */
button.save-btn,
button.delete-selected-btn,
button[type="submit"] {
  width: 100%;
  background: var(--gradient-primary);
  color: #000;
  border: none;
  padding: 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(255, 0, 56, 0.3);
  -webkit-appearance: none;
  appearance: none;
}

button.save-btn::before,
button.delete-selected-btn::before,
button[type="submit"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.4s;
}

button.save-btn:active::before,
button.delete-selected-btn:active::before,
button[type="submit"]:active::before {
  left: 100%;
}

button.save-btn:active,
button.delete-selected-btn:active,
button[type="submit"]:active {
  transform: translateY(1px);
  box-shadow: 0 1px 5px rgba(255, 0, 56, 0.4);
}

/* ==========================================================================
   MOBILE-FIRST PREMIUM TABLE STYLES
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: 12px;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  min-width: 600px; /* Forces scroll on mobile for wide tables */
}

table::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gradient-primary);
  z-index: 1;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  white-space: nowrap;
}

th {
  background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-card) 100%);
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 2;
}

tr:active {
  background: rgba(255, 0, 56, 0.05);
}

/* ==========================================================================
   HR MODULE COMPONENTS
   ========================================================================== */

/* Employee Cards */
.module-hr .employee-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--hr-glass-border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--glass-shadow);
  transition: all 0.2s var(--ease-smooth);
  text-align: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  width: 100%;
}

.module-hr .employee-card:active {
  transform: translateY(-2px);
  border-color: var(--hr-accent);
  box-shadow: 0 0 15px var(--hr-accent-glow);
}

/* Avatar / Photo */
.module-hr .employee-card img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 0 1rem;
  border: 2px solid var(--hr-accent);
  box-shadow: var(--hr-avatar-shadow);
}

/* Employee Name */
.module-hr .employee-card h3 {
  font-family: var(--font-heading);
  color: var(--hr-accent);
  font-size: 1.1rem;
  margin: 0 0 0.25rem;
  line-height: 1.3;
}

/* Job Title */
.module-hr .employee-card p.position {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

/* Contact / Status Badges */
.module-hr .badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--hr-gradient-primary);
  color: #000;
  box-shadow: 0 2px 8px var(--hr-accent-glow);
}

/* Form Panels */
.module-hr form {
  background: var(--hr-glass-bg);
  border: 1px solid var(--hr-glass-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0 0;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.module-hr label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: block;
  margin: 0 0 0.25rem;
}

.module-hr .hst-btn {
  background: var(--hr-gradient-primary);
  color: #000;
  width: 100%;
  padding: 0.875rem;
  border-radius: 10px;
  font-weight: 600;
  border: none;
  box-shadow: 0 2px 10px var(--hr-accent-glow);
}

.module-hr .hst-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 5px var(--hr-accent-glow);
}

/* ==========================================================================
   HR GRID / DASHBOARD LAYOUTS
   ========================================================================== */

.module-hr .employee-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin: 1rem 0 0;
}

@media (min-width: 480px) {
  .module-hr .employee-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .module-hr .employee-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==========================================================================
   ENHANCED CYBERPUNK CORNERS
   ========================================================================== */
.corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border-style: solid;
  border-color: var(--accent);
  border-width: 0;
  opacity: 0.4;
  transition: all 0.2s ease;
  pointer-events: none;
}

.corner-tl { 
  top: 0; 
  left: 0; 
  border-top-width: 2px; 
  border-left-width: 2px; 
  border-radius: 6px 0 0 0;
}

.corner-tr { 
  top: 0; 
  right: 0; 
  border-top-width: 2px; 
  border-right-width: 2px; 
  border-radius: 0 6px 0 0;
}

.corner-bl { 
  bottom: 0; 
  left: 0; 
  border-bottom-width: 2px; 
  border-left-width: 2px; 
  border-radius: 0 0 0 6px;
}

.corner-br { 
  bottom: 0; 
  right: 0; 
  border-bottom-width: 2px; 
  border-right-width: 2px; 
  border-radius: 0 0 6px 0;
}

.container:active .corner {
  opacity: 1;
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   PREMIUM HIGHLIGHT EFFECTS
   ========================================================================== */
.highlight-flash {
  position: relative;
  animation: premiumPulse 2s var(--ease-smooth) infinite;
  border: 2px solid var(--accent);
  border-radius: 8px;
  z-index: 5;
  background: rgba(255, 0, 56, 0.05);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

@keyframes premiumPulse {
  0%, 100% { 
    border-color: rgba(255, 0, 56, 0.4);
    box-shadow: 0 0 8px rgba(255, 0, 56, 0.2);
  }
  50% { 
    border-color: rgba(255, 0, 56, 0.8);
    box-shadow: 0 0 15px rgba(255, 0, 56, 0.5);
  }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 8px var(--hr-accent-glow); }
  50% { box-shadow: 0 0 15px var(--hr-accent-glow); }
}

.module-hr .employee-card:active img {
  animation: glowPulse 1s infinite ease-in-out;
}

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (min-width: 480px) {
  .container { 
    padding: 1.25rem; 
    border-radius: 14px;
  }
  
  h1 { 
    font-size: 2rem; 
    margin-bottom: 1.75rem; 
  }
  
  button.save-btn,
  button.delete-selected-btn,
  button[type="submit"] {
    width: auto;
    min-width: 160px;
    padding: 1rem 2rem;
  }
}

@media (min-width: 768px) {
  .container { 
    max-width: 720px;
    margin: 1rem auto; 
    padding: 1.5rem;
    border-radius: 16px;
  }
  
  h1 { 
    font-size: 2.25rem; 
  }
  
  form.upload-form {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  
  .flash {
    max-width: 720px;
    margin: 0 auto 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container { 
    max-width: 960px;
    padding: 2rem;
    border-radius: 20px;
  }
  
  h1 { 
    font-size: 2.5rem; 
  }
  
  /* Desktop hover effects only */
  @media (hover: hover) {
    .container:hover {
      transform: translateY(-2px);
      border-color: rgba(255, 0, 56, 0.3);
    }
    
    .container:hover .corner {
      opacity: 1;
      width: 16px;
      height: 16px;
    }
    
    button.save-btn:hover,
    button.delete-selected-btn:hover,
    button[type="submit"]:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 15px rgba(255, 0, 56, 0.4);
    }
  }
}

@media (min-width: 1200px) {
  .container { 
    max-width: 1140px;
  }
}

/* ==========================================================================
   FIX FOR STICKY HEADER OVERLAP
   ========================================================================== */
body {
  padding-top: 60px;
}

/* Offset for anchor links */
:target {
  scroll-margin-top: 70px;
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #fff;
    --glass-border: #fff;
  }
  
  .corner {
    opacity: 1;
    border-width: 2px;
  }
}

/* Touch optimization */
@media (hover: none) and (pointer: coarse) {
  button.save-btn,
  button.delete-selected-btn,
  button[type="submit"],
  .container,
  select,
  input[type="file"]::file-selector-button {
    cursor: default;
  }
  
  /* Larger tap targets */
  button.save-btn,
  button.delete-selected-btn,
  button[type="submit"] {
    min-height: 48px;
  }
  
  select,
  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"] {
    min-height: 48px;
  }
}