/* CSS Variables */
:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary-color: #4f46e5;

  --success-color: #15803d;
  --warning-color: #d97706;
  --danger-color: #dc2626;

  --body-color: #eef3fb;
  --surface-color: #ffffff;
  --surface-muted: #f8fafc;

  --text-color: #0f172a;
  --muted-color: #64748b;
  --border-color: #dce5f1;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 30px;

  --shadow-sm: 0 10px 28px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 20px 55px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 28px 70px rgba(15, 23, 42, 0.18);

  --focus-ring: 0 0 0 4px rgba(37, 99, 235, 0.14);
  --transition: 0.25s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.6;
  background:
    radial-gradient(
      circle at 8% 4%,
      rgba(37, 99, 235, 0.16),
      transparent 27rem
    ),
    radial-gradient(
      circle at 93% 12%,
      rgba(79, 70, 229, 0.12),
      transparent 25rem
    ),
    linear-gradient(180deg, #f8fbff 0%, var(--body-color) 48%, #edf2fa 100%);
  color: var(--text-color);
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

select {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* Layout */
.app {
  width: min(1200px, calc(100% - 32px));
  margin-inline: auto;
  padding-block: 48px 70px;
}

/* Header */
.app-header {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  min-height: 300px;
  margin-bottom: 34px;
  padding: clamp(32px, 5vw, 58px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-xl);
  background: linear-gradient(
    130deg,
    rgba(15, 23, 42, 0.98) 0%,
    rgba(30, 58, 138, 0.97) 52%,
    rgba(67, 56, 202, 0.95) 100%
  );
  color: #ffffff;
  box-shadow: var(--shadow-lg);
}

.app-header::before,
.app-header::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}

.app-header::before {
  top: -120px;
  right: -70px;
  width: 310px;
  height: 310px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background-color: rgba(255, 255, 255, 0.06);
}

.app-header::after {
  bottom: -170px;
  left: 38%;
  width: 360px;
  height: 360px;
  background: radial-gradient(
    circle,
    rgba(96, 165, 250, 0.24),
    transparent 67%
  );
}

.header-copy {
  max-width: 710px;
  animation: header-copy-enter 0.72s cubic-bezier(0.22, 1, 0.36, 1);
}

.app-header .eyebrow {
  margin-bottom: 14px;
  color: #bfdbfe;
}

.app-header h1 {
  max-width: 700px;
  margin-bottom: 18px;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1.04;
  letter-spacing: -1.7px;
}

.app-header p {
  max-width: 620px;
  color: #dbeafe;
  font-size: clamp(16px, 2vw, 18px);
}

.eyebrow,
.section-label {
  display: inline-block;
  color: var(--primary-color);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.eyebrow {
  margin-bottom: 10px;
}

.add-application-btn {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 52px;
  padding: 14px 23px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background-color: #ffffff;
  color: var(--primary-dark);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.22);
  animation: header-button-enter 0.72s 0.08s cubic-bezier(0.22, 1, 0.36, 1);
  transition:
    color var(--transition),
    background-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.add-application-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -135%;
  width: 80%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(37, 99, 235, 0.13),
    transparent
  );
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.add-application-btn:hover {
  color: #ffffff;
  background-color: var(--primary-color);
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.28);
}

.add-application-btn:hover::before {
  left: 145%;
}

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

.add-application-btn span {
  font-size: 20px;
  line-height: 1;
}

/* Statistics */
.statistics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 34px;
}

.stat-card {
  --card-accent: var(--primary-color);
  --card-accent-soft: #dbeafe;

  position: relative;
  min-height: 150px;
  padding: 27px;
  overflow: hidden;
  border: 1px solid rgba(220, 229, 241, 0.9);
  border-radius: var(--radius-lg);
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.99),
    rgba(248, 250, 252, 0.96)
  );
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background-color: var(--card-accent);
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -40px;
  width: 125px;
  height: 125px;
  border-radius: 50%;
  background-color: var(--card-accent-soft);
  opacity: 0.58;
}

.stat-card:hover,
.stat-card.reveal-ready.is-visible:hover {
  border-color: color-mix(in srgb, var(--card-accent) 25%, var(--border-color));
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}

.stat-card-total {
  --card-accent: #2563eb;
  --card-accent-soft: #dbeafe;
}

