/* Material Design 3 Custom Styles - Blue Theme */
:root {
  /* MDC Theme Overrides */
  --mdc-theme-primary: #1976D2;
  --mdc-theme-secondary: #1976D2;
  --mdc-theme-on-primary: #ffffff;
  --mdc-theme-on-secondary: #ffffff;

  /* Blue Color Palette */
  --md-sys-color-primary: #1976D2;
  --md-sys-color-primary-light: #42A5F5;
  --md-sys-color-primary-dark: #1565C0;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #BBDEFB;
  --md-sys-color-on-primary-container: #0D47A1;
  --md-sys-color-secondary: #455A64;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #CFD8DC;
  --md-sys-color-on-secondary-container: #263238;
  --md-sys-color-tertiary: #0277BD;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #B3E5FC;
  --md-sys-color-on-tertiary-container: #01579B;
  --md-sys-color-error: #D32F2F;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #FFCDD2;
  --md-sys-color-on-error-container: #B71C1C;
  --md-sys-color-background: #FAFAFA;
  --md-sys-color-on-background: #212121;
  --md-sys-color-surface: #ffffff;
  --md-sys-color-on-surface: #212121;
  --md-sys-color-surface-variant: #ECEFF1;
  --md-sys-color-on-surface-variant: #546E7A;
  --md-sys-color-outline: #90A4AE;
  --md-sys-color-outline-variant: #B0BEC5;
  --md-sys-color-shadow: #000000;
  --md-sys-color-surface-tint: #1976D2;

  /* Token Box Specific Variables */
  --token-box-size: 52px;
  --token-box-gap: 12px;
  --token-box-radius: 12px;
  --token-box-border-default: #B0BEC5;
  --token-box-border-focus: #1976D2;
  --token-box-bg-default: #ffffff;
  --token-box-bg-filled: #E3F2FD;
  --token-box-shadow-focus: 0 0 0 3px rgba(25, 118, 210, 0.2);
  --token-success-color: #4CAF50;
  --token-success-bg: #E8F5E9;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  line-height: 1.5;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   Header Styles
   ======================================== */
.mdc-top-app-bar {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.mdc-top-app-bar__title {
  font-weight: 500;
  font-size: 22px;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
  flex: 1;
  padding: 24px;
  padding-top: 88px; /* 64px (top app bar) + 24px (spacing) */
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.content-section {
  margin-bottom: 24px;
}

/* ========================================
   Card Styles
   ======================================== */
.mdc-card {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mdc-card:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
}

.card-content {
  padding: 24px;
}

/* Token Input Card with Background Decoration */
.token-card {
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #ffffff 0%, #E3F2FD 100%);
}

.token-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(25, 118, 210, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.token-card::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -30%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(25, 118, 210, 0.05) 0%, transparent 60%);
  pointer-events: none;
}

.token-card .card-content {
  position: relative;
  z-index: 1;
}

/* ========================================
   Token Box Styles
   ======================================== */
.token-boxes-wrapper {
  text-align: center;
  margin-bottom: 32px;
}

.token-input-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin: 0 0 8px 0;
}

.token-input-description {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 20px 0;
}

.token-boxes-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  position: relative;
}

.token-boxes {
  display: flex;
  gap: var(--token-box-gap);
  justify-content: center;
}

.token-box {
  width: var(--token-box-size);
  height: var(--token-box-size);
  border: 2px solid var(--token-box-border-default);
  border-radius: var(--token-box-radius);
  background-color: var(--token-box-bg-default);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  caret-color: var(--md-sys-color-primary);
}

.token-box::placeholder {
  color: transparent;
}

.token-box:focus {
  border-color: var(--token-box-border-focus);
  box-shadow: var(--token-box-shadow-focus);
  transform: scale(1.08);
  background-color: var(--token-box-bg-default);
}

