/*
==========================================================
SEA STAFF ATTENDANCE SYSTEM V2
Main stylesheet
==========================================================
*/


/* -------------------------------------------------------
   CSS VARIABLES
------------------------------------------------------- */

:root {
  --primary: #0b78c6;
  --primary-dark: #075d9b;
  --primary-light: #eaf5fd;

  --success: #178a4b;
  --success-light: #eaf8f0;

  --warning: #b56a00;
  --warning-light: #fff5df;

  --danger: #c93636;
  --danger-light: #fff0f0;

  --offline: #5c6670;
  --offline-light: #eef1f4;

  --background: #f3f6f9;
  --surface: #ffffff;

  --text-primary: #17212b;
  --text-secondary: #66717d;
  --text-muted: #8c96a0;

  --border: #dce3e8;
  --border-dark: #c8d1d8;

  --shadow:
    0 8px 24px rgba(20, 38, 54, 0.08);

  --shadow-small:
    0 3px 10px rgba(20, 38, 54, 0.07);

  --radius-large: 20px;
  --radius-medium: 14px;
  --radius-small: 9px;

  --header-height: 92px;

  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}


/* -------------------------------------------------------
   RESET
------------------------------------------------------- */

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(
      180deg,
      #eaf4fb 0,
      var(--background) 220px
    );
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

img,
video,
canvas {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}


/* -------------------------------------------------------
   APP LAYOUT
------------------------------------------------------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;

  padding:
    calc(14px + var(--safe-top))
    22px
    14px;

  min-height:
    calc(var(--header-height) + var(--safe-top));

  background:
    rgba(255, 255, 255, 0.95);

  border-bottom: 1px solid var(--border);

  box-shadow:
    0 3px 14px rgba(20, 38, 54, 0.05);

  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.logo-container {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 72px;
  height: 58px;

  border-radius: 11px;
  background: #ffffff;
  overflow: hidden;
}

.company-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  height: 100%;

  border-radius: 11px;

  background:
    linear-gradient(
      135deg,
      var(--primary),
      #36a5e8
    );

  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(17px, 2.2vw, 24px);
  line-height: 1.2;
  font-weight: 800;
  color: var(--text-primary);
}

.brand-text p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-status {
  flex: 0 0 auto;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 8px 11px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: #ffffff;

  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.status-online {
  background: var(--success);
  box-shadow:
    0 0 0 4px rgba(23, 138, 75, 0.12);
}

.status-offline {
  background: var(--danger);
  box-shadow:
    0 0 0 4px rgba(201, 54, 54, 0.12);
}

.app-main {
  flex: 1;
  width: 100%;
  padding: 28px 18px 36px;
}

.screen {
  display: none;
  width: 100%;
}

.active-screen {
  display: block;
  animation: screenFadeIn 220ms ease-out;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* -------------------------------------------------------
   CARDS
------------------------------------------------------- */

.card {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 32px);

  border: 1px solid rgba(220, 227, 232, 0.9);
  border-radius: var(--radius-large);

  background: var(--surface);
  box-shadow: var(--shadow);
}

.centered-card {
  max-width: 520px;
  text-align: center;
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 31px);
  line-height: 1.2;
}

.section-heading p {
  margin: 9px 0 0;
  color: var(--text-secondary);
  font-size: 15px;
}


/* -------------------------------------------------------
   TYPOGRAPHY
------------------------------------------------------- */

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h2 {
  color: var(--text-primary);
}

h3 {
  margin: 0;
  font-size: 16px;
}

.centered-card h2 {
  margin: 18px 0 8px;
}

.centered-card > p {
  margin: 0 auto 22px;
  max-width: 440px;
  color: var(--text-secondary);
}

.optional-text {
  margin-left: 5px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}


/* -------------------------------------------------------
   FORMS
------------------------------------------------------- */

.form-group {
  margin-bottom: 21px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;

  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  display: block;
  width: 100%;

  border: 1px solid var(--border-dark);
  border-radius: var(--radius-small);

  background: #ffffff;
  color: var(--text-primary);

  outline: none;

  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

input {
  min-height: 50px;
  padding: 11px 14px;
  font-size: 16px;
}

textarea {
  min-height: 92px;
  padding: 12px 14px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #9aa4ad;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(11, 120, 198, 0.12);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow:
    0 0 0 4px rgba(201, 54, 54, 0.1);
}

.field-error {
  margin: 7px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}


/* -------------------------------------------------------
   BUTTONS
------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 48px;
  padding: 11px 18px;

  border: 1px solid transparent;
  border-radius: var(--radius-small);

  cursor: pointer;

  font-size: 15px;
  font-weight: 750;
  text-align: center;
  text-decoration: none;

  transition:
    transform 120ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    opacity 150ms ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:focus-visible {
  outline: 3px solid rgba(11, 120, 198, 0.24);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.full-width {
  width: 100%;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow:
    0 5px 12px rgba(11, 120, 198, 0.2);
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.secondary-button {
  border-color: var(--border-dark);
  background: #ffffff;
  color: var(--text-primary);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.text-button {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
}

.text-button:hover:not(:disabled) {
  background: var(--primary-light);
}

.attendance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin: 22px 0 8px;
}

.attendance-button {
  min-height: 62px;
  font-size: 17px;
}

.check-in-button {
  background: var(--success);
  color: #ffffff;
  box-shadow:
    0 5px 12px rgba(23, 138, 75, 0.18);
}

.check-in-button:hover {
  background: #126f3c;
}

.check-out-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow:
    0 5px 12px rgba(11, 120, 198, 0.18);
}

.check-out-button:hover {
  background: var(--primary-dark);
}


/* -------------------------------------------------------
   LOADING SPINNER
------------------------------------------------------- */

.loading-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto;

  border: 5px solid #dfeaf2;
  border-top-color: var(--primary);
  border-radius: 50%;

  animation: spinnerRotation 780ms linear infinite;
}

