/* ===== OZTECH 통합관제 디자인 시스템 ===== */

/* --- Web Fonts: ATOZ --- */
@font-face {
    font-family: 'ATOZ';
    src: url('/static/font/ATOZ-3Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'ATOZ';
    src: url('/static/font/ATOZ-4Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'ATOZ';
    src: url('/static/font/ATOZ-5Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'ATOZ';
    src: url('/static/font/ATOZ-6SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'ATOZ';
    src: url('/static/font/ATOZ-7Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --- Design Tokens --- */
:root {
    /* Primary */
    --primary-900: #1e3a5f;
    --primary-800: #1e40af;
    --primary-700: #1d4ed8;
    --primary-600: #2563eb;
    --primary-500: #3b82f6;
    --primary-100: #dbeafe;
    --primary-50: #eff6ff;

    /* Status */
    --success-700: #047857;
    --success-600: #059669;
    --success-100: #d1fae5;
    --success-50: #ecfdf5;
    --error-700: #b91c1c;
    --error-600: #dc2626;
    --error-100: #fee2e2;
    --error-50: #fef2f2;
    --warning-700: #b45309;
    --warning-600: #d97706;
    --warning-100: #fef3c7;
    --warning-50: #fffbeb;
    --offline-600: #6b7280;
    --offline-100: #f3f4f6;
    --offline-50: #f9fafb;

    /* Layout */
    --sidebar-w: 256px;
    --sidebar-collapsed: 72px;
    --topbar-h: 56px;
    --page-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;

    /* Typography */
    --font-body: 'ATOZ', 'Noto Sans KR', -apple-system, sans-serif;
    --font-heading: 'ATOZ', 'Noto Sans KR', -apple-system, sans-serif;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
}

/* --- Base --- */
html {
    font-size: 17px;   /* 기본 16px → 17px 전역 스케일업 */
}
body {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.6;
    background: var(--page-bg);
    color: var(--text-primary);
}

/* Headings use Medium weight */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 500;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    transition: width 0.3s cubic-bezier(.4,0,.2,1), transform 0.3s cubic-bezier(.4,0,.2,1);
    z-index: 40;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-header-text,
.sidebar.collapsed .sidebar-footer-detail { display: none; }
.sidebar.collapsed .sidebar-logo-icon { display: flex !important; }
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-link svg { margin: 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    border-right: 3px solid transparent;
    transition: all 0.15s;
}
.nav-link:hover { background: var(--primary-50); color: var(--primary-700); }
.nav-link.active {
    background: var(--primary-50);
    color: var(--primary-700);
    border-right-color: var(--primary-600);
    font-weight: 600;
}
.nav-link svg { width: 22px; height: 22px; flex-shrink: 0; }

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(.4,0,.2,1);
}
.main-content.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* --- Top bar --- */
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card-body { padding: 1.25rem; }

/* KPI Card */
.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-600);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kpi-card.success { border-left-color: var(--success-600); }
.kpi-card.error { border-left-color: var(--error-600); }
.kpi-card.warning { border-left-color: var(--warning-600); }
.kpi-card.offline { border-left-color: var(--offline-600); }
.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}
.kpi-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

/* Stat card hover */
.stat-card { transition: transform 0.15s, box-shadow 0.15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
}
.btn-primary { background: var(--primary-600); color: #fff; }
.btn-primary:hover { background: var(--primary-700); }
.btn-secondary { background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--offline-50); }
.btn-danger { background: var(--error-600); color: #fff; }
.btn-danger:hover { background: var(--error-700); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid transparent;
}
.badge-online { background: var(--success-50); color: var(--success-700); border-color: #bbf7d0; }
.badge-offline { background: var(--offline-100); color: var(--offline-600); border-color: #d1d5db; }
.badge-alarm { background: var(--error-50); color: var(--error-700); border-color: #fecaca; }
.badge-warning { background: var(--warning-50); color: var(--warning-700); border-color: #fde68a; }

/* --- Status Dot --- */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online { background: var(--success-600); box-shadow: 0 0 0 3px var(--success-100); }
.status-dot.offline { background: var(--offline-600); box-shadow: 0 0 0 3px var(--offline-100); }
.status-dot.alarm { background: var(--error-600); box-shadow: 0 0 0 3px var(--error-100); animation: pulse-dot 2s infinite; }

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 3px var(--error-100); }
    50% { box-shadow: 0 0 0 6px rgba(220,38,38,0.1); }
}

/* --- Tables --- */
.pro-table { width: 100%; font-size: 0.9375rem; }
.pro-table thead { background: #f8fafc; }
.pro-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}
.pro-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-light);
}
.pro-table tbody tr:hover { background: #f8fafc; }

/* --- Modals --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-card {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

/* --- Toggle switch --- */
.toggle-switch { position: relative; width: 48px; height: 26px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: #cbd5e1; border-radius: 13px;
    cursor: pointer; transition: 0.3s;
}
.toggle-slider::before {
    content: ''; position: absolute;
    width: 20px; height: 20px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary-600); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* --- Dashboard specific --- */
.dashboard-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    height: 100%;
    min-height: 0;
}
.dashboard-panel {
    overflow-y: auto;
    padding: 1rem;
    border-right: 1px solid var(--border-color);
    background: var(--card-bg);
}
.dashboard-map {
    position: relative;
    overflow: hidden;
}
.dashboard-map #map { height: 100%; width: 100%; }

/* Status bar (horizontal stacked) */
.status-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--offline-100);
}
.status-bar-segment { height: 100%; transition: width 0.5s ease; }

/* --- Filter chips --- */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--primary-500); color: var(--primary-600); }
.filter-chip.active {
    background: var(--primary-600);
    color: #fff;
    border-color: var(--primary-600);
}

