/* ============================================================
   Korea SMA 메일서버 — 디자인 시스템
   ------------------------------------------------------------
   Color   : Ink #14171F · Ink-soft #5B6272 · Primary #2E86AB
             Primary-dark #1F5E7A · Accent #4FB3E0 · Canvas #F3F6FA
             Surface #FFFFFF · Line #E4E8F0
             Success #1F9D55 · Warn #B7791F · Danger #D6455A
   Type    : Pretendard (본문/제목 공통, 한글 가독성 우선) +
             JetBrains Mono (포트/IP/ID 같은 데이터 값)
   Layout  : 고정폭 사이드바(그리드) + 카드 콘텐츠, 모바일은 하단 탭바
   Signature: 상태 배지의 은은한 펄스 점 — 메일 서버 "관제" 느낌을 위한 장치
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');

:root {
    --ink: #14171f;
    --ink-soft: #5b6272;
    --ink-faint: #9aa1af;

    --primary: #2e86ab;
    --primary-dark: #1f5e7a;
    --accent: #4fb3e0;

    --canvas: #f3f6fa;
    --surface: #ffffff;
    --line: #e4e8f0;

    --success: #1f9d55;
    --success-bg: #e7f8ee;
    --warn: #b7791f;
    --warn-bg: #fdf2df;
    --danger: #d6455a;
    --danger-bg: #fdeaee;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(20,23,31,0.04), 0 8px 24px rgba(20,23,31,0.05);
    --shadow-lift: 0 10px 30px rgba(20,23,31,0.10);

    /* 구 클래스 호환용 alias (기존 페이지 코드가 참조) */
    --sma-blue: var(--primary);
    --sma-blue-dark: var(--primary-dark);
    --sma-gray: var(--ink-soft);
    --sma-gray-light: var(--canvas);
    --sma-white: var(--surface);
    --sma-danger: var(--danger);
    --sma-radius: var(--radius);
    --sma-shadow: var(--shadow);
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Pretendard', -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    background: var(--canvas);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

code, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------------- 상단바 ---------------- */
.sma-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    padding: 12px 24px;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 40;
}
.sma-topbar .brand { display: flex; align-items: center; gap: 10px; }
.sma-topbar .brand img { height: 30px; }
.sma-topbar .brand span { font-weight: 700; color: var(--ink); font-size: 16px; letter-spacing: -0.01em; }

/* ---------------- 레이아웃 (Grid 고정폭 사이드바) ---------------- */
.sma-layout { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 57px); }

.sma-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 18px 12px;
    overflow: hidden;
}
.sma-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.sma-sidebar a svg { flex: none; width: 18px; height: 18px; opacity: 0.75; }
.sma-sidebar a:hover {
    background: var(--canvas);
    color: var(--ink);
    text-decoration: none;
}
.sma-sidebar a.active {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(46,134,171,0.28);
}
.sma-sidebar a.active svg { opacity: 1; }

.sma-content { min-width: 0; padding: 28px; overflow-x: auto; }

/* ---------------- 카드 ---------------- */
.sma-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}
.sma-card h2 {
    margin: 0 0 16px;
    font-size: 16px;
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ---------------- 표 ---------------- */
table.sma-table { width: 100%; border-collapse: collapse; }
table.sma-table th, table.sma-table td {
    text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
table.sma-table th {
    color: var(--ink-faint); font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: transparent;
}
table.sma-table tr:last-child td { border-bottom: none; }
table.sma-table tr:hover td { background: var(--canvas); }

/* ---------------- 버튼 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b7364a; }
.btn.secondary { background: var(--canvas); color: var(--ink-soft); border: 1px solid var(--line); }
.btn.secondary:hover { background: #eaeef4; color: var(--ink); }

/* ---------------- 폼 ---------------- */
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 14px;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,179,224,0.15);
    outline: none;
}
label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }

/* ---------------- 로그인 (스플릿 카드) ---------------- */
.sma-login-wrap {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    padding: 24px;
    background:
        radial-gradient(1000px 500px at 15% -10%, rgba(79,179,224,0.14), transparent),
        radial-gradient(800px 500px at 110% 110%, rgba(46,134,171,0.10), transparent),
        var(--canvas);
}
.sma-login-box {
    display: flex;
    width: 100%;
    max-width: 900px;
    min-height: 560px;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-lift);
    overflow: hidden;
    border: 1px solid var(--line);
}