@keyframes spinnerRotation {
  to {
    transform: rotate(360deg);
  }
}


/* -------------------------------------------------------
   EMPLOYEE PROFILE
------------------------------------------------------- */

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;

  margin-bottom: 24px;
}

.profile-avatar {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 66px;
  height: 66px;

  border-radius: 50%;

  background:
    linear-gradient(
      135deg,
      var(--primary),
      #40a8e4
    );

  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
}

.welcome-text {
  margin: 0 0 2px;
  color: var(--text-secondary);
  font-size: 13px;
}

.profile-header h2 {
  margin: 0;
  font-size: 23px;
}

.profile-header p:last-child {
  margin: 3px 0 0;
  color: var(--text-secondary);
}


/* -------------------------------------------------------
   INFORMATION ROWS
------------------------------------------------------- */

.employee-information,
.verification-details,
.result-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-medium);
  background: #fbfcfd;
  overflow: hidden;
}

.information-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;

  padding: 13px 15px;

  border-bottom: 1px solid var(--border);
}

.information-row:last-child {
  border-bottom: 0;
}

.information-row span {
  color: var(--text-secondary);
  font-size: 14px;
}

.information-row strong {
  max-width: 60%;
  color: var(--text-primary);
  font-size: 14px;
  text-align: right;
  overflow-wrap: anywhere;
}


/* -------------------------------------------------------
   NOTICES
------------------------------------------------------- */

.notice {
  margin-top: 18px;
  padding: 14px 15px;

  border-radius: var(--radius-small);
}

.notice strong {
  display: block;
  margin-bottom: 4px;
}

.notice p {
  margin: 0;
  font-size: 14px;
}

.warning-notice {
  border: 1px solid #eed49f;
  background: var(--warning-light);
  color: #794900;
}


/* -------------------------------------------------------
   VERIFICATION SECTIONS
------------------------------------------------------- */

.verification-section {
  margin-bottom: 22px;
  padding: 18px;

  border: 1px solid var(--border);
  border-radius: var(--radius-medium);

  background: #fcfdfe;
}

.verification-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;

  margin-bottom: 16px;
}

.verification-heading p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.verification-details {
  margin-bottom: 14px;
}

.status-badge {
  flex: 0 0 auto;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 28px;
  padding: 5px 10px;

  border-radius: 999px;

  font-size: 12px;
  font-weight: 750;
}

.neutral-badge {
  background: var(--offline-light);
  color: var(--offline);
}

.success-badge {
  background: var(--success-light);
  color: var(--success);
}

.warning-badge {
  background: var(--warning-light);
  color: var(--warning);
}

.error-badge {
  background: var(--danger-light);
  color: var(--danger);
}


/* -------------------------------------------------------
   CAMERA
------------------------------------------------------- */

.camera-container {
  position: relative;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 300px;

  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-medium);

  background: #111820;
  overflow: hidden;
}

.camera-preview,
.selfie-preview {
  display: block;
  width: 100%;
  max-height: 470px;
  object-fit: cover;
  aspect-ratio: 4 / 3;
}

.camera-preview {
  transform: scaleX(-1);
}

.selfie-preview {
  background: #111820;
}

.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  min-height: 280px;
  padding: 26px;

  color: #d7e0e8;
  text-align: center;
}

.camera-placeholder-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 76px;
  height: 76px;

  margin-bottom: 12px;

  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;

  font-size: 38px;
}

.camera-placeholder p {
  margin: 0;
  color: #c4ced7;
  font-size: 14px;
}

.camera-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;

  margin-top: 14px;
}


/* -------------------------------------------------------
   MESSAGE ICONS
------------------------------------------------------- */

.message-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 76px;
  height: 76px;

  margin: 0 auto;

  border-radius: 50%;

  font-size: 38px;
  font-weight: 850;
}

.success-icon {
  background: var(--success-light);
  color: var(--success);
}

.error-icon {
  background: var(--danger-light);
  color: var(--danger);
}

.offline-icon {
  background: var(--offline-light);
  color: var(--offline);
}


