/* Material Design 3 Dark Theme */
:root {
  /* Primary Colors */
  --md-sys-color-primary: #D0BCFF;
  --md-sys-color-on-primary: #371E73;
  --md-sys-color-primary-container: #4F378B;
  --md-sys-color-on-primary-container: #EADDFF;
  
  /* Surface Colors */
  --md-sys-color-surface: #141218;
  --md-sys-color-on-surface: #E6E0E9;
  --md-sys-color-surface-container-low: #1D1B20;
  --md-sys-color-surface-container: #211F26;
  --md-sys-color-surface-container-high: #2B2930;
  --md-sys-color-surface-container-highest: #36343B;
  
  /* Error Colors */
  --md-sys-color-error: #F2B8B5;
  --md-sys-color-on-error: #601410;
  --md-sys-color-error-container: #8C1D18;
  --md-sys-color-on-error-container: #F9DEDC;
  
  /* Success Colors */
  --md-sys-color-success: #A6D189;
  --md-sys-color-on-success: #0D2818;
  --md-sys-color-success-container: #1E3B2C;
  --md-sys-color-on-success-container: #C2F0A4;
  
  /* Outline */
  --md-sys-color-outline: #938F99;
  --md-sys-color-outline-variant: #49454F;
  
  /* Typography */
  --md-sys-typescale-display-large-font-family-name: 'Roboto';
  --md-sys-typescale-display-large-font-weight: 400;
  --md-sys-typescale-display-large-font-size: 57px;
  --md-sys-typescale-display-large-line-height: 64px;
  
  --md-sys-typescale-headline-large-font-family-name: 'Roboto';
  --md-sys-typescale-headline-large-font-weight: 400;
  --md-sys-typescale-headline-large-font-size: 32px;
  --md-sys-typescale-headline-large-line-height: 40px;
  
  --md-sys-typescale-body-large-font-family-name: 'Roboto';
  --md-sys-typescale-body-large-font-weight: 400;
  --md-sys-typescale-body-large-font-size: 16px;
  --md-sys-typescale-body-large-line-height: 24px;
  
  /* Elevations */
  --md-sys-elevation-level0: 0px 0px 0px 0px rgba(0, 0, 0, 0);
  --md-sys-elevation-level1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
  --md-sys-elevation-level3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-level4: 0px 6px 10px 4px rgba(0, 0, 0, 0.15), 0px 2px 3px 0px rgba(0, 0, 0, 0.3);
  --md-sys-elevation-level5: 0px 8px 12px 6px rgba(0, 0, 0, 0.15), 0px 4px 4px 0px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-y: scroll; /* Vždy zobrazit scrollbar prostor pro konzistentní layout */
}

body {
  font-family: var(--md-sys-typescale-body-large-font-family-name);
  font-size: var(--md-sys-typescale-body-large-font-size);
  line-height: var(--md-sys-typescale-body-large-line-height);
  font-weight: var(--md-sys-typescale-body-large-font-weight);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  min-height: 100vh;
  margin: 0;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 48px;
  padding: 24px 0;
}

h1 {
  font-family: var(--md-sys-typescale-headline-large-font-family-name);
  font-size: var(--md-sys-typescale-headline-large-font-size);
  line-height: var(--md-sys-typescale-headline-large-line-height);
  font-weight: var(--md-sys-typescale-headline-large-font-weight);
  color: var(--md-sys-color-primary);
  margin-bottom: 8px;
}

.subtitle {
  color: var(--md-sys-color-on-surface);
  opacity: 0.7;
  font-size: 16px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Input Section */
.input-section {
  background-color: var(--md-sys-color-surface-container);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--md-sys-elevation-level2);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.input-section:hover {
  box-shadow: var(--md-sys-elevation-level3);
}

.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
}

