@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  min-height: 100vh;
  background: #f5f5f5;
}

main {
  display: flex;
  min-height: 100vh;
}

/* Login Section */
.login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  padding: 30px 40px;
  background-color: #fff;
  overflow-y: auto;
}

.login.hidden {
  display: none;
}

/* Generic hidden class */
.hidden {
  display: none !important;
}

.wrapper {
  width: 100%;
}

/* Logo */
.login__logo {
  width: 140px;
  margin-bottom: 24px;
}

/* Title */
.login__title {
  font-size: 1.6rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.login__subtitle {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 20px;
}

/* Info text */
.login__info {
  font-size: 0.85rem;
  color: #9ca3af;
  line-height: 1.5;
  margin-top: 8px;
}

/* Form Control */
.form-control {
  position: relative;
  margin-bottom: 16px;
}

.form-control input,
.form-control select {
  width: 100%;
  padding: 14px 12px 8px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-control select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-control label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: #6b7280;
  pointer-events: none;
  transition: all 0.2s ease;
  background: #fff;
  padding: 0 6px;
}

.form-control input:focus,
.form-control select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control input:focus + label,
.form-control input:valid + label,
.form-control select:focus + label,
.form-control select:valid + label {
  top: 0;
  font-size: 0.75rem;
  color: #3b82f6;
}

/* Checkbox */
.login__checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #4b5563;
  cursor: pointer;
  margin-bottom: 20px;
}

.login__checkbox input {
  display: none;
}

.checkmark {
  width: 22px;
  height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  position: relative;
  transition: all 0.2s;
}

.login__checkbox input:checked + .checkmark {
  background: #3b82f6;
  border-color: #3b82f6;
}

.login__checkbox input:checked + .checkmark::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Button */
.btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #3b82f6;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-bottom: 16px;
}

.btn:hover {
  background: #2563eb;
}

.btn:active {
  transform: scale(0.98);
}

/* Links */
.login__link {
  display: block;
  text-align: center;
  font-size: 0.9rem;
  color: #6b7280;
  text-decoration: none;
  margin-bottom: 12px;
  transition: color 0.2s;
}

.login__link:hover {
  color: #3b82f6;
}

/* Wallpaper */
.wallpaper {
  flex: 1;
  background: url('./images/wallpaper.jpg') center/cover no-repeat;
  position: relative;
}

.wallpaper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(0, 0, 0, 0.4));
}

/* ========== LOADING OVERLAY ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 16px;
  font-size: 1rem;
  color: #4b5563;
  font-weight: 500;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal__icon {
  width: 60px;
  height: 60px;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0 auto 20px;
}

.modal__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.modal__message {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ========== RESPONSIVIDADE ========== */

/* Desktop Grande (1200px+) */
@media (min-width: 1200px) {
  .login {
    max-width: 450px;
    padding: 40px 50px;
  }

  .login__logo {
    width: 150px;
  }

  .login__title {
    font-size: 1.75rem;
  }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .login {
    max-width: 400px;
    padding: 30px 35px;
  }

  .login__logo {
    width: 130px;
  }
}

/* Mobile Grande (481px - 768px) */
@media (max-width: 768px) {
  main {
    flex-direction: column;
  }

  .login {
    max-width: 100%;
    height: 100vh;
    padding: 25px 30px;
  }

  .wallpaper {
    display: none;
  }

  .login__logo {
    width: 120px;
    margin-bottom: 20px;
  }

  .login__title {
    font-size: 1.5rem;
  }

  .login__subtitle {
    font-size: 0.85rem;
    margin-bottom: 18px;
  }

  .form-control {
    margin-bottom: 14px;
  }

  .form-control input,
  .form-control select {
    padding: 12px 10px 6px;
  }

  .btn {
    padding: 12px 18px;
  }
}

/* Mobile Pequeno (até 480px) */
@media (max-width: 480px) {
  .login {
    padding: 20px 18px;
  }

  .login__logo {
    width: 100px;
    margin-bottom: 16px;
  }

  .login__title {
    font-size: 1.3rem;
  }

  .login__subtitle {
    font-size: 0.8rem;
    margin-bottom: 16px;
  }

  .form-control {
    margin-bottom: 12px;
  }

  .form-control input,
  .form-control select {
    padding: 12px 10px 6px;
    font-size: 0.9rem;
  }

  .form-control label {
    font-size: 0.85rem;
  }

  .login__checkbox {
    font-size: 0.8rem;
    margin-bottom: 16px;
  }

  .btn {
    padding: 11px 14px;
    font-size: 0.9rem;
    margin-bottom: 14px;
  }

  .login__link {
    font-size: 0.8rem;
  }
}

/* ========== SISTEMA EXTERNO (IFRAME) ========== */
.external-system {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.external-system.hidden {
  display: none;
}

.external-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #1a1a2e;
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.external-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.external-back:hover {
  background: rgba(255, 255, 255, 0.2);
}

.external-title {
  font-size: 1rem;
  font-weight: 600;
}

.external-fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.external-fullscreen:hover {
  background: rgba(255, 255, 255, 0.2);
}

.external-iframe-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.external-iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.iframe-loading {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.iframe-loading.hidden {
  display: none;
}

.iframe-loading p {
  color: #4b5563;
  font-size: 1rem;
}

.iframe-loading-hint {
  font-size: 0.85rem !important;
  color: #9ca3af !important;
}

/* Responsivo para iframe mobile */
@media (max-width: 768px) {
  .external-header {
    padding: 10px 15px;
  }

  .external-back {
    padding: 6px 12px;
    font-size: 0.85rem;
  }

  .external-title {
    font-size: 0.9rem;
  }
}

/* ========== MODAL DE CREDENCIAIS ========== */
.credentials-modal {
  max-width: 420px;
}

.credentials-box {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.credential-item {
  margin-bottom: 12px;
}

.credential-item:last-child {
  margin-bottom: 0;
}

.credential-item label {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 6px;
  font-weight: 500;
}

.credential-value {
  display: flex;
  gap: 8px;
}

.credential-value input {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: 'Courier New', monospace;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
  font-weight: 600;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  color: #3b82f6;
  background: #eff6ff;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.copy-btn:hover {
  background: #3b82f6;
  color: #fff;
}

.copy-btn svg {
  flex-shrink: 0;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #10b981;
}

.btn-primary:hover {
  background: #059669;
}

.btn-secondary {
  background: transparent;
  color: #6b7280;
  border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
  background: #f3f4f6;
  color: #374151;
}

/* Responsivo para modal de credenciais */
@media (max-width: 480px) {
  .credentials-modal {
    max-width: 100%;
    margin: 10px;
  }
  
  .credential-value {
    flex-direction: column;
  }
  
  .copy-btn {
    justify-content: center;
  }
}