/*
 * 로그인 화면 스타일시트.
 *
 * templates/login.html에서 로드되며, 로그인 카드 레이아웃과 좌측 브랜드 장식,
 * 우측 입력 폼을 담당한다. 인증 처리 자체는 app.py/db.py에서 수행한다.
 */

/* 화면 전체에서 재사용하는 색상 토큰.
   원본 login.html의 어두운 관제 시스템 스타일을 유지하되 Flask 템플릿에 맞게 정리했다. */
    :root {
      --bg-primary: #0d0f14;
      --bg-secondary: #141720;
      --bg-card: #1a1e2a;
      --border: #2a2f3f;
      --border-bright: #3a4055;
      --text-primary: #e8eaf0;
      --text-secondary: #9ba1b2;
      --text-muted: #646b80;
      --accent-yellow: #f5b800;
      --accent-red: #ff4757;
      --accent-blue: #4fc3f7;
      --accent-green: #26de81;
    }

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

    /* 배경은 별도 이미지 없이 CSS 그라데이션과 그리드로 구성한다.
       네트워크 자산 의존성을 줄이면서 원본의 관제 화면 분위기를 재현한다. */
    body {
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
      overflow: hidden;
      background:
        radial-gradient(circle at 15% 20%, rgba(79, 195, 247, 0.08), transparent 28%),
        radial-gradient(circle at 85% 80%, rgba(245, 184, 0, 0.06), transparent 28%),
        linear-gradient(rgba(42, 47, 63, 0.28) 1px, transparent 1px),
        linear-gradient(90deg, rgba(42, 47, 63, 0.28) 1px, transparent 1px),
        var(--bg-primary);
      background-size: auto, auto, 40px 40px, 40px 40px, auto;
      color: var(--text-primary);
      font-family: "Noto Sans KR", sans-serif;
    }

    /* 로그인 전체 컨테이너.
       좌측 브랜드 패널과 우측 로그인 폼을 한 화면에 배치한다. */
    .login-wrapper {
      width: min(960px, 100%);
      min-height: 560px;
      display: flex;
      overflow: hidden;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 16px;
      box-shadow: 0 32px 80px rgba(0, 0, 0, 0.58);
    }

    /* 좌측 소개 영역.
       실제 인증에는 관여하지 않고 서비스 정체성과 배경형 관제 장식을 보여준다. */
    .brand-panel {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      padding: 48px 44px;
      background: var(--bg-secondary);
      border-right: 1px solid var(--border);
      position: relative;
      overflow: hidden;
    }

    .brand-logo {
      display: flex;
      align-items: center;
      gap: 10px;
      position: relative;
      z-index: 1;
    }

    .logo-icon {
      width: 36px;
      height: 36px;
      display: grid;
      place-items: center;
      border-radius: 8px;
      background: linear-gradient(135deg, var(--accent-blue), rgba(79, 195, 247, 0.45));
      box-shadow: 0 0 18px rgba(79, 195, 247, 0.28);
    }

    .logo-text { font-size: 13px; font-weight: 700; }
    .logo-sub {
      margin-top: 2px;
      color: var(--text-muted);
      font-family: "JetBrains Mono", monospace;
      font-size: 11px;
    }

    .brand-copy {
      position: relative;
      z-index: 1;
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    .eyebrow {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 16px;
      color: var(--accent-blue);
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 2px;
    }

    .eyebrow::before {
      content: "";
      width: 24px;
      height: 1px;
      background: var(--accent-blue);
    }

    h1 {
      font-size: 34px;
      line-height: 1.2;
      font-weight: 900;
    }

    h1 em {
      color: var(--accent-yellow);
      font-style: normal;
    }

    .brand-copy p {
      max-width: 310px;
      margin-top: 16px;
      color: var(--text-secondary);
      font-size: 13px;
      line-height: 1.8;
    }

    /* 좌측 패널의 빈 공간을 하나의 배경 장식으로 정리한다.
       실제 데이터가 아니라 시각 장식이므로 HTML에서는 aria-hidden으로 숨긴다. */
    .brand-visual {
      position: absolute;
      inset: 94px 26px 28px 34px;
      z-index: 0;
      opacity: 0.58;
      pointer-events: none;
    }

    .brand-visual svg {
      width: 100%;
      height: 100%;
      display: block;
    }

    .visual-line {
      fill: none;
      stroke: rgba(79, 195, 247, 0.32);
      stroke-width: 2;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .visual-line.muted {
      stroke: rgba(255, 255, 255, 0.08);
      stroke-width: 1;
    }

    .visual-line.warn {
      stroke: rgba(245, 184, 0, 0.28);
      stroke-dasharray: 7 9;
    }

    .visual-node {
      fill: var(--bg-secondary);
      stroke: rgba(79, 195, 247, 0.68);
      stroke-width: 2;
    }

    .visual-node.warn {
      stroke: rgba(245, 184, 0, 0.78);
    }

    .visual-pulse {
      fill: rgba(38, 222, 129, 0.84);
      filter: drop-shadow(0 0 7px rgba(38, 222, 129, 0.46));
    }

    .visual-grid rect,
    .visual-bars rect {
      fill: rgba(255, 255, 255, 0.06);
    }

    .visual-zone {
      fill: rgba(79, 195, 247, 0.045);
      stroke: rgba(79, 195, 247, 0.09);
    }

    .visual-shield {
      fill: rgba(13, 15, 20, 0.34);
      stroke: rgba(255, 255, 255, 0.08);
    }

    /* 우측 로그인 패널. form 요소는 templates/login.html에 있고 여기서는 배치만 담당한다. */
    .form-panel {
      width: 380px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 48px 40px;
    }

    /* 로그인 폼 스타일.
       HTML form은 `/login`으로 POST되고, app.py의 login() 라우트가 값을 처리한다. */
    .form-header { margin-bottom: 30px; }
    .form-header h2 {
      margin-bottom: 8px;
      font-size: 22px;
      font-weight: 800;
    }

    .form-header p {
      color: var(--text-secondary);
      font-size: 12px;
      line-height: 1.7;
    }

    .form-header strong { color: var(--accent-blue); }

    .login-form {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .field-wrap {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }

    .field-label {
      color: var(--text-secondary);
      font-size: 11px;
      font-weight: 500;
    }

    .input-row {
      display: flex;
      align-items: center;
      overflow: hidden;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--bg-secondary);
      transition: border-color 0.2s, box-shadow 0.2s;
    }

    .input-row:focus-within {
      border-color: var(--accent-blue);
      box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.12);
    }

    /* 입력 왼쪽 아이콘과 비밀번호 표시 버튼의 공통 크기/정렬. */
    .input-icon,
    .toggle-pw {
      width: 40px;
      display: grid;
      place-items: center;
      flex-shrink: 0;
      color: var(--text-muted);
    }

    .toggle-pw {
      border: 0;
      background: transparent;
      cursor: pointer;
    }

    .input-row input {
      width: 100%;
      border: 0;
      outline: 0;
      padding: 12px 8px 12px 0;
      background: transparent;
      color: var(--text-primary);
      font: 13px "Noto Sans KR", sans-serif;
    }

    /* 서버에서 error 값이 전달될 때만 HTML에 렌더링되는 오류 메시지 박스. */
    .error-msg {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 9px 12px;
      border: 1px solid rgba(255, 71, 87, 0.24);
      border-radius: 6px;
      background: rgba(255, 71, 87, 0.08);
      color: var(--accent-red);
      font-size: 11px;
      line-height: 1.5;
    }

    /* 로그인 POST를 제출하는 기본 CTA 버튼. */
    .login-btn {
      width: 100%;
      margin-top: 4px;
      padding: 13px;
      border: 0;
      border-radius: 8px;
      background: linear-gradient(135deg, #1a6fa8, var(--accent-blue));
      color: #fff;
      cursor: pointer;
      font: 700 14px "Noto Sans KR", sans-serif;
      letter-spacing: 1px;
    }

    .login-btn:hover {
      box-shadow: 0 6px 20px rgba(79, 195, 247, 0.34);
      transform: translateY(-1px);
    }

    /* 아이디 저장 체크박스와 접근 안내 문구를 같은 줄에 배치한다. */
    .form-options {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 14px;
      gap: 12px;
    }

    .remember-wrap {
      display: flex;
      align-items: center;
      gap: 7px;
      color: var(--text-secondary);
      cursor: pointer;
      font-size: 11px;
    }

    .notice-text {
      display: flex;
      align-items: center;
      gap: 4px;
      color: var(--accent-red);
      font-size: 10px;
    }

    /* 계정 문의 영역 위의 시각적 구분선. */
    .divider {
      display: flex;
      align-items: center;
      gap: 12px;
      margin: 24px 0 12px;
    }

    .divider::before,
    .divider::after {
      content: "";
      height: 1px;
      flex: 1;
      background: var(--border);
    }

    .divider span {
      color: var(--text-muted);
      font-size: 11px;
    }

    .contact {
      text-align: center;
      color: var(--text-muted);
      font-size: 11px;
      line-height: 1.8;
    }

    .contact strong {
      color: var(--accent-blue);
      font-family: "JetBrains Mono", monospace;
    }

    /* 태블릿/모바일에서는 좌우 2단 레이아웃을 세로 배치로 바꾼다. */
    /* 태블릿 이하에서는 좌우 레이아웃을 세로로 바꿔 좁은 화면에서도 읽기 쉽게 한다. */
    @media (max-width: 820px) {
      body {
        align-items: flex-start;
        overflow-y: auto;
      }

      .login-wrapper {
        flex-direction: column;
        min-height: 0;
      }

      .brand-panel {
        min-height: 300px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 32px;
      }

      .form-panel {
        width: 100%;
        padding: 32px;
      }
    }

    @media (max-width: 480px) {
      body { padding: 0; }
      .login-wrapper {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
      }

      .brand-panel,
      .form-panel { padding: 28px 24px; }

      h1 { font-size: 25px; }
      .brand-visual {
        inset: 82px 8px 18px 18px;
        opacity: 0.36;
      }
      .form-options {
        align-items: flex-start;
        flex-direction: column;
      }
    }
