﻿/* =============================================
   Common.css — SignFlow 공통 스타일
   수정 금지: 모든 페이지가 공유하는 기반 스타일
   ============================================= */

/* CSS 변수 (라이트 테마) */
:root {
    --primary:           #6366f1;
    --primary-hover:     #4f46e5;
    --primary-light:     rgba(99, 102, 241, 0.1);
    --foreground:        #0f172a;
    --foreground-muted:  #64748b;
    --background:        #f8fafc;
    --card:              #ffffff;
    --border:            #e2e8f0;
    --input-border:      #cbd5e1;
    --sidebar-width:     256px;
    --header-height:     64px;
    --destructive:       #ef4444;
    --destructive-light: rgba(239, 68, 68, 0.1);
    --success:           #22c55e;
    --warning:           #f59e0b;
    --muted-bg:          #f1f5f9;
    --shadow-sm:         0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:         0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --radius:            8px;
    --radius-lg:         12px;
}

/* 리셋 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-size: 14px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Noto Sans KR', sans-serif; color: var(--foreground); background: var(--background); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* 레이아웃 */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s ease;
}

.app-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    z-index: 50;
}

.app-main {
    flex: 1;
    padding: 32px;
}

/* 사이드바 */
.sidebar-logo {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 18px;
    font-weight: 700;
}
.sidebar-logo-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 900; font-size: 14px;
    flex-shrink: 0;
}
.sidebar-logo-text { color: var(--foreground); }
.sidebar-logo-text span { color: var(--primary); }

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--foreground-muted);
    transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--muted-bg); color: var(--foreground); }
.sidebar-nav a.active { background: var(--primary-light); color: var(--primary); }
.sidebar-nav a svg, .sidebar-nav a i { width: 18px; height: 18px; font-size: 16px; flex-shrink: 0; }

.sidebar-bottom {
    padding: 12px;
    border-top: 1px solid var(--border);
}

/* 헤더 */
.header-menu-btn {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    color: var(--foreground-muted);
}
.header-title { font-size: 15px; font-weight: 600; flex: 1; }
.header-user {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px;
}
.header-user-name { font-weight: 600; color: var(--foreground); }
.header-user-role {
    font-size: 11px; color: var(--foreground-muted);
    background: var(--muted-bg);
    padding: 2px 8px; border-radius: 20px;
}
.btn-logout {
    background: none; border: 1px solid var(--border);
    padding: 5px 12px; border-radius: var(--radius);
    font-size: 12px; color: var(--foreground-muted);
    transition: background .15s, border-color .15s;
}
.btn-logout:hover { background: var(--muted-bg); border-color: var(--input-border); color: var(--foreground); }

/* 사이드바 오버레이 (모바일) */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

/* 카드 */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 24px; }