.stat-card-pending {
  --card-accent: #d97706;
  --card-accent-soft: #fef3c7;
}

.stat-card-interview {
  --card-accent: #7c3aed;
  --card-accent-soft: #ede9fe;
}

.stat-card-rejected {
  --card-accent: #dc2626;
  --card-accent-soft: #fee2e2;
}

.stat-card span,
.stat-card strong {
  position: relative;
  z-index: 1;
}

.stat-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted-color);
  font-size: 14px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  font-size: clamp(34px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -1px;
}

/* Applications Section*/
.applications-section {
  width: 100%;
  min-width: 0;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(220, 229, 241, 0.95);
  border-radius: var(--radius-lg);
  background-color: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-label {
  margin-bottom: 7px;
}

.section-header h2 {
  margin-bottom: 6px;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.section-header p {
  color: var(--muted-color);
}

/* Buttons */
.delete-all-btn,
#resetFiltersBtn,
.primary-btn,
.secondary-btn {
  min-height: 46px;
  padding: 11px 17px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.delete-all-btn {
  flex-shrink: 0;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background-color: rgba(220, 38, 38, 0.07);
  color: var(--danger-color);
  transition:
    border-color var(--transition),
    color var(--transition),
    background-color var(--transition),
    transform var(--transition);
}

.delete-all-btn:hover {
  border-color: var(--danger-color);
  background-color: var(--danger-color);
  color: #ffffff;
  transform: translateY(-2px);
}

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

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 310px) auto;
  gap: 14px;
  margin-bottom: 28px;
  padding: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--surface-muted);
}

.toolbar input,
.toolbar select {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 13px 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  background-color: var(--surface-color);
  color: var(--text-color);
}

.toolbar input {
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.toolbar select {
  transition: border-color 0.15s ease;
}

.toolbar input::placeholder,
.form-group input::placeholder {
  color: #94a3b8;
}

.toolbar input:focus,
.toolbar select:focus,
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: var(--focus-ring);
}

#resetFiltersBtn {
  border: 1px solid #cbd5e1;
  background-color: var(--surface-color);
  color: #334155;
  white-space: nowrap;
  transition:
    border-color var(--transition),
    color var(--transition),
    background-color var(--transition),
    transform var(--transition);
}

#resetFiltersBtn:hover {
  border-color: #94a3b8;
  background-color: #eaf0f7;
  color: var(--text-color);
}

#resetFiltersBtn:active {
  transform: scale(0.97);
}

/* Application Form */
.application-form {
  margin-bottom: 30px;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid #d7e2f0;
  border-radius: var(--radius-md);
  background: linear-gradient(
    145deg,
    rgba(239, 246, 255, 0.9),
    rgba(248, 250, 252, 0.96)
  );
}

.application-form:not([hidden]) {
  animation: form-enter 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: top center;
}

.form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.form-header .eyebrow {
  margin-bottom: 5px;
  font-size: 12px;
}

.form-header h2 {
  font-size: clamp(23px, 3vw, 29px);
  line-height: 1.25;
}

.close-form-btn {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background-color: #e2e8f0;
  color: var(--text-color);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--transition),
    background-color var(--transition),
    transform var(--transition);
}