.input-wrapper {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

input[type="text"] {
  flex: 1;
  background-color: var(--md-sys-color-surface-container-high);
  border: 2px solid var(--md-sys-color-outline-variant);
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 16px;
  color: var(--md-sys-color-on-surface);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(208, 188, 255, 0.2);
}

input[type="text"]:invalid {
  border-color: var(--md-sys-color-error);
}

.input-helper {
  font-size: 12px;
  color: var(--md-sys-color-on-surface);
  opacity: 0.7;
  margin-top: 4px;
}

.input-error {
  color: var(--md-sys-color-error);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

/* Buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  overflow: hidden;
  outline: none;
  min-height: 48px;
}

.btn:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.btn:hover:before {
  opacity: 0.08;
}

.btn:focus:before {
  opacity: 0.12;
}

.btn:active:before {
  opacity: 0.16;
}

.btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level1);
}

.btn-primary:hover {
  box-shadow: var(--md-sys-elevation-level2);
}

.btn-secondary {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.btn-outline {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:disabled:before {
  display: none;
}

/* Loading State */
.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading .btn-text {
  opacity: 0;
}

.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Result Section */
.result-section {
  background-color: var(--md-sys-color-surface-container);
  border-radius: 28px;
  padding: 32px;
  box-shadow: var(--md-sys-elevation-level2);
  display: none;
  animation: slideUp 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.result-section.show {
  display: block;
}

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

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

.result-title {
  font-size: 24px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.article-info {
  background-color: var(--md-sys-color-surface-container-high);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.article-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.article-id {
  font-size: 14px;
  opacity: 0.7;
}

.result-content {
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  border-left: 4px solid var(--md-sys-color-primary);
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  max-width: 400px;
}

.toast {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: var(--md-sys-elevation-level3);
  margin-bottom: 8px;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  background-color: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}

.toast.error {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 14px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.modal-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background-color: var(--md-sys-color-surface-container);
  border-radius: 28px;
  padding: 32px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--md-sys-elevation-level5);
  animation: scaleIn 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.modal-title {
  font-size: 24px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.modal-close:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.modal-content {
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: 16px;
  padding: 24px;
  font-family: 'Roboto Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 60vh;
  overflow-y: auto;
}

/* Error State */
.error-section {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-radius: 16px;
  padding: 24px;
  margin-top: 16px;
  display: none;
}

.error-section.show {
  display: block;
  animation: slideUp 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.error-title {
  font-weight: 500;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-message {
  font-size: 14px;
  line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  
  h1 {
    font-size: 28px;
    line-height: 36px;
  }
  
  .input-section,
  .result-section {
    padding: 24px;
    border-radius: 20px;
  }
  
  .input-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .result-header {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  
  .result-actions {
    justify-content: center;
  }
  
  .toast-container {
    top: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
  
  .modal {
    margin: 16px;
    padding: 24px;
    border-radius: 20px;
  }
  
  .btn {
    min-height: 44px;
    padding: 14px 20px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }
  
  .input-section,
  .result-section {
    padding: 20px;
  }
  
  .result-actions {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
}

/* Focus Indicators */
@media (prefers-reduced-motion: no-preference) {
  .btn,
  input,
  .modal-close {
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --md-sys-color-outline: #FFFFFF;
    --md-sys-color-outline-variant: #CCCCCC;
  }
  
  input[type="text"] {
    border-width: 3px;
  }
  
  .btn {
    border-width: 2px;
  }
}

/* LOGIN SCREEN STYLES */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--md-sys-color-surface) 0%, var(--md-sys-color-surface-container) 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: all 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.login-container {
  background-color: var(--md-sys-color-surface-container);
  border-radius: 32px;
  padding: 48px 40px;
  box-shadow: var(--md-sys-elevation-level4);
  text-align: center;
  max-width: 480px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.login-container::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-container));
}

.login-header {
  margin-bottom: 40px;
}

.login-title {
  font-family: var(--md-sys-typescale-headline-large-font-family-name);
  font-size: 28px;
  line-height: 36px;
  font-weight: 500;
  color: var(--md-sys-color-primary);
  margin-bottom: 12px;
}

.login-subtitle {
  color: var(--md-sys-color-on-surface);
  opacity: 0.8;
  font-size: 16px;
  font-weight: 400;
}

.login-form {
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.pin-inputs {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.pin-input {
  width: 56px;
  height: 56px;
  background-color: var(--md-sys-color-surface-container-high);
  border: 2px solid var(--md-sys-color-outline-variant);
  border-radius: 16px;
  text-align: center;
  font-size: 24px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  outline: none;
  caret-color: var(--md-sys-color-primary);
}

.pin-input:focus {
  border-color: var(--md-sys-color-primary);
  background-color: var(--md-sys-color-surface-container-highest);
  box-shadow: 0 0 0 2px rgba(208, 188, 255, 0.2);
  transform: scale(1.05);
}

.pin-input:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.pin-input.filled {
  border-color: var(--md-sys-color-primary);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.login-status {
  min-height: 60px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.error-message {
  color: var(--md-sys-color-error);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.error-message.show {
  opacity: 1;
  transform: translateY(0);
}

.attempts-info {
  color: var(--md-sys-color-on-surface);
  font-size: 12px;
  opacity: 0;
  transform: translateY(-5px);
  transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.attempts-info.show {
  opacity: 0.7;
  transform: translateY(0);
}

.login-btn {
  width: 100%;
  margin-bottom: 24px;
  font-size: 16px;
  font-weight: 500;
  height: 56px;
  position: relative;
  overflow: hidden;
}

.login-btn.btn-ready {
  background-color: var(--md-sys-color-primary);
  box-shadow: var(--md-sys-elevation-level2);
}

.login-btn.btn-ready:hover {
  box-shadow: var(--md-sys-elevation-level3);
}

.login-help {
  color: var(--md-sys-color-on-surface);
  opacity: 0.6;
  font-size: 12px;
  line-height: 1.4;
}

.success-animation {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
  text-align: center;
}

.success-check {
  width: 80px;
  height: 80px;
  background-color: var(--md-sys-color-success);
  color: var(--md-sys-color-on-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: bold;
  margin: 0 auto 16px;
  animation: successPulse 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes successPulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-animation p {
  color: var(--md-sys-color-success);
  font-weight: 500;
  font-size: 18px;
  margin: 0;
}

/* Logout Button */
.logout-btn {
  font-size: 12px;
  padding: 8px 16px;
  min-height: 40px;
  right: 32px !important;
  top: 16px !important;
}

.logout-btn:hover {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-color: var(--md-sys-color-error);
}

/* Mobile Responsiveness for Login */
@media (max-width: 768px) {
  .login-overlay {
    padding: 16px;
  }
  
  .login-container {
    padding: 32px 24px;
    border-radius: 24px;
  }
  
  .login-title {
    font-size: 24px;
    line-height: 32px;
  }
  
  .pin-inputs {
    gap: 8px;
  }
  
  .pin-input {
    width: 48px;
    height: 48px;
    font-size: 20px;
    border-radius: 12px;
  }
  
  .logout-btn {
    position: static !important;
    margin-top: 16px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .login-container {
    padding: 24px 20px;
    border-radius: 20px;
  }
  
  .login-title {
    font-size: 20px;
    line-height: 28px;
  }
  
  .pin-inputs {
    gap: 6px;
    flex-wrap: wrap;
  }
  
  .pin-input {
    width: 44px;
    height: 44px;
    font-size: 18px;
    border-radius: 8px;
  }
  
  .success-check {
    width: 60px;
    height: 60px;
    font-size: 30px;
  }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
  .pin-inputs {
    gap: 4px;
    max-width: 280px;
    margin: 0 auto 32px;
  }
  
  .pin-input {
    width: 40px;
    height: 40px;
    font-size: 16px;
    border-radius: 8px;
  }
}

/* Very small devices like 344px width */
@media (max-width: 360px) {
  .login-container {
    padding: 20px 16px;
  }
  
  .login-title {
    font-size: 18px;
    line-height: 24px;
  }
  
  .pin-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 160px;
    margin: 0 auto 32px;
  }
  
  .pin-input {
    width: 48px;
    height: 48px;
    font-size: 18px;
    border-radius: 8px;
  }
}

/* Hide main app initially when auth is required */
.container.auth-required {
  display: none;
}

/* Print Styles */
@media print {
  .input-section,
  .result-actions,
  .toast-container,
  .modal-overlay,
  .login-overlay {
    display: none !important;
  }
  
  .result-section {
    box-shadow: none;
    border: 2px solid #000;
  }
  
  .result-content {
    background-color: transparent;
    border: 1px solid #000;
    color: #000;
  }
}
