/* =============================================
   PageTalk Admin Panel Styles
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&display=swap');

:root {
    --pt-primary: #2563eb;
    --pt-primary-dark: #1d4ed8;
    --pt-primary-light: #dbeafe;
    --pt-accent: #f59e0b;
    --pt-bg: #f1f5f9;
    --pt-sidebar: #0f172a;
    --pt-sidebar-hover: #1e293b;
    --pt-card: #ffffff;
    --pt-border: #e2e8f0;
    --pt-text: #1e293b;
    --pt-text-sub: #64748b;
    --pt-success: #10b981;
    --pt-danger: #ef4444;
    --pt-warning: #f59e0b;
    --pt-radius: 10px;
    --pt-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --pt-shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--pt-bg);
    color: var(--pt-text);
    font-size: 14px;
    line-height: 1.6;
}

/* ---- Login ---- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.login-box {
    background: var(--pt-card);
    border-radius: 16px;
    padding: 48px 40px;
    width: 420px;
    box-shadow: var(--pt-shadow-lg);
}
.login-box h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--pt-primary);
}
.login-box h1 span { color: var(--pt-accent); }
.login-box p.sub { color: var(--pt-text-sub); margin-bottom: 32px; }

/* ---- Layout ---- */
.pt-layout { display: flex; min-height: 100vh; }

.pt-sidebar {
    width: 260px;
    background: var(--pt-sidebar);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s;
}
.pt-sidebar .logo {
    padding: 24px 20px;
    font-size: 22px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.pt-sidebar .logo span { color: var(--pt-accent); }

.pt-sidebar nav { padding: 12px 0; }
.pt-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    transition: all .15s;
}
.pt-sidebar nav a:hover,
.pt-sidebar nav a.active {
    background: var(--pt-sidebar-hover);
    color: #fff;
}
.pt-sidebar nav a.active { border-right: 3px solid var(--pt-primary); }
.pt-sidebar nav a i { font-size: 18px; width: 24px; text-align: center; }
.pt-sidebar .nav-group { padding: 16px 24px 8px; font-size: 11px; text-transform: uppercase; color: #475569; letter-spacing: .05em; }

.pt-main { margin-left: 260px; flex: 1; min-height: 100vh; }

.pt-header {
    background: var(--pt-card);
    border-bottom: 1px solid var(--pt-border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.pt-header h2 { font-size: 18px; font-weight: 600; }
.pt-header .user-info { display: flex; align-items: center; gap: 12px; }
.pt-header .user-badge {
    background: var(--pt-primary-light);
    color: var(--pt-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.pt-content { padding: 32px; }

/* ---- Cards ---- */
.pt-card {
    background: var(--pt-card);
    border-radius: var(--pt-radius);
    border: 1px solid var(--pt-border);
    box-shadow: var(--pt-shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.pt-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pt-border);
}

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--pt-card);
    border-radius: var(--pt-radius);
    border: 1px solid var(--pt-border);
    padding: 24px;
    box-shadow: var(--pt-shadow);
}
.stat-card .stat-label { font-size: 13px; color: var(--pt-text-sub); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--pt-primary); }
.stat-card .stat-icon { font-size: 36px; float: right; opacity: .15; margin-top: -8px; }

/* ---- Forms ---- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--pt-text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--pt-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s;
    background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--pt-primary);
    box-shadow: 0 0 0 3px var(--pt-primary-light);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--pt-primary); color: #fff; }
.btn-primary:hover { background: var(--pt-primary-dark); }
.btn-success { background: var(--pt-success); color: #fff; }
.btn-danger { background: var(--pt-danger); color: #fff; }
.btn-warning { background: var(--pt-warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--pt-border); color: var(--pt-text); }
.btn-outline:hover { background: var(--pt-bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; }

/* ---- Table ---- */
.pt-table {
    width: 100%;
    border-collapse: collapse;
}
.pt-table th,
.pt-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--pt-border);
}
.pt-table th {
    background: var(--pt-bg);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--pt-text-sub);
    letter-spacing: .03em;
}
.pt-table tr:hover { background: #f8fafc; }
.pt-table .badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-free { background: #e0e7ff; color: #3730a3; }
.badge-pro { background: #fef3c7; color: #92400e; }

/* ---- Tabs ---- */
.pt-tabs { display: flex; border-bottom: 2px solid var(--pt-border); margin-bottom: 24px; }
.pt-tabs .tab {
    padding: 12px 24px;
    cursor: pointer;
    font-weight: 500;
    color: var(--pt-text-sub);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
}
.pt-tabs .tab:hover { color: var(--pt-text); }
.pt-tabs .tab.active { color: var(--pt-primary); border-bottom-color: var(--pt-primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Modal ---- */
.pt-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.pt-modal-overlay.show { display: flex; }
.pt-modal {
    background: var(--pt-card);
    border-radius: 16px;
    width: 600px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--pt-shadow-lg);
}
.pt-modal .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--pt-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pt-modal .modal-header h3 { margin: 0; border: none; padding: 0; }
.pt-modal .modal-body { padding: 24px; }
.pt-modal .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--pt-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-close { cursor: pointer; font-size: 20px; color: var(--pt-text-sub); background: none; border: none; }

/* ---- Flow Editor ---- */
.flow-canvas {
    background: #f8fafc;
    background-image: radial-gradient(circle, #ddd 1px, transparent 1px);
    background-size: 20px 20px;
    min-height: 600px;
    border-radius: var(--pt-radius);
    border: 1px solid var(--pt-border);
    position: relative;
    overflow: auto;
}
.flow-node {
    position: absolute;
    background: var(--pt-card);
    border: 2px solid var(--pt-border);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 180px;
    cursor: move;
    box-shadow: var(--pt-shadow);
    z-index: 10;
}
.flow-node.selected { border-color: var(--pt-primary); box-shadow: 0 0 0 3px var(--pt-primary-light); }
.flow-node .node-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.flow-node .node-type { font-size: 11px; color: var(--pt-text-sub); }
.flow-node .node-actions { position: absolute; top: 8px; right: 8px; }

.node-message { border-left: 4px solid var(--pt-primary); }
.node-question { border-left: 4px solid var(--pt-accent); }
.node-condition { border-left: 4px solid #8b5cf6; }
.node-api { border-left: 4px solid var(--pt-success); }
.node-ai { border-left: 4px solid #ec4899; }
.node-group { border-left: 4px solid #06b6d4; }

/* ---- Menu Tree ---- */
.menu-tree { list-style: none; padding: 0; }
.menu-tree li { padding: 0; }
.menu-tree .menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid var(--pt-border);
    border-radius: 8px;
    margin-bottom: 4px;
    background: #fff;
    cursor: grab;
}
.menu-tree .menu-item:hover { background: #f8fafc; }
.menu-tree .menu-item .grip { color: #ccc; cursor: grab; }
.menu-tree .menu-children { padding-left: 28px; }

/* ---- Toast ---- */
.pt-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    padding: 14px 24px;
    border-radius: 10px;
    color: #fff;
    font-weight: 500;
    box-shadow: var(--pt-shadow-lg);
    animation: slideIn .3s ease;
}
.pt-toast.success { background: var(--pt-success); }
.pt-toast.error { background: var(--pt-danger); }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Pagination ---- */
.pt-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 0;
    justify-content: center;
}
.pg-btn {
    width: 34px; height: 34px;
    border: 1px solid var(--pt-border);
    background: var(--pt-card);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .1s;
    color: var(--pt-text);
    font-family: inherit;
}
.pg-btn:hover { background: var(--pt-bg); border-color: var(--pt-primary); color: var(--pt-primary); }
.pg-btn.active { background: var(--pt-primary); color: #fff; border-color: var(--pt-primary); }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.pg-dots { color: var(--pt-text-sub); font-size: 13px; padding: 0 4px; }
.pg-info { font-size: 12px; color: var(--pt-text-sub); margin-left: 12px; }

/* ---- Form Validation ---- */
.input-error { border-color: var(--pt-danger) !important; box-shadow: 0 0 0 3px rgba(239,68,68,.15) !important; }
.form-error { font-size: 11px; color: var(--pt-danger); margin-top: 4px; }

/* ---- Search Input ---- */
.table-search {
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--pt-border);
    border-radius: 8px;
    font-size: 13px;
    min-width: 200px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 12px center;
}

/* ---- Script Code Box ---- */
.code-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    overflow-x: auto;
    position: relative;
}
.code-box .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,.1);
    border: none;
    color: #94a3b8;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

/* ---- Company Selector ---- */
.company-select {
    padding: 8px 14px;
    border: 1px solid var(--pt-border);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .pt-sidebar { transform: translateX(-100%); position: fixed; z-index: 200; }
    .pt-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
    .pt-main { margin-left: 0; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .form-row { flex-direction: column; gap: 0; }
    .pt-content { padding: 16px; }
    .pt-header { padding: 12px 16px; }
    .pt-header h2 { font-size: 16px; }
    .pt-modal { width: 95vw; }
    .pt-table { font-size: 12px; }
    .pt-table th, .pt-table td { padding: 8px 10px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-group { flex-wrap: wrap; }
    .pt-card { padding: 16px; margin-bottom: 16px; }
    .code-box { font-size: 11px; padding: 12px; }
    .fe-toolbar { gap: 4px; }
    .fe-toolbar .divider { display: none; }
    .flow-canvas { min-height: 400px; }
    .monitor-layout { flex-direction: column; }
    .monitor-sidebar { width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid #e2e8f0; }
    .theme-editor-grid { grid-template-columns: 1fr !important; }
    .pe-layout { flex-direction: column; }
    #dashboard-charts { grid-template-columns: 1fr !important; }
    .login-box { width: 95vw; padding: 32px 24px; }
    .company-select { font-size: 11px; max-width: 120px; }
    .user-info { gap: 6px; }
    #notif-dropdown { right: 8px; width: calc(100vw - 16px); }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card .stat-value { font-size: 24px; }
    .pt-tabs { overflow-x: auto; }
    .pt-tabs .tab { white-space: nowrap; padding: 10px 16px; font-size: 13px; }
}
