/* =============================================================
   AILicet 디자인 시스템 (aicura.css)
   브랜드: Primary #0F6E56 / Secondary #1D9E75
   서버렌더링(Admin/대행사/고객) 공통 스타일
   ============================================================= */

:root {
    /* 브랜드 */
    --color-primary: #0F6E56;
    --color-primary-dark: #0A5241;
    --color-primary-soft: #E6F2ED;
    --color-secondary: #1D9E75;
    --color-secondary-soft: #E4F5EE;

    /* 뉴트럴 */
    --color-bg: #F4F6F5;
    --color-surface: #FFFFFF;
    --color-border: #E3E8E6;
    --color-border-strong: #CBD4D0;
    --color-text: #1B2420;
    --color-text-muted: #66756F;
    --color-text-soft: #98A5A0;

    /* 시맨틱 */
    --color-success: #1D9E75;
    --color-warning: #C9820B;
    --color-danger: #D64545;
    --color-info: #2F80C4;

    /* 타이포 */
    --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
        'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;

    /* 간격·모양 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 40, 32, 0.06);
    --shadow-md: 0 4px 16px rgba(16, 40, 32, 0.08);

    --sidebar-width: 240px;
    --topbar-height: 60px;
}

/* ---------- 리셋 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
    outline: 3px solid var(--color-secondary);
    outline-offset: 3px;
}

/* ---------- 앱 셸(사이드바 + 상단바 + 콘텐츠) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary-dark);
    color: #DCEAE4;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    z-index: 30;
}
.sidebar__brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar__brand-mark {
    width: 28px; height: 28px;
    display: block;
}
.sidebar__role {
    padding: 12px 20px 6px;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}
.sidebar__nav { flex: 1; overflow-y: auto; padding: 4px 12px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #C6D8D1;
    font-weight: 500;
    margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--color-secondary); color: #fff; }
.nav-item__icon { width: 18px; text-align: center; opacity: 0.9; }

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__context { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__title { font-size: 16px; font-weight: 600; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.topbar__avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    display: grid; place-items: center;
    font-weight: 700;
}
.topbar__meta { text-align: right; line-height: 1.25; }
.topbar__name { font-weight: 600; font-size: 13px; }
.topbar__role { font-size: 11px; color: var(--color-text-muted); }
.topbar__bell {
    position: relative;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: var(--color-text);
    font-size: 20px;
    text-decoration: none;
}
.topbar__notification-count {
    position: absolute;
    top: 1px;
    right: -2px;
    min-width: 18px;
    padding: 1px 5px;
    font-size: 11px;
}
.nav-toggle, .sidebar-backdrop { display: none; }

.content { padding: 24px; flex: 1; }
.page-head { margin-bottom: 20px; }
.page-head__title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-head__desc { color: var(--color-text-muted); margin: 0; }

/* ---------- 카드 ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card__head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    display: flex; align-items: center; justify-content: space-between;
}
.card__body { padding: 20px; }
.page-head--actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.detail-grid--balanced { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.inline-action-form { display: flex; gap: 8px; }
.module-create-form { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 12px; align-items: end; }

/* 통계 카드 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.stat__label { color: var(--color-text-muted); font-size: 13px; margin-bottom: 6px; }
.stat__value { font-size: 26px; font-weight: 700; color: var(--color-text); }
.stat__delta { font-size: 12px; margin-top: 4px; }
.stat__delta.up { color: var(--color-success); }
.stat__delta.down { color: var(--color-danger); }

/* ---------- 버튼 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--color-border-strong); color: var(--color-text); }
.btn--ghost:hover { background: var(--color-bg); }
.btn--block { width: 100%; justify-content: center; padding: 12px; }

/* ---------- 배지 ---------- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}
.badge--success { background: var(--color-secondary-soft); color: var(--color-primary-dark); }
.badge--warning { background: #FBF0DA; color: var(--color-warning); }
.badge--danger { background: #FBE3E3; color: var(--color-danger); }
.badge--muted { background: #EDF1EF; color: var(--color-text-muted); }

/* ---------- 폼 ---------- */
.field { margin-bottom: 16px; }
.field__label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    color: var(--color-text);
}
.input:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px var(--color-secondary-soft);
}

/* ---------- 알림 ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert--danger { background: #FBE3E3; border-color: #F3C6C6; color: #A83232; }
.alert--info { background: #E7F1FB; border-color: #C9E0F5; color: #245C8C; }

/* ---------- 로그인 ---------- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary) 60%, var(--color-secondary));
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
}
.auth-card__brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 22px; font-weight: 700; color: var(--color-primary);
    margin-bottom: 4px;
}
.auth-card__brand-mark {
    width: 34px; height: 34px;
    display: block;
}
.auth-card__sub { color: var(--color-text-muted); margin: 0 0 24px; font-size: 13px; }

/* ---------- 탭 ---------- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--color-border);
}
.tab-btn {
    border: none;
    background: none;
    padding: 10px 18px;
    font-size: 14px;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab-btn:hover { color: var(--color-primary); }
.tab-btn.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 600;
}

/* ---------- 유틸 ---------- */
.muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* AG Grid 컨테이너 높이 기본값 */
.grid-wrap { width: 100%; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease-out; box-shadow: var(--shadow-md); }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 20;
        border: 0;
        background: rgba(16, 40, 32, 0.4);
    }
    body.is-navigation-open { overflow: hidden; }
    body.is-navigation-open .sidebar { transform: translateX(0); }
    body.is-navigation-open .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .nav-toggle { display: inline-flex; align-items: center; gap: 7px; min-width: 44px; min-height: 44px; padding: 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-text); cursor: pointer; }
    .nav-toggle__icon, .nav-toggle__icon::before, .nav-toggle__icon::after { width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
    .nav-toggle__icon { position: relative; display: block; }
    .nav-toggle__icon::before, .nav-toggle__icon::after { position: absolute; left: 0; content: ''; }
    .nav-toggle__icon::before { top: -6px; }
    .nav-toggle__icon::after { top: 6px; }
    .content { padding: 20px; }
    .page-head--actions { align-items: stretch; flex-direction: column; }
    .form-grid, .detail-grid, .detail-grid--balanced { grid-template-columns: 1fr; }
    .inline-action-form { flex-wrap: wrap; }
    .inline-action-form .input { min-width: min(100%, 220px); flex: 1 1 220px; }
}

@media (max-width: 640px) {
    .topbar { height: auto; min-height: var(--topbar-height); padding: 8px 12px; gap: 8px; }
    .topbar__user { gap: 6px; }
    .topbar__meta, .topbar__avatar { display: none; }
    .content { padding: 16px; }
    .card__head, .card__body { padding: 14px 16px; }
    .page-head__title { font-size: 20px; }
    .page-head--actions > .btn, .page-head--actions > a.btn { width: 100%; justify-content: center; }
    .btn { min-height: 44px; }
    .input { font-size: 16px; }
    .stat-grid { grid-template-columns: 1fr; }
    .module-create-form { grid-template-columns: 1fr; }
}