.sma-login-side {
    flex: 1.05;
    position: relative;
    padding: 44px 40px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        radial-gradient(420px 320px at 90% 0%, rgba(255,255,255,0.14), transparent),
        radial-gradient(360px 360px at 100% 100%, rgba(255,255,255,0.10), transparent),
        linear-gradient(155deg, var(--primary-dark) 0%, var(--primary) 55%, var(--accent) 130%);
    overflow: hidden;
}
.sma-login-badge {
    display: inline-flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.22);
    padding: 8px 14px 8px 8px;
    border-radius: 999px;
    width: fit-content;
    margin-bottom: 34px;
}
.sma-login-badge img { height: 26px; width: 26px; border-radius: 50%; background: #fff; padding: 3px; display: block; }
.sma-login-badge span { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }

.sma-login-side h1 {
    font-size: 26px;
    line-height: 1.4;
    font-weight: 800;
    margin: 0 0 14px;
    letter-spacing: -0.01em;
}
.sma-login-side p.lead {
    font-size: 14px;
    line-height: 1.7;
    color: rgba(255,255,255,0.86);
    margin: 0 0 34px;
    max-width: 360px;
}
.sma-login-stats {
    display: flex;
    gap: 26px;
    flex-wrap: wrap;
}
.sma-login-stats .stat b { display: block; font-size: 18px; font-weight: 800; }
.sma-login-stats .stat span { font-size: 12px; color: rgba(255,255,255,0.75); }

.sma-login-main {
    flex: 1;
    padding: 48px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.sma-login-main h2 { font-size: 22px; font-weight: 800; color: var(--ink); margin: 0 0 6px; letter-spacing: -0.01em; }
.sma-login-main .sub { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 26px; }
.sma-login-main .btn { width: 100%; padding: 13px; font-size: 15px; margin-top: 6px; }
.sma-login-main .switch-link { text-align: center; margin-top: 18px; font-size: 13px; color: var(--ink-soft); }
.sma-login-notice {
    margin-top: 26px;
    background: var(--warn-bg);
    border: 1px solid #f3dfae;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 12.5px;
    color: #8a6100;
    line-height: 1.6;
}

/* ---------------- 상태 배지 (시그니처: 펄스 점) ---------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px 4px 8px; border-radius: 20px; font-size: 12px; font-weight: 700;
}
.badge::before {
    content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none;
}
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.ok::before { animation: sma-pulse 1.8s ease-in-out infinite; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--danger-bg); color: var(--danger); }

@keyframes sma-pulse {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    50% { box-shadow: 0 0 0 4px transparent; opacity: 0.55; }
}

.watermark-preview {
    border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px;
    font-size: 12px; color: var(--ink-faint);
}

/* ---------------- 받는사람 칩(chip) 입력 ---------------- */
.sma-chip-input {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-bottom: 14px;
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sma-chip-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,179,224,0.15);
}
.sma-chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sma-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--canvas);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 13px;
    padding: 5px 6px 5px 10px;
    border-radius: 999px;
}
.sma-chip button {
    background: none; border: none; cursor: pointer;
    color: var(--ink-faint); font-size: 15px; line-height: 1;
    padding: 2px 4px;
    border-radius: 50%;
}
.sma-chip button:hover { background: var(--line); color: var(--ink); }
.sma-chip-textinput {
    flex: 1; min-width: 160px;
    border: none !important; outline: none;
    padding: 6px 4px !important; margin: 0 !important;
    font-size: 14px;
    background: transparent;
}
.sma-chip-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lift);
    max-height: 260px; overflow-y: auto;
    z-index: 30;
}
.sma-chip-option {
    padding: 9px 12px; cursor: pointer; font-size: 13.5px;
    display: flex; flex-direction: column; gap: 1px;
}
.sma-chip-option b { font-weight: 600; color: var(--ink); }
.sma-chip-option span { font-size: 12px; color: var(--ink-faint); }
.sma-chip-option:hover { background: var(--canvas); }

/* ---------------- 모바일 / PWA 대응 ---------------- */
.sma-hide-mobile { display: inherit; }
.sma-bottom-nav { display: none; }

@media (max-width: 720px) {
    .sma-hide-mobile { display: none !important; }
    .sma-layout { grid-template-columns: 1fr; }

    .sma-topbar { padding: 10px 14px; }
    .sma-topbar .brand span { font-size: 15px; }
    .sma-content { padding: 16px !important; }
    .sma-card { padding: 16px; border-radius: 12px; }

    table.sma-table { display: block; }
    table.sma-table thead { display: none; }
    table.sma-table tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
    table.sma-table td { display: block; border: none; padding: 3px 0; }

    .sma-login-wrap { padding: 0; align-items: stretch; }
    .sma-login-box { flex-direction: column; max-width: none; min-height: 100dvh; min-height: 100vh; border-radius: 0; border: none; box-shadow: none; }
    .sma-login-side { flex: none; padding: 32px 24px 26px; }
    .sma-login-side h1 { font-size: 21px; }
    .sma-login-side p.lead { display: none; }
    .sma-login-stats { display: none; }
    .sma-login-badge { margin-bottom: 4px; }
    .sma-login-main { flex: 1; padding: 30px 26px; justify-content: flex-start; padding-top: 34px; }

    .sma-bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--line);
        padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(20,23,31,0.06);
        z-index: 50;
    }
    .sma-bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 10.5px;
        color: var(--ink-faint);
        text-decoration: none;
        padding: 4px 0;
    }
    .sma-bottom-nav a .ic { font-size: 20px; line-height: 1; }
    .sma-bottom-nav a.active { color: var(--primary-dark); font-weight: 700; }
}

/* ---- 휴대폰(아이폰 15 Pro 등 ~430px): 입력 확대 방지 + 여백 미세조정 ---- */
@media (max-width: 480px) {
    .sma-login-main input[type=text],
    .sma-login-main input[type=password] {
        font-size: 16.5px; /* iOS 자동 확대 방지 */
        padding: 14px 15px;
    }
    .sma-login-main h2 { font-size: 20px; }
}