/* 버튼 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13.5px; font-weight: 500;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, opacity .15s;
    cursor: pointer;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--muted-bg); color: var(--foreground); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger    { background: var(--destructive); color: #fff; border-color: var(--destructive); }
.btn-danger:hover { background: #dc2626; }
.btn-outline   { background: transparent; color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { background: var(--muted-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 폼 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--foreground); }
.form-label.required::after { content: ' *'; color: var(--destructive); font-weight: 700; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-size: 13.5px; background: #fff; color: var(--foreground);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-control.is-invalid { border-color: var(--destructive); }
.form-hint { font-size: 12px; color: var(--foreground-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--destructive); margin-top: 4px; }
.input-group { position: relative; }
.input-group .input-icon {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--foreground-muted); pointer-events: none; font-size: 15px;
}
.input-group .form-control { padding-left: 36px; }

/* 테이블 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead tr { background: var(--muted-bg); }
th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--foreground-muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td { padding: 12px 16px; border-top: 1px solid var(--border); color: var(--foreground); vertical-align: middle; }
tr:hover td { background: var(--muted-bg); }
.td-muted { font-size: 12px; color: var(--foreground-muted); }

/* 배지 */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 500;
}
.badge-draft   { background: #f1f5f9; color: #64748b; }
.badge-sent    { background: #dbeafe; color: #1d4ed8; }
.badge-unread  { background: #fef3c7; color: #b45309; }
.badge-reading { background: #fce7f3; color: #be185d; }
.badge-signed  { background: #dcfce7; color: #15803d; }
.badge-active  { background: #dcfce7; color: #15803d; }
.badge-inactive{ background: #f1f5f9; color: #64748b; }
.badge-resigned{ background: #fee2e2; color: #b91c1c; }

/* KPI 카드 */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.kpi-card { padding: 20px; }
.kpi-label { font-size: 12px; color: var(--foreground-muted); margin-bottom: 6px; font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--foreground); line-height: 1; }
.kpi-desc  { font-size: 11px; color: var(--foreground-muted); margin-top: 4px; }

/* 페이지 헤더 */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--foreground-muted); margin-top: 2px; }

/* 알림 */
.alert {
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: 13.5px; display: flex; align-items: flex-start; gap: 8px;
}
.alert-danger  { background: var(--destructive-light); border: 1px solid rgba(239,68,68,.2); color: #b91c1c; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.2); color: #15803d; }
.alert-info    { background: rgba(99,102,241,.08); border: 1px solid rgba(99,102,241,.2); color: var(--primary); }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.2); color: #92400e; }

/* 모달 */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal {
    background: var(--card); border-radius: var(--radius-lg);
    width: 100%; max-width: 520px;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    display: flex; flex-direction: column;
    max-height: 90vh; overflow: hidden;
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--foreground-muted); padding: 2px; line-height: 1; }
.modal-close:hover { color: var(--foreground); }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}

/* 검색바 */
.search-bar {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.search-bar .form-control { min-width: 200px; flex: 1; }

/* 빈 상태 */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--foreground-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--foreground); }
.empty-state p { font-size: 13px; }

/* 페이지네이션 */
.pagination {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    padding: 20px 0;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius);
    font-size: 13px; border: 1px solid var(--border); color: var(--foreground-muted);
    transition: background .15s;
}
.pagination a:hover { background: var(--muted-bg); color: var(--foreground); }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* Toast */
#toast-container {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9999;
}
.toast {
    background: #1e293b; color: #f8fafc;
    padding: 12px 18px; border-radius: var(--radius);
    font-size: 13.5px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
    box-shadow: var(--shadow-md);
    animation: toastIn .25s ease;
    min-width: 240px; max-width: 360px;
}
.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error   { border-left: 4px solid var(--destructive); }
.toast.toast-info    { border-left: 4px solid var(--primary); }
.toast.toast-warning { border-left: 4px solid var(--warning); }
@keyframes toastIn { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }

/* 반응형 */
@media (max-width: 1023px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-content { margin-left: 0; }
    .sidebar-overlay.show { display: block; }
    .header-menu-btn { display: flex; }
    .app-main { padding: 16px; }
}
@media (max-width: 640px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }

    /* 헤더 사용자 영역 축소 */
    .header-user-role { display: none; }
    .header-user-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .btn-logout { padding: 4px 8px; font-size: 11px; }
    .app-header { padding: 0 12px; gap: 8px; }
    .header-title { font-size: 13px; }

    /* 검색바 인풋 전체 너비 */
    .search-bar .form-control { min-width: 0; flex: 1 1 100%; }
    .search-bar { gap: 6px; }

    /* 모달 패딩 축소 */
    .modal-body { padding: 16px; }
    .modal-header, .modal-footer { padding: 14px 16px; }

    /* 토스트 모바일 위치 */
    #toast-container { left: 12px; right: 12px; bottom: 12px; }
    .toast { min-width: 0; max-width: 100%; width: 100%; }

    /* 페이지네이션 터치 영역 */
    .pagination a, .pagination span { width: 36px; height: 36px; }

    /* 버튼 터치 대응 */
    .btn { min-height: 36px; }
    .btn-sm { min-height: 30px; }

    /* 카드 헤더 패딩 */
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
}
