/* ==========================================
   KÝ IPA ONLINE - APPLE STYLE
   ========================================== */

/* === RESET & BASE === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--layout-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

:root {
  --layout-glass-control-bg: rgba(255, 255, 255, 0.2);
  --layout-glass-control-hover-bg: rgba(255, 255, 255, 0.24);
  --layout-liquid-glass-shadow:
    rgba(242, 242, 242, 0.8) 2px 2px 3px -3px inset,
    rgba(242, 242, 242, 0.8) -2px -2px 3px -3px inset,
    rgba(255, 255, 255, 0.8) -3px -3px 0.8px -3.5px inset,
    rgba(255, 255, 255, 0.8) 3px 3px 0.8px -3.5px inset,
    rgba(0, 0, 0, 0.1) 0 0 8px 0;
}

/* === MAIN APP CONTAINER === */
#app {
  width: 100%;
  max-width: 620px;
  margin: 24px auto 56px;
  padding: 0 clamp(14px, 3vw, 24px);
}

/* === HERO SECTION === */
h1 {
  font-size: 48px;
  font-weight: 600;
  text-align: center;
  background: linear-gradient(90deg, #0084ff 30%, #ff6600 60%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 70px rgba(255, 159, 64, 0.9);
  margin: 0 0 12px;
  letter-spacing: 0;
}

.subtitle {
  text-align: center;
  color: #86868b;
  font-size: 21px;
  line-height: 1.45;
  margin-bottom: 26px;
}

/* === CARD === */
.card {
  background: #fff;
  border-radius: 24px;
  padding: clamp(22px, 3vw, 30px);
  margin: 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.035);
}

/* === FORM GROUPS === */
.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 12px;
  letter-spacing: 0;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 58px;
  padding: 16px 18px;
  border: 0;
  border-radius: 999px;
  font-size: 17px;
  transition: color 0.2s ease;
  background: transparent;
  color: #1d1d1f;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input[type="text"]::placeholder,
.form-group input[type="password"]::placeholder {
  color: rgba(29, 29, 31, 0.52);
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
  color: #111113;
}

.input-with-icon {
  position: relative;
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  transition: transform 0.24s ease;
}

.input-with-icon::before,
.file-input-display::before,
.selected-file-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(247,248,250,0.72), rgba(232,234,238,0.46) 48%, rgba(220,223,229,0.34)),
    linear-gradient(180deg, rgba(255,255,255,0.16), transparent 22%);
  box-shadow:
    0 12px 24px rgba(120, 128, 140, 0.14),
    0 3px 8px rgba(120, 128, 140, 0.1),
    inset 0 -8px 14px rgba(136, 143, 155, 0.1),
    inset 0 1px 10px rgba(255,255,255,0.16);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  pointer-events: none;
  transition: background 0.24s ease, box-shadow 0.24s ease, transform 0.24s ease;
}

.input-with-icon:focus-within::before,
.file-input-wrapper:focus-within .file-input-display::before {
  background:
    linear-gradient(180deg, rgba(248,249,251,0.78), rgba(236,238,242,0.58) 52%, rgba(226,229,235,0.44)),
    linear-gradient(180deg, rgba(255,255,255,0.24), transparent 24%);
  box-shadow:
    0 18px 38px rgba(120, 128, 140, 0.18),
    0 6px 14px rgba(120, 128, 140, 0.14),
    inset 0 -8px 14px rgba(136, 143, 155, 0.05),
    inset 0 1px 14px rgba(255,255,255,0.62);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  transform: translateY(-1px);
}

.input-with-icon svg {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 21px;
  height: 21px;
  stroke: rgba(29, 29, 31, 0.54);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  z-index: 3;
}

.input-with-icon:focus-within svg {
  stroke: #0071e3;
}

.input-with-icon:hover {
  transform: translateY(-1px);
}

.input-with-icon input[type="text"],
.input-with-icon input[type="password"] {
  padding-left: 49px;
}

/* === FILE INPUT === */
.app-source-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.app-source-card {
  appearance: none;
  position: relative;
  display: grid;
  width: 100%;
  height: 112px;
  min-width: 0;
  grid-template-rows: 64px 20px;
  align-content: center;
  justify-items: center;
  row-gap: 6px;
  padding: 16px 8px 10px;
  border: 1px solid rgba(120, 128, 140, 0.22);
  border-radius: 20px;
  background: transparent;
  color: #1d1d1f;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  text-align: center;
  vertical-align: top;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease, filter 0.2s ease, transform 0.2s ease;
}

.app-source-card:hover {
  border-color: rgba(0, 113, 227, 0.45);
  transform: translateY(-1px);
}

.app-source-card.is-selected {
  border-color: #0071e3;
  color: #0071e3;
  box-shadow: none;
}

.app-source-card.is-dimmed {
  opacity: 0.45;
  filter: grayscale(1);
}

.app-logo-frame {
  display: flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #f5f5f7;
}

.app-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-card input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 6;
}

.upload-card .upload-logo {
  display: grid;
  place-items: center;
  margin-right: auto;
  margin-left: auto;
  transform: translateY(-4px);
}

.upload-logo svg {
  position: static;
  left: auto;
  top: auto;
  display: block;
  width: 64px;
  height: 64px;
  margin: auto;
  transform: none;
  stroke: #0071e3;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-source-name {
  width: 100%;
  align-self: center;
  min-height: 18px;
  min-width: 0;
  overflow: hidden;
  color: #1d1d1f;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  padding-bottom: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-card .app-source-name {
  transform: translateY(15px);
}