.token-box.filled {
  background-color: var(--token-box-bg-filled);
  border-color: var(--md-sys-color-primary);
  animation: charAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.token-box.error {
  border-color: var(--md-sys-color-error);
  animation: shake 0.4s ease;
}

.token-box:disabled {
  background-color: var(--md-sys-color-surface-variant);
  opacity: 0.7;
  cursor: not-allowed;
}

/* Token Complete Indicator */
.token-complete-indicator {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) scale(0);
  opacity: 0;
  transition: all 0.3s ease;
}

.token-complete-indicator.visible {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}

.token-complete-indicator i {
  font-size: 28px;
  color: var(--token-success-color);
  animation: checkBounce 0.5s ease;
}

/* Token Helper Text */
.token-helper-text {
  font-size: 0.8rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 16px;
  transition: all 0.3s ease;
}

.token-helper-text.success {
  color: var(--token-success-color);
}

.token-helper-text.error {
  color: var(--md-sys-color-error);
  font-weight: 500;
  padding: 12px 16px;
  background-color: var(--md-sys-color-error-container);
  border-radius: 8px;
  margin-top: 20px;
}

/* Token boxes complete state */
.token-boxes.complete .token-box {
  border-color: var(--token-success-color);
  background-color: var(--token-success-bg);
}

/* ========================================
   Phone Input Styles
   ======================================== */
.phone-input-wrapper {
  text-align: center;
  margin-bottom: 24px;
}

.phone-input-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  margin: 0 0 8px 0;
}

.phone-input-description {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 16px 0;
}

.phone-field {
  width: 100%;
  max-width: 320px;
}

.phone-field .mdc-text-field__input {
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.1rem;
}

/* Material Design Text Field Overrides */
.mdc-text-field--outlined:not(.mdc-text-field--disabled) .mdc-notched-outline__leading,
.mdc-text-field--outlined:not(.mdc-text-field--disabled) .mdc-notched-outline__notch,
.mdc-text-field--outlined:not(.mdc-text-field--disabled) .mdc-notched-outline__trailing {
  border-color: var(--md-sys-color-outline-variant);
}

.mdc-text-field--outlined:not(.mdc-text-field--disabled):not(.mdc-text-field--focused):hover .mdc-notched-outline .mdc-notched-outline__leading,
.mdc-text-field--outlined:not(.mdc-text-field--disabled):not(.mdc-text-field--focused):hover .mdc-notched-outline .mdc-notched-outline__notch,
.mdc-text-field--outlined:not(.mdc-text-field--disabled):not(.mdc-text-field--focused):hover .mdc-notched-outline .mdc-notched-outline__trailing {
  border-color: var(--md-sys-color-primary);
}

.mdc-text-field--outlined.mdc-text-field--focused .mdc-notched-outline__leading,
.mdc-text-field--outlined.mdc-text-field--focused .mdc-notched-outline__notch,
.mdc-text-field--outlined.mdc-text-field--focused .mdc-notched-outline__trailing {
  border-color: var(--md-sys-color-primary);
  border-width: 2px;
}

.mdc-text-field--outlined.mdc-text-field--focused .mdc-floating-label {
  color: var(--md-sys-color-primary);
}

/* MDC Text Field Theme Override */
.mdc-text-field--focused:not(.mdc-text-field--disabled) .mdc-floating-label {
  color: #1976D2 !important;
}

.mdc-line-ripple--active {
  background-color: #1976D2 !important;
}

.mdc-text-field--focused .mdc-notched-outline__leading,
.mdc-text-field--focused .mdc-notched-outline__notch,
.mdc-text-field--focused .mdc-notched-outline__trailing {
  border-color: #1976D2 !important;
}

/* ========================================
   Button Styles
   ======================================== */
.submit-button {
  width: 100%;
  height: 52px;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 12px;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  transition: all 0.3s ease;
  margin-top: 8px;
}

.submit-button:hover:not(:disabled) {
  background-color: #1565C0;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.submit-button:disabled {
  background-color: var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  cursor: not-allowed;
}

.retry-button {
  margin-top: 16px;
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-primary);
  border-radius: 8px;
}

.retry-button:hover {
  background-color: var(--md-sys-color-primary-container);
}

/* ========================================
   Success Section
   ======================================== */