/* -------------------------------------------------------
   RESULTS
------------------------------------------------------- */

.result-details {
  width: 100%;
  margin: 18px 0 22px;
  text-align: left;
}


/* -------------------------------------------------------
   FOOTER
------------------------------------------------------- */

.app-footer {
  padding:
    18px
    22px
    calc(18px + var(--safe-bottom));

  border-top: 1px solid var(--border);

  background: rgba(255, 255, 255, 0.85);

  color: var(--text-secondary);
  text-align: center;
}

.footer-status {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 22px;

  font-size: 13px;
}

.footer-status strong {
  color: var(--text-primary);
}

.app-footer p {
  margin: 7px 0 0;
  font-size: 12px;
}


/* -------------------------------------------------------
   TOAST
------------------------------------------------------- */

.toast-message {
  position: fixed;
  left: 50%;
  bottom:
    calc(24px + var(--safe-bottom));
  z-index: 100;

  width: min(calc(100% - 32px), 460px);
  padding: 13px 16px;

  border-radius: var(--radius-small);

  background: #18232d;
  color: #ffffff;

  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.25);

  text-align: center;
  font-size: 14px;
  font-weight: 600;

  transform: translateX(-50%);

  animation: toastFadeIn 180ms ease-out;
}

@keyframes toastFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}


/* -------------------------------------------------------
   RESPONSIVE TABLET/DESKTOP
------------------------------------------------------- */

@media (min-width: 760px) {
  .app-main {
    padding-top: 38px;
    padding-bottom: 48px;
  }

  .card {
    padding: 34px;
  }

  .verification-section {
    padding: 21px;
  }
}


/* -------------------------------------------------------
   RESPONSIVE MOBILE
------------------------------------------------------- */

@media (max-width: 620px) {
  :root {
    --header-height: 82px;
  }

  .app-header {
    align-items: flex-start;
    padding-left: 15px;
    padding-right: 15px;
  }

  .logo-container {
    width: 57px;
    height: 48px;
  }

  .brand-section {
    gap: 10px;
    min-width: 0;
  }

  .brand-text h1 {
    font-size: 16px;
  }

  .brand-text p {
    max-width: 210px;
    font-size: 11px;
  }

  .header-status {
    padding: 7px 8px;
    font-size: 0;
  }

  .header-status .status-dot {
    margin: 0;
  }

  .app-main {
    padding: 18px 11px 28px;
  }

  .card {
    padding: 21px 17px;
    border-radius: 17px;
  }

  .attendance-actions {
    grid-template-columns: 1fr;
  }

  .verification-heading {
    flex-direction: column;
  }

  .status-badge {
    align-self: flex-start;
  }

  .information-row {
    gap: 12px;
  }

  .information-row strong {
    max-width: 58%;
  }

  .camera-container {
    min-height: 245px;
  }

  .camera-placeholder {
    min-height: 235px;
  }

  .camera-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .camera-buttons .button {
    width: 100%;
  }
}


/* -------------------------------------------------------
   VERY SMALL SCREENS
------------------------------------------------------- */

@media (max-width: 380px) {
  .brand-text p {
    max-width: 165px;
  }

  .profile-header {
    align-items: flex-start;
  }

  .profile-avatar {
    width: 56px;
    height: 56px;
  }

  .information-row {
    flex-direction: column;
    gap: 4px;
  }

  .information-row strong {
    max-width: 100%;
    text-align: left;
  }
}


/* -------------------------------------------------------
   ACCESSIBILITY
------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* -------------------------------------------------------
   DARK MODE
------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111820;
    --surface: #18222c;

    --text-primary: #f2f6f8;
    --text-secondary: #afbbc5;
    --text-muted: #8e9aa4;

    --border: #2e3a45;
    --border-dark: #3b4854;

    --primary-light: #15354c;
    --success-light: #173a2a;
    --warning-light: #43351e;
    --danger-light: #442426;
    --offline-light: #28323b;

    --shadow:
      0 8px 26px rgba(0, 0, 0, 0.28);
  }

  body {
    background:
      linear-gradient(
        180deg,
        #11283a 0,
        var(--background) 220px
      );
  }

  .app-header,
  .app-footer {
    background:
      rgba(24, 34, 44, 0.94);
  }

  .logo-container,
  .header-status,
  input,
  textarea,
  .secondary-button {
    background: #202b35;
  }

  input,
  textarea {
    color: var(--text-primary);
  }

  input::placeholder,
  textarea::placeholder {
    color: #75828d;
  }

  .employee-information,
  .verification-details,
  .result-details,
  .verification-section {
    background: #1b2630;
  }

  .secondary-button {
    color: var(--text-primary);
  }

  .secondary-button:hover:not(:disabled),
  .text-button:hover:not(:disabled) {
    background: var(--primary-light);
  }

  .camera-container {
    background: #080d12;
  }

  .toast-message {
    background: #edf2f5;
    color: #18232d;
  }
}