/* --- Login split layout --- */
.login-split {
    display: grid;
    grid-template-columns: 55% 45%;
    min-height: 100vh;
}
.login-hero {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: #fff;
}

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary-600); }
.breadcrumb .sep { color: var(--text-muted); }

/* --- Map legend overlay --- */
.map-legend {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    font-size: 0.8125rem;
}

/* --- LIVE indicator --- */
.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    background: var(--error-50);
    color: var(--error-600);
    border: 1px solid #fecaca;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--error-600);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}
.fade-in { animation: fadeIn 0.3s ease forwards; }
.slide-in { animation: slideIn 0.3s ease forwards; }
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.375rem;
}

/* --- Toast enhanced --- */
.toast-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    font-size: 0.9375rem;
    min-width: 300px;
    border-left: 4px solid var(--primary-600);
    animation: slideIn 0.3s ease;
}
.toast-item.success { border-left-color: var(--success-600); }
.toast-item.error { border-left-color: var(--error-600); }
.toast-item.warning { border-left-color: var(--warning-600); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* --- Leaflet customization --- */
.leaflet-popup-content { min-width: 240px; font-family: var(--font-body); }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
.popup-weather { border-top: 1px solid #f3f4f6; padding-top: 6px; }

/* Marker controlling blink */
@keyframes markerBlink {
    0%, 100% { box-shadow: 0 0 0 3px rgba(37,99,235,0.8); }
    50% { box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
}
.leaflet-marker-icon.marker-controlling {
    animation: markerBlink 0.8s infinite;
    border-radius: 10px;
}

/* --- Responsive --- */
@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); position: fixed; top: 0; left: 0; height: 100%; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .dashboard-layout { grid-template-columns: 1fr; }
    .dashboard-panel { border-right: none; border-bottom: 1px solid var(--border-color); max-height: 40vh; }
    .dashboard-map { min-height: 60vh; }
    .login-split { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .topbar { padding: 0 1rem; }
}

@media (max-width: 640px) {
    html { font-size: 16px; }
    .kpi-value { font-size: 1.5rem; }
}
