/* ============================================================
   TPTVK - Common / Shared Styles
   공통 스타일 / Style chung
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-main);
    background: var(--light-gray);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.number, .metric { font-family: var(--font-num); }

a { text-decoration: none; color: inherit; }
button { font-family: var(--font-main); cursor: pointer; }
input, select, textarea { font-family: var(--font-main); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    line-height: 1;
}
.btn:active { transform: scale(0.97); }

.btn-primary   { background: var(--blue);        color: #fff; }
.btn-primary:hover { background: var(--blue-hover); box-shadow: var(--shadow-md); }

.btn-secondary {
    background: var(--white);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--light-gray); border-color: var(--border-dark); }

.btn-success   { background: var(--status-green); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }

.btn-danger    { background: var(--status-red);  color: #fff; }
.btn-danger:hover  { background: var(--status-red-h); }

.btn-ghost {
    background: none;
    color: var(--text-secondary);
    border: none;
}
.btn-ghost:hover { background: var(--light-gray); color: var(--text-primary); }

.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-lg  { padding: 13px 26px; font-size: 15px; }
.btn-icon{ padding: 8px; border-radius: var(--radius); }

/* ── Form Elements ───────────────────────────────────────── */
.form-group  { margin-bottom: 18px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-label  {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}
.form-label .vn {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}
.form-label .kr {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-secondary);
    display: block;
}
.form-hint { font-size: 11px; color: var(--text-secondary); margin-top: 5px; }

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    outline: none;
    background: var(--white);
    color: var(--text-primary);
    transition: var(--transition-fast);
}
.form-input:focus,
.form-select:focus  { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.form-input::placeholder { color: var(--text-muted); }
.form-input[readonly] { background: var(--light-gray); cursor: not-allowed; }
.form-select { cursor: pointer; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid rgba(0,0,0,0.04);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}
.card-title .vn {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.card-title .kr {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 1px;
}
.card-actions { display: flex; gap: 8px; align-items: center; }

/* ── Table ───────────────────────────────────────────────── */
.table-container { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--light-gray); }
th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    user-select: none;
}
th .vn  { display: block; font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
th .kr  { display: block; font-size: 9px; font-weight: 400; text-transform: none; color: var(--text-muted); margin-top: 1px; }
th:hover { background: #edf2f7; cursor: pointer; }
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-primary);
    vertical-align: middle;
}
tbody tr { transition: var(--transition-fast); }
tbody tr:hover { background: #f7fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ── Status Badges ───────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.status-badge.progress   { background: rgba(37,99,235,0.10);  color: var(--status-blue);   }
.status-badge.delayed    { background: rgba(239,68,68,0.10);   color: var(--status-red);    }
.status-badge.comment    { background: rgba(249,115,22,0.10);  color: var(--status-orange); }
.status-badge.completed  { background: rgba(107,114,128,0.10); color: var(--status-gray);   }
.status-badge.admin      { background: rgba(239,68,68,0.10);   color: var(--status-red);    }
.status-badge.success    { background: rgba(34,197,94,0.10);   color: var(--status-green);  }

/* ── Toggle Switch ───────────────────────────────────────── */
.toggle-switch {
    position: relative;
    width: 44px; height: 24px;
    background: var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.25s;
    flex-shrink: 0;
}
.toggle-switch.active { background: var(--status-green); }
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-xs);
    transition: left 0.25s;
}
.toggle-switch.active::after { left: 22px; }

/* ── Toast Notification ──────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 28px; right: 28px;
    background: white;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9000;
    transform: translateY(120px);
    opacity: 0;
    transition: var(--transition);
    min-width: 260px;
    max-width: 380px;
    border-left: 4px solid var(--status-green);
}
.toast.error   { border-left-color: var(--status-red); }
.toast.warning { border-left-color: var(--status-orange); }
.toast.active  { transform: translateY(0); opacity: 1; }
.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-icon.success { color: var(--status-green); }
.toast-icon.error   { color: var(--status-red); }
.toast-icon.warning { color: var(--status-orange); }
.toast-message { font-weight: 600; font-size: 13px; line-height: 1.4; }

/* ── Modal ───────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modal-in 0.25s ease;
}
.modal-content.modal-lg { max-width: 680px; }
@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: sticky; top: 0;
    background: white;
    z-index: 1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title      { font-size: 18px; font-weight: 700; line-height: 1.3; }
.modal-title.vn   { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-title.kr   { font-size: 12px; font-weight: 400; color: var(--text-secondary); margin-top: 3px; }
.modal-close {
    background: none; border: none; font-size: 20px;
    color: var(--text-secondary); cursor: pointer; padding: 4px;
    border-radius: var(--radius-sm); transition: var(--transition-fast);
    flex-shrink: 0;
}
.modal-close:hover { background: var(--light-gray); color: var(--text-primary); }
.modal-body   { padding: 22px 24px; }
.modal-footer { padding: 18px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 20px; flex-wrap: wrap; }
.page-btn {
    padding: 7px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition-fast);
}
.page-btn:hover   { background: var(--light-gray); border-color: var(--border-dark); }
.page-btn.active  { background: var(--blue); color: white; border-color: var(--blue); }

/* ── Grid Layouts ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ── Utilities ───────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted   { color: var(--text-secondary); }
.text-sm      { font-size: 12px; }
.font-bold    { font-weight: 700; }

/* ── Bilingual Label ─────────────────────────────────────── */
.bi-label .vn { font-size: 13px; font-weight: 700; color: var(--text-primary); display: block; }
.bi-label .kr { font-size: 10px; font-weight: 400; color: var(--text-secondary); display: block; margin-top: 1px; }

/* ── Responsive Helpers ──────────────────────────────────── */
@media (max-width: 768px) {
    /* 폼 */
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-input, .form-select { font-size: 16px; } /* iOS 자동 줌 방지 */

    /* 카드 */
    .card { padding: 14px; }
    .card-header { flex-wrap: wrap; gap: 10px; }

    /* 모달 */
    .modal-body   { padding: 16px; }
    .modal-header { padding: 16px; }
    .modal-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn { flex: 1; justify-content: center; min-width: 0; }

    /* 버튼 */
    .btn { padding: 10px 14px; font-size: 13px; }

    /* 테이블 */
    th { padding: 10px 10px; font-size: 11px; }
    td { padding: 11px 10px; font-size: 12px; }

    /* 토스트 */
    .toast { bottom: calc(62px + env(safe-area-inset-bottom) + 10px); left: 12px; right: 12px; width: auto; }

    /* 페이지네이션 */
    .pagination { gap: 3px; }
    .page-btn   { padding: 6px 10px; font-size: 12px; }

    /* 상태 배지 */
    .status-badge { font-size: 10px; padding: 3px 7px; }
}

@media (max-width: 480px) {
    .form-input, .form-select { padding: 10px 12px; }
    .btn { padding: 9px 12px; }
    .modal-footer .btn { font-size: 12px; }
    th { padding: 8px; font-size: 10px; }
    td { padding: 9px 8px; font-size: 11px; }
}

/* ── 사이드바 메뉴 승인 대기 배지 ────────────────────────── */
.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #F97316;
    color: white;
    font-size: 10px;
    font-weight: 800;
    border-radius: 999px;
    margin-left: auto;
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
    0%,100% { opacity: 1; }
    50%      { opacity: .6; }
}