.close-form-btn:hover {
  background-color: var(--danger-color);
  color: #ffffff;
  transform: rotate(90deg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.form-group label {
  font-size: 14px;
  font-weight: 800;
}

.form-group input,
.form-group select {
  width: 100%;
  min-width: 0;
  min-height: 49px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  background-color: var(--surface-color);
  color: var(--text-color);
}

.form-group input {
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.form-group select {
  transition: border-color 0.15s ease;
}

.form-action {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.primary-btn,
.secondary-btn {
  transition:
    border-color var(--transition),
    color var(--transition),
    background-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

.primary-btn {
  border: 1px solid var(--primary-color);
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.2);
}

.primary-btn:hover {
  border-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.26);
}

.secondary-btn {
  border: 1px solid var(--border-color);
  background-color: var(--surface-color);
  color: var(--text-color);
}

.secondary-btn:hover {
  border-color: #cbd5e1;
  background-color: #e8eef6;
}

/* Table */
.table-wrapper {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 18px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  vertical-align: middle;
}

th {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--muted-color);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

td:first-child {
  font-weight: 800;
}

.application-row {
  animation: row-enter 0.32s ease both;
  animation-delay: var(--row-delay, 0ms);
  transition: background-color var(--transition);
}

.application-row:hover {
  background-color: #f7faff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.actions-cell {
  white-space: nowrap;
}

.action-btn {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color var(--transition),
    color var(--transition),
    background-color var(--transition),
    transform var(--transition);
}

.action-btn + .action-btn {
  margin-left: 6px;
}

.action-btn:hover {
  transform: translateY(-1px);
}

.edit-btn {
  border-color: rgba(37, 99, 235, 0.24);
  background-color: rgba(37, 99, 235, 0.09);
  color: var(--primary-color);
}

.edit-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
  color: #ffffff;
}

.delete-btn {
  border-color: rgba(220, 38, 38, 0.24);
  background-color: rgba(220, 38, 38, 0.07);
  color: var(--danger-color);
}

.delete-btn:hover {
  border-color: var(--danger-color);
  background-color: var(--danger-color);
  color: #ffffff;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 27px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.status-saved {
  background-color: #f1f5f9;
  color: #475569;
}

.status-applied {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.status-review {
  background-color: #fef3c7;
  color: #92400e;
}

.status-interview {
  background-color: #ede9fe;
  color: #6d28d9;
}

.status-offer {
  background-color: #dcfce7;
  color: #15803d;
}

.status-rejected {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Empty State and Notification */
.empty-message {
  padding: 68px 20px;
  color: var(--muted-color);
  text-align: center;
}

.notification {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  width: min(370px, calc(100% - 32px));
  padding: 15px 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 13px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-13px);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.24);
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease,
    transform 0.25s ease;
}

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

.notification.error {
  background-color: #b91c1c;
}

.notification.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Reveal Animations */
.reveal.reveal-ready {
  opacity: 0;
  transition:
    opacity 0.68s ease var(--reveal-delay, 0ms),
    transform 0.68s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.reveal-up.reveal-ready {
  transform: translateY(30px);
}

.reveal.reveal-ready.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Keyboard Focus */
button:focus-visible,
.table-wrapper:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 3px;
}

/* Animations */
@keyframes header-copy-enter {
  from {
    opacity: 0;
    transform: translateX(-32px);
  }

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

@keyframes header-button-enter {
  from {
    opacity: 0;
    transform: translateX(32px);
  }

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

@keyframes form-enter {
  from {
    opacity: 0;
    transform: translateY(-14px) scaleY(0.98);
  }

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

@keyframes row-enter {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

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

/* Responsive Design */
@media (max-width: 960px) {
  .app-header {
    min-height: 280px;
  }

  .statistics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 270px);
  }

  #resetFiltersBtn {
    justify-self: start;
  }
}

@media (max-width: 760px) {
  .app {
    padding-block: 28px 46px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    min-height: auto;
    padding: 34px 26px;
  }

  .app-header h1 {
    font-size: clamp(38px, 12vw, 54px);
  }

  .add-application-btn {
    width: 100%;
  }

  .statistics {
    margin-bottom: 28px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .applications-section {
    padding: 21px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  #resetFiltersBtn {
    justify-self: stretch;
  }

  .application-form {
    padding: 21px;
  }

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

  .form-action {
    flex-direction: column-reverse;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .app {
    width: min(100% - 20px, 1200px);
    padding-block: 18px 34px;
  }

  .app-header {
    gap: 26px;
    margin-bottom: 24px;
    padding: 30px 21px;
    border-radius: 22px;
  }

  .app-header h1 {
    font-size: 39px;
    letter-spacing: -1px;
  }

  .statistics {
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 24px;
  }

  .stat-card {
    min-height: 135px;
    padding: 23px;
  }

  .applications-section {
    padding: 17px;
    border-radius: 20px;
  }

  .section-header {
    margin-bottom: 22px;
  }

  .delete-all-btn {
    width: 100%;
  }

  .toolbar {
    padding: 11px;
  }

  .application-form {
    padding: 17px;
  }

  th,
  td {
    padding: 16px;
  }

  .notification {
    top: 14px;
    right: 10px;
    width: calc(100% - 20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .reveal.reveal-ready {
    opacity: 1;
    transform: none;
  }
}
