<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MySQL Configuration · Enterprise</title>
  <link rel="icon" type="image/png" sizes="32x32" href="static/config.png">
  <!-- Bootstrap 5.3 + Icons -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.10.5/font/bootstrap-icons.min.css" rel="stylesheet">
  <!-- Google Font: Inter (professional sans) -->
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
  <style>
    /* ----- DESIGN SYSTEM — FASTER, CLEANER, PREMIUM ----- */
    :root {
      --primary-gradient: linear-gradient(145deg, #6a11cb, #2575fc);
      --secondary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      --glass-bg: rgba(255, 255, 255, 0.88);
      --border-radius-card: 28px;
      --border-radius-input: 14px;
      --transition-fast: 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94);
      --shadow-elevation: 0 20px 35px -8px rgba(0, 0, 0, 0.2), 0 8px 12px -6px rgba(0, 0, 0, 0.1);
      --shadow-hover: 0 30px 45px -12px rgba(106, 17, 203, 0.25);
    }

    body {
      background: var(--secondary-gradient);
      font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
      min-height: 100vh;
      margin: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1.25rem;
      position: relative;
    }

    /* subtle animated noise texture (professional touch) */
    body::after {
      content: '';
      position: fixed;
      top: 0; left: 0; width: 100%; height: 100%;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
      pointer-events: none;
      opacity: 0.4;
    }

    /* ----- CARD — MODERN GLASSMORPHISM, FASTER ENTRANCE ----- */
    .config-card {
      border: none;
      border-radius: var(--border-radius-card);
      box-shadow: var(--shadow-elevation);
      background: var(--glass-bg);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      transition: box-shadow var(--transition-fast), transform 0.25s ease;
      animation: cardEntrance 0.35s ease-out; /* faster than typical 0.5s */
    }

    .config-card:hover {
      box-shadow: var(--shadow-hover);
    }

    @keyframes cardEntrance {
      0% { opacity: 0; transform: translateY(18px) scale(0.98); }
      100% { opacity: 1; transform: translateY(0) scale(1); }
    }

    /* ----- HEADER — DEEP GRADIENT, SMOOTH EDGES ----- */
    .card-header {
      background: var(--primary-gradient);
      color: white;
      padding: 2rem 1.8rem;
      border-radius: var(--border-radius-card) var(--border-radius-card) 0 0 !important;
      text-align: center;
      border-bottom: none;
      position: relative;
      isolation: isolate;
    }

    .card-header h2 {
      font-weight: 700;
      letter-spacing: -0.02em;
      font-size: 2.1rem;
      margin-bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
    }

    .card-header i {
      filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
      transition: transform var(--transition-fast);
    }

    .card-header:hover i {
      transform: scale(1.05) rotate(2deg);
    }

    /* ----- FORM CONTROLS — ELEVATED, FASTER FOCUS ----- */
    .form-label {
      font-weight: 600;
      font-size: 0.9rem;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      color: #2c3e50;
      margin-bottom: 0.35rem;
      margin-left: 0.2rem;
    }

    .form-control {
      border: 2px solid #edf2f7;
      border-radius: var(--border-radius-input);
      padding: 0.9rem 1.2rem;
      font-size: 1rem;
      background: white;
      transition: all 0.2s ease;  /* faster than original 0.3s */
    }

    .form-control:focus {
      border-color: #6a11cb;
      box-shadow: 0 0 0 4px rgba(106, 17, 203, 0.08);
      outline: none;
    }

    /* ----- INPUT GROUP — PASSWORD TOGGLE (CLEAN & FAST) ----- */
    .input-group {
      border-radius: var(--border-radius-input);
      background: white;
      transition: box-shadow var(--transition-fast);
    }

    .input-group:focus-within {
      box-shadow: 0 0 0 4px rgba(106, 17, 203, 0.08);
    }

    .input-group .form-control {
      border-right: none;
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }

    .input-group .btn-outline-secondary {
      border: 2px solid #edf2f7;
      border-left: none;
      border-radius: 0 var(--border-radius-input) var(--border-radius-input) 0;
      background: white;
      color: #4a5568;
      padding: 0 1.2rem;
      transition: all 0.15s ease;
    }

    .input-group .btn-outline-secondary:hover {
      background: #f8fafd;
      color: #6a11cb;
      border-color: #edf2f7;
    }

    .input-group .btn-outline-secondary:focus-visible {
      box-shadow: none;
      background: #f1f5f9;
    }

    .bi-eye, .bi-eye-slash {
      font-size: 1.25rem;
      transition: transform 0.15s, color 0.15s;
    }

    .btn-outline-secondary:hover .bi-eye,
    .btn-outline-secondary:hover .bi-eye-slash {
      transform: scale(0.95);
    }

    /* ----- PRIMARY BUTTON — FASTER HOVER, PULSE-LIGHT ----- */
    .btn-primary {
      background: var(--primary-gradient);
      border: none;
      padding: 0.9rem 1.8rem;
      border-radius: 60px;
      font-weight: 600;
      letter-spacing: 0.5px;
      font-size: 1.1rem;
      transition: all 0.2s ease, box-shadow 0.15s;
      box-shadow: 0 6px 14px rgba(106, 17, 203, 0.25);
    }

    .btn-primary:hover {
      transform: translateY(-3px);
      box-shadow: 0 12px 22px rgba(106, 17, 203, 0.35);
    }

    .btn-primary:active {
      transform: translateY(-1px);
      box-shadow: 0 8px 16px rgba(106, 17, 203, 0.4);
    }

    .btn-primary i {
      transition: transform 0.2s;
    }

    .btn-primary:hover i {
      transform: rotate(60deg);
    }

    /* ----- FLOATING ALERT — FASTER SLIDE & GLASSY ----- */
    .floating-alert {
      position: fixed;
      top: 24px;
      left: 50%;
      transform: translateX(-50%);
      min-width: 360px;
      max-width: 90%;
      text-align: center;
      animation: slideDownFaster 0.22s cubic-bezier(0.21, 0.98, 0.35, 1);
      z-index: 1070;
      background: rgba(255, 255, 255, 0.9);
      backdrop-filter: blur(12px);
      border: none;
      border-left: 6px solid #6a11cb;
      border-radius: 100px;
      box-shadow: 0 12px 28px rgba(0,0,0,0.16);
      font-weight: 500;
      padding: 0.9rem 1.5rem;
      color: #1e293b;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
    }

    @keyframes slideDownFaster {
      0% { top: -40px; opacity: 0; }
      100% { top: 24px; opacity: 1; }
    }

    .alert .btn-close {
      filter: brightness(0.6);
      margin-left: 0.75rem;
      transition: transform 0.15s;
    }

    .alert .btn-close:hover {
      transform: scale(1.2);
    }

    /* ----- RESPONSIVE REFINEMENTS ----- */
    @media (max-width: 576px) {
      .card-header h2 { font-size: 1.8rem; }
      .config-card { margin: 0.5rem; }
      .floating-alert { min-width: 280px; }
    }

    /* subtle focus ring for accessibility */
    :focus-visible {
      outline: 3px solid #6a11cb;
      outline-offset: 2px;
    }

    /* placeholders style */
    ::placeholder {
      color: #a0aec0;
      font-weight: 400;
      opacity: 0.8;
    }
  </style>
