/* ============================================================
   4M Change Management System - Styles
   ============================================================ */
:root {
    --primary: #1e3a5f;
    --primary-light: #2a5a8f;
    --primary-dark: #0f2440;
    --accent: #3b82f6;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --sidebar-width: 220px;
    --radius: 8px;
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Login ── */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}
.login-card {
    background: #fff; border-radius: 12px; padding: 40px;
    width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 {
    font-size: 48px; font-weight: 700; color: var(--primary);
    letter-spacing: 4px; margin-bottom: 8px;
}
.login-header p { color: var(--gray-600); font-size: 15px; }
.login-header .vi { font-size: 13px; color: var(--gray-400); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--gray-600); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: 14px; font-family: inherit;
    transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border: none; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer;
    font-family: inherit; transition: all .2s; text-decoration: none;
}
.btn:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
    background: #fff; color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; text-align: center; }

/* ── Layout ── */
#main-app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width); background: var(--primary-dark);
    color: #fff; display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
}
.sidebar-header {
    padding: 20px; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-header h2 { font-size: 28px; letter-spacing: 3px; font-weight: 700; }
.sidebar-subtitle { font-size: 12px; opacity: .7; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: rgba(255,255,255,.7);
    text-decoration: none; transition: all .2s;
    border-left: 3px solid transparent; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
    background: rgba(255,255,255,.12); color: #fff;
    border-left-color: var(--accent);
}
.nav-item small { font-size: 10px; opacity: .6; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.badge {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: var(--danger); color: #fff; font-size: 11px;
    padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; flex-direction: column; }
.user-info span { font-size: 13px; font-weight: 500; }
.user-info small { font-size: 11px; opacity: .6; }

.content {
    flex: 1; margin-left: var(--sidebar-width); padding: 24px 32px;
    min-height: 100vh;
}

/* ── Page Header ── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.page-header h1 small { font-size: 13px; color: var(--gray-400); font-weight: 400; display: block; }
.page-actions { display: flex; gap: 8px; }

/* ── Cards ── */
.card {
    background: #fff; border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stats Grid ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: #fff; border-radius: var(--radius); padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    border-left: 4px solid var(--accent);
}
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.primary { border-left-color: var(--primary); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--gray-800); }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.stat-label small { display: block; font-size: 11px; color: var(--gray-400); }

/* ── Table ── */
.table-container { overflow-x: auto; }
table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
thead { background: var(--gray-50); }
th {
    padding: 10px 14px; text-align: left; font-weight: 600;
    color: var(--gray-600); border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}
td {
    padding: 10px 14px; border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tr:hover { background: var(--gray-50); }
.clickable-row { cursor: pointer; }

/* ── Status Badges ── */
.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
}
.status-DRAFT { background: var(--gray-200); color: var(--gray-600); }
.status-SUBMITTED { background: #dbeafe; color: #1d4ed8; }
.status-TEAM_REVIEW, .status-QUALITY_REVIEW { background: #fef3c7; color: #92400e; }
.status-APPROVAL_PENDING { background: #fed7aa; color: #9a3412; }
.status-APPROVED { background: #d1fae5; color: #065f46; }
.status-IMPLEMENTING, .status-DOC_UPDATE { background: #e0e7ff; color: #3730a3; }
.status-COMPLETED { background: #d1fae5; color: #065f46; }
.status-REJECTED { background: #fecaca; color: #991b1b; }
.status-CANCELLED { background: var(--gray-200); color: var(--gray-500); }
.status-REQUESTED { background: #dbeafe; color: #1d4ed8; }
.status-REVIEWING { background: #fef3c7; color: #92400e; }
.status-IN_PROGRESS { background: #e0e7ff; color: #3730a3; }
.status-RESTORED { background: #d1fae5; color: #065f46; }

.type-badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.type-MAN { background: #ede9fe; color: #5b21b6; }
.type-MACHINE { background: #fce7f3; color: #9d174d; }
.type-MATERIAL { background: #ccfbf1; color: #115e59; }
.type-METHOD { background: #fef9c3; color: #854d0e; }

/* ── Approval Timeline ── */
.timeline { padding: 16px 0; }
.timeline-step {
    display: flex; gap: 16px; padding: 16px 0;
    position: relative;
}
.timeline-step:not(:last-child)::after {
    content: ''; position: absolute; left: 19px; top: 52px;
    width: 2px; height: calc(100% - 36px); background: var(--gray-200);
}
.timeline-step.step-APPROVED:not(:last-child)::after { background: var(--success); }
.timeline-step.step-ACTIVE:not(:last-child)::after { background: var(--accent); }

.timeline-dot {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0; z-index: 1;
}
.step-PENDING .timeline-dot { background: var(--gray-200); }
.step-ACTIVE .timeline-dot { background: var(--accent); color: #fff; animation: pulse 2s infinite; }
.step-APPROVED .timeline-dot { background: var(--success); color: #fff; }
.step-REJECTED .timeline-dot { background: var(--danger); color: #fff; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,.4); }
    50% { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
}

.timeline-content { flex: 1; }
.timeline-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.timeline-subtitle { font-size: 12px; color: var(--gray-500); }
.timeline-approvers { margin-top: 8px; }
.approver-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; font-size: 13px;
}
.approver-status {
    width: 20px; height: 20px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 11px;
}
.approver-PENDING { background: var(--gray-200); }
.approver-APPROVED { background: var(--success); color: #fff; }
.approver-REJECTED { background: var(--danger); color: #fff; }

/* ── Filter Bar ── */
.filter-bar {
    display: flex; gap: 12px; margin-bottom: 20px;
    flex-wrap: wrap; align-items: center;
}
.filter-bar select, .filter-bar input {
    padding: 7px 12px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: 13px; font-family: inherit;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
    background: #fff; border-radius: 12px; width: 90%; max-width: 600px;
    max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--gray-400); padding: 4px;
}
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--gray-200);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Detail Info ── */
.detail-grid {
    display: grid; grid-template-columns: 140px 1fr; gap: 0;
    border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden;
}
.detail-label {
    padding: 10px 14px; background: var(--gray-50); font-weight: 500;
    color: var(--gray-600); border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
}
.detail-value {
    padding: 10px 14px; border-bottom: 1px solid var(--gray-200);
}
.detail-grid > :nth-last-child(-n+2) { border-bottom: none; }

/* ── Empty State ── */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--gray-400);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Toast ── */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px; border-radius: var(--radius);
    color: #fff; font-size: 14px; z-index: 2000;
    animation: slideIn .3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--accent); }

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ── Responsive ── */
/* ── Language Switcher ── */
.lang-switcher-login {
    display: flex; justify-content: center; gap: 6px;
    margin-bottom: 20px;
}
.lang-switcher-sidebar {
    display: flex; justify-content: center; gap: 4px;
    padding: 8px 16px 4px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.lang-btn {
    background: transparent; border: 1px solid rgba(255,255,255,.3);
    color: rgba(255,255,255,.6); padding: 3px 10px; border-radius: 4px;
    font-size: 11px; font-weight: 600; cursor: pointer;
    transition: all .2s; font-family: inherit;
}
.lang-btn:hover { border-color: rgba(255,255,255,.6); color: #fff; }
.lang-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lang-switcher-login .lang-btn {
    border-color: var(--gray-300); color: var(--gray-600);
}
.lang-switcher-login .lang-btn:hover { border-color: var(--primary); color: var(--primary); }
.lang-switcher-login .lang-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2 { font-size: 18px; }
    .sidebar-subtitle, .nav-item span:not(.nav-icon), .user-info { display: none; }
    .nav-item { justify-content: center; padding: 14px; }
    .content { margin-left: 60px; padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; gap: 0; }
    .detail-grid { grid-template-columns: 100px 1fr; }
}