.app-source-card.is-selected .app-source-name {
  color: #0071e3;
}

.app-source-card.is-selected .app-logo-frame {
  outline: 1px solid rgba(0, 113, 227, 0.18);
}

.selected-file-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  margin-top: 10px;
  padding: 16px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  overflow: hidden;
}

.selected-file-bar.has-file {
  background: transparent;
}

.file-input-wrapper {
  position: relative;
  display: block;
  border-radius: 999px;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 6;
}

.file-input-display {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 58px;
  padding: 16px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  transition: transform 0.24s ease;
  cursor: pointer;
  overflow: hidden;
}

.file-input-wrapper:hover .file-input-display {
  transform: translateY(-1px);
}

.file-input-display.has-file {
  background: transparent;
}

.file-name {
  position: relative;
  z-index: 2;
  color: rgba(29, 29, 31, 0.52);
  font-size: 17px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-input-display.has-file .file-name {
  color: #1d1d1f;
}

.file-icon {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.file-icon svg {
  width: 21px;
  height: 21px;
  stroke: rgba(29, 29, 31, 0.54);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-input-wrapper:focus-within .file-icon svg,
.file-input-display.has-file .file-icon svg,
.selected-file-bar.has-file .file-icon svg {
  stroke: #0071e3;
}

/* === BUTTONS === */
.button-primary {
  width: 100%;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(0, 122, 255, 0.9), rgba(0, 113, 227, 0.78)),
    var(--layout-glass-control-bg);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--layout-liquid-glass-shadow);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  transition: all 0.2s ease;
  margin-top: 32px;
  min-height: 54px;
}

.button-primary:hover {
  background:
    linear-gradient(180deg, rgba(0, 128, 255, 0.96), rgba(0, 119, 237, 0.88)),
    var(--layout-glass-control-hover-bg);
  transform: translateY(-1px);
}

.button-primary:active {
  transform: translateY(0);
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.download-section .button-group {
  margin-top: 22px;
}

.download-button {
  display: block;
  width: 100%;
  padding: 14px 32px;
  background:
    linear-gradient(180deg, rgba(0, 122, 255, 0.9), rgba(0, 113, 227, 0.78)),
    var(--layout-glass-control-bg);
  color: white;
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--layout-liquid-glass-shadow);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  transition: all 0.2s ease;
  text-align: center;
}

.download-button:hover {
  background:
    linear-gradient(180deg, rgba(0, 128, 255, 0.96), rgba(0, 119, 237, 0.88)),
    var(--layout-glass-control-hover-bg);
  transform: translateY(-1px);
}

.download-button.secondary {
  background:
    linear-gradient(180deg, rgba(52, 199, 89, 0.94), rgba(36, 138, 61, 0.82)),
    var(--layout-glass-control-bg);
  color: #fff;
}

.download-button.secondary:hover {
  background:
    linear-gradient(180deg, rgba(60, 210, 98, 0.98), rgba(42, 150, 69, 0.9)),
    var(--layout-glass-control-hover-bg);
}

.button-reload {
  display: block;
  width: 100%;
  padding: 14px 32px;
  background: var(--layout-glass-control-bg);
  color: #1d1d1f;
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    var(--layout-liquid-glass-shadow),
    0 10px 22px rgba(120, 128, 140, 0.16),
    0 2px 8px rgba(29, 29, 31, 0.08);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  transition: all 0.2s ease;
  text-align: center;
}

.button-reload:hover {
  background: var(--layout-glass-control-hover-bg);
  color: #0071e3;
  transform: translateY(-1px);
  box-shadow:
    var(--layout-liquid-glass-shadow),
    0 12px 28px rgba(0, 113, 227, 0.14),
    0 3px 10px rgba(29, 29, 31, 0.08);
}

/* === PROGRESS === */
.progress-section {
  text-align: center;
  padding: 32px 0;
}

.progress-text {
  font-size: 17px;
  color: #1d1d1f;
  margin-bottom: 16px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #e5e5e7;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0071e3, #00a3ff);
  transition: width 0.16s linear;
  border-radius: 3px;
}

.progress-percentage {
  font-size: 24px;
  font-weight: 600;
  color: #0071e3;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* === DOWNLOAD SECTION === */
.download-section {
  text-align: center;
  padding: 2px 0 4px;
}

.download-title {
  margin: 0;
  color: #1d1d1f;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
}

/* === DIVIDER === */
.divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 24px 0;
}

@media (max-width: 768px) {
  /* App container mobile */
  #app {
    margin: 16px auto 36px;
  }

  h1 {
    font-size: 42px;
  }
  
  .subtitle {
    font-size: 18px;
  }
  
  .card {
    padding: 24px;
    border-radius: 22px;
  }
}

@media (max-width: 640px) {
  #app {
    padding: 0 18px;
    margin-top: 12px;
  }

  h1 {
    font-size: 36px;
  }

  .subtitle {
    font-size: 16px;
    margin-bottom: 24px;
  }

  .card {
    padding: 20px;
    border-radius: 18px;
  }

  .app-source-grid {
    gap: 8px;
  }

  .app-source-card {
    height: 98px;
    grid-template-rows: 54px 18px;
    row-gap: 5px;
    padding: 12px 4px 8px;
  }

  .app-logo-frame {
    width: 54px;
    height: 54px;
    border-radius: 13px;
  }

  .upload-logo svg {
    width: 54px;
    height: 54px;
    transform: none;
  }

  .upload-card .upload-logo {
    transform: translateY(-4px);
  }

  .app-source-name {
    font-size: 12px;
  }
}