.success-card {
  text-align: center;
  position: relative;
  overflow: hidden;
}

.success-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--md-sys-color-primary), var(--md-sys-color-primary-light));
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--md-sys-color-primary-light), var(--md-sys-color-primary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: successPop 0.5s ease;
}

.success-icon i {
  font-size: 48px;
  color: white;
}

.success-card h2 {
  color: var(--md-sys-color-primary);
  margin-bottom: 8px;
}

.download-info {
  background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  padding: 20px;
  border-radius: 12px;
  margin: 24px 0;
  text-align: left;
  border: 1px solid rgba(25, 118, 210, 0.2);
}

.download-info p {
  margin: 10px 0;
  font-size: 0.95rem;
  color: var(--md-sys-color-on-surface);
}

.download-info strong {
  color: var(--md-sys-color-primary);
}

/* Download Button */
.download-button {
  width: 100%;
  height: 56px;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-primary-dark));
  color: white;
  margin: 16px 0;
  transition: all 0.3s ease;
}

.download-button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--md-sys-color-primary-dark), var(--md-sys-color-primary));
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
  transform: translateY(-2px);
}

.download-button:disabled {
  background: var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
}

.download-button .material-icons {
  margin-right: 8px;
}

/* ========================================
   Error Section
   ======================================== */
.error-card {
  border-left: 4px solid var(--md-sys-color-error);
  text-align: center;
}

.error-icon {
  margin-bottom: 16px;
}

.error-icon i {
  font-size: 64px;
  color: var(--md-sys-color-error);
}

/* ========================================
   Loading Animation
   ======================================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  margin-right: 8px;
}

/* ========================================
   Keyframe Animations
   ======================================== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes charAppear {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes checkBounce {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

@keyframes successPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========================================
   Snackbar Styles
   ======================================== */
.mdc-snackbar {
  z-index: 1000;
  top: 16px;
  bottom: auto !important;
}

.mdc-snackbar--opening,
.mdc-snackbar--open,
.mdc-snackbar--closing {
  top: 16px;
  bottom: auto !important;
}

.mdc-snackbar__surface {
  background-color: #323232;
  color: #ffffff;
}

.snackbar-success .mdc-snackbar__surface {
  background-color: #4CAF50;
  color: #ffffff;
}

.snackbar-error .mdc-snackbar__surface {
  background-color: var(--md-sys-color-error);
  color: #ffffff;
}

.snackbar-info .mdc-snackbar__surface {
  background-color: var(--md-sys-color-primary);
  color: #ffffff;
}

/* ========================================
   Footer Styles
   ======================================== */
.app-footer {
  background-color: #E3F2FD;
  padding: 24px 16px;
  margin-top: auto;
}

.footer-content {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.footer-company {
  margin-bottom: 8px;
}

.company-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: #37474F;
}

.footer-address {
  font-size: 0.8rem;
  color: #546E7A;
  margin-bottom: 8px;
}

.footer-info {
  font-size: 0.8rem;
  color: #546E7A;
  margin-bottom: 4px;
}

.footer-separator {
  margin: 0 8px;
  color: #90A4AE;
}

.footer-links {
  margin: 12px 0;
}

.footer-links a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: #1565C0;
  text-decoration: underline;
}

.footer-link-separator {
  margin: 0 12px;
  color: #90A4AE;
}

.footer-copyright {
  font-size: 0.75rem;
  color: #78909C;
  margin-top: 8px;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
  .main-content {
    padding: 16px;
    padding-top: 80px; /* 64px (top app bar) + 16px (spacing) */
  }

  .card-content {
    padding: 20px 16px;
  }

  .token-box {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  .token-boxes {
    gap: 8px;
  }

  .token-complete-indicator i {
    font-size: 24px;
  }
}

@media (max-width: 400px) {
  .token-box {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 8px;
  }

  .token-boxes {
    gap: 6px;
  }

  .mdc-top-app-bar__title {
    font-size: 18px;
  }
}

/* ========================================
   Utility Classes
   ======================================== */
.text-center {
  text-align: center;
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