</head>
<body>
  <main class="container">
    <div class="row justify-content-center">
      <div class="col-lg-6 col-md-8 col-sm-11">
        <!-- MAIN CONFIG CARD — FASTER ENTRANCE, ELEVATED GLASS -->
        <div class="config-card">
          <header class="card-header">
            <h2>
              <i class="bi bi-database"></i>
              <span>MySQL Config</span>
            </h2>
            <p class="mt-2 mb-0 opacity-75 small fw-light" style="letter-spacing: 0.5px;">
              <i class="bi bi-shield-lock me-1"></i>ENTERPRISE SECURE CONNECTION
            </p>
          </header>

          <div class="card-body p-4 p-xl-5">
            <form action="/config_mysql" method="POST" class="needs-validation" novalidate>
              <!-- HOST -->
              <div class="mb-4">
                <label for="host" class="form-label">
                  <i class="bi bi-hdd-stack me-1"></i> Hostname
                </label>
                <input type="text" class="form-control" id="host" name="host"
                       placeholder="e.g., localhost, 127.0.0.1 or db.example.com"
                       required autocomplete="off">
                <div class="invalid-feedback">Host is required</div>
              </div>

              <!-- USERNAME -->
              <div class="mb-4">
                <label for="username" class="form-label">
                  <i class="bi bi-person-circle me-1"></i> Username
                </label>
                <input type="text" class="form-control" id="username" name="username"
                       placeholder="Database user (e.g., root, admin)"
                       required autocomplete="off">
              </div>

              <!-- PASSWORD — TOGGLE VISIBILITY, FASTER TRANSITION -->
              <div class="mb-4">
                <label for="password" class="form-label">
                  <i class="bi bi-key me-1"></i> Password
                </label>
                <div class="input-group">
                  <input type="password" class="form-control" id="password" name="password"
                         placeholder="••••••••••" autocomplete="new-password">
                  <button type="button" class="btn btn-outline-secondary" id="togglePassword"
                          aria-label="Show password">
                    <i class="bi bi-eye" id="eyeIcon"></i>
                  </button>
                </div>
                <small class="text-muted mt-2 d-block ms-1">
                  <i class="bi bi-info-circle"></i> Leave empty if no password
                </small>
              </div>

              <!-- DATABASE NAME -->
              <div class="mb-5">
                <label for="database" class="form-label">
                  <i class="bi bi-database-fill me-1"></i> Database name
                </label>
                <input type="text" class="form-control" id="database" name="database"
                       placeholder="e.g., sales_db, wordpress" required>
              </div>

              <!-- SUBMIT BUTTON — FASTER HOVER, MICRO-ANIMATION -->
              <div class="d-grid">
                <button type="submit" class="btn btn-primary btn-lg">
                  <i class="bi bi-gear-wide-connected me-2"></i> Establish Connection
                </button>
              </div>
            </form>

            <!-- FLASH MESSAGES — FASTER SLIDE-DOWN, MODERN GLASS -->
            {% with messages = get_flashed_messages() %}
              {% if messages %}
                <div class="floating-alert alert-dismissible fade show" role="alert">
                  <i class="bi bi-check-circle-fill" style="color: #6a11cb;"></i>
                  {{ messages[0] }}
                  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
              {% endif %}
            {% endwith %}
          </div>
        </div>
        <!-- subtle footer note -->
        <p class="text-center text-white-50 mt-4 small fw-light opacity-75">
          <i class="bi bi-shield-check"></i> Encrypted connection · SSL ready
        </p>
      </div>
    </div>
  </main>

  <!-- Bootstrap JS bundle -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  <script>
    (function() {
      "use strict";

      // ---------- FAST PASSWORD TOGGLE (INSTANT FEEDBACK) ----------
      const togglePassword = document.querySelector('#togglePassword');
      const passwordField = document.querySelector('#password');
      const eyeIcon = document.querySelector('#eyeIcon');

      if (togglePassword && passwordField && eyeIcon) {
        togglePassword.addEventListener('click', (e) => {
          e.preventDefault();
          const isPassword = passwordField.getAttribute('type') === 'password';
          passwordField.setAttribute('type', isPassword ? 'text' : 'password');

          // switch icon + aria-label (fast class toggling)
          if (isPassword) {
            eyeIcon.classList.remove('bi-eye');
            eyeIcon.classList.add('bi-eye-slash');
            togglePassword.setAttribute('aria-label', 'Hide password');
          } else {
            eyeIcon.classList.remove('bi-eye-slash');
            eyeIcon.classList.add('bi-eye');
            togglePassword.setAttribute('aria-label', 'Show password');
          }
        });
      }

      // ---------- (OPTIONAL) AUTO-DISMISS FLASH ALERT AFTER 5 SEC ----------
      // smooth, professional — keeps UI clean
      const flashAlert = document.querySelector('.floating-alert');
      if (flashAlert) {
        setTimeout(() => {
          const bsAlert = bootstrap.Alert.getOrCreateInstance(flashAlert);
          if (bsAlert) bsAlert.close();
        }, 5000); // disappears after 5s gracefully
      }

      // ---------- BOOTSTRAP VALIDATION STYLING (subtle) ----------
      const forms = document.querySelectorAll('.needs-validation');
      Array.from(forms).forEach(form => {
        form.addEventListener('submit', event => {
          if (!form.checkValidity()) {
            event.preventDefault();
            event.stopPropagation();
          }
          form.classList.add('was-validated');
        }, false);
      });
    })();
  </script>

  <!-- improve invalid feedback styling (Bootstrap default override) -->
  <style>
    .was-validated .form-control:invalid:focus,
    .form-control.is-invalid:focus {
      box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
      border-color: #dc2626;
    }
    .invalid-feedback {
      font-size: 0.8rem;
      font-weight: 500;
      margin-top: 0.35rem;
      color: #b91c1c;
    }
  </style>
</body>
</html>