<?php
/**
 * 炎酷CMS - 后台公共头部（菜单 + 顶部栏 + 内联样式）
 * 引用前可设置：$page_title 页面标题，$active 当前菜单标识
 */
defined('YKCMS') or exit('Access Denied');
$page_title = isset($page_title) ? $page_title : '后台管理';
$active     = isset($active) ? $active : '';
$ykAdmin    = admin_current();
$ykFlash    = flash_get();
$ykMenus = array(
    array('config', '站点设置', ADMIN_URL . '/config/index.php'),
    array('visual', '在线编辑', ADMIN_URL . '/config/visual.php'),
    array('block',  '首页区块', ADMIN_URL . '/block/index.php'),
    array('column', '栏目管理', ADMIN_URL . '/column/index.php'),
    array('article','文章管理', ADMIN_URL . '/article/index.php'),
);
$ykSysMenus = array(
    array('admin',    '管理员工', ADMIN_URL . '/system/admin.php'),
    array('stats',    '访问统计', ADMIN_URL . '/stats/index.php'),
    array('backup',   '数据备份', ADMIN_URL . '/system/backup.php'),
    array('log',      '操作日志', ADMIN_URL . '/system/log.php'),
);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo e($page_title); ?> - 炎酷CMS后台</title>
<style>
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:"Microsoft YaHei","PingFang SC",sans-serif;font-size:14px;color:#333;background:#f4f6fb}
a{color:#2563eb;text-decoration:none}
a:hover{text-decoration:underline}
.yk-layout{display:flex;min-height:100vh}
.yk-side{width:212px;background:linear-gradient(180deg,#1e2749 0%,#131a2c 100%);flex-shrink:0;position:sticky;top:0;height:100vh;overflow-y:auto;box-shadow:2px 0 12px rgba(10,16,32,.25);z-index:10}
.yk-side .logo{color:#fff;font-size:19px;font-weight:bold;padding:22px 20px;border-bottom:1px solid rgba(255,255,255,.08);letter-spacing:1px}
.yk-side .logo span{background:linear-gradient(90deg,#ffb347,#ff7d2a);-webkit-background-clip:text;background-clip:text;color:transparent}
.yk-menu{padding:10px 12px}
.yk-menu a{display:block;color:#9aa7c0;padding:11px 16px;font-size:14px;border-radius:8px;margin-bottom:2px;transition:all .2s}
.yk-menu a:hover{background:rgba(255,255,255,.07);color:#fff;text-decoration:none;transform:translateX(2px)}
.yk-menu a.on{background:linear-gradient(90deg,#3b82f6,#2563eb);color:#fff;box-shadow:0 4px 12px rgba(37,99,235,.35)}
.yk-menu .grp{color:#5c6a8a;font-size:12px;padding:16px 16px 8px;letter-spacing:2px}
.yk-main{flex:1;min-width:0;display:flex;flex-direction:column}
.yk-topbar{background:rgba(255,255,255,.92);backdrop-filter:blur(8px);height:60px;display:flex;align-items:center;justify-content:space-between;padding:0 26px;box-shadow:0 2px 10px rgba(31,45,61,.07);position:sticky;top:0;z-index:9}
.yk-topbar .tt{font-size:17px;font-weight:bold;color:#1f2d3d}
.yk-topbar .tt::before{content:"";display:inline-block;width:4px;height:16px;background:linear-gradient(180deg,#3b82f6,#2563eb);border-radius:2px;margin-right:10px;vertical-align:-2px}
.yk-topbar .user{color:#666;font-size:13px}
.yk-content{padding:26px;flex:1}
.yk-card{background:#fff;border-radius:12px;padding:22px 24px;box-shadow:0 2px 14px rgba(31,45,61,.06);margin-bottom:22px;border:1px solid rgba(234,238,242,.7)}
.yk-card h3{font-size:15px;margin-bottom:18px;padding-bottom:12px;border-bottom:1px solid #f0f2f5;color:#1f2d3d;position:relative;padding-left:12px}
.yk-card h3::before{content:"";position:absolute;left:0;top:2px;bottom:12px;width:4px;border-radius:2px;background:linear-gradient(180deg,#3b82f6,#2563eb)}
.yk-flash{padding:11px 18px;border-radius:8px;margin-bottom:18px;box-shadow:0 2px 8px rgba(31,45,61,.05)}
.yk-flash.ok{background:#e8f7ee;color:#1a9b4c;border:1px solid #b7e6c8}
.yk-flash.err{background:#fdecea;color:#d93025;border:1px solid #f5c6c2}
.yk-btn{display:inline-block;padding:8px 18px;background:linear-gradient(90deg,#3b82f6,#2563eb);color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:14px;transition:all .2s;box-shadow:0 2px 6px rgba(37,99,235,.25)}
.yk-btn:hover{box-shadow:0 4px 14px rgba(37,99,235,.4);transform:translateY(-1px);text-decoration:none;color:#fff}
.yk-btn.gray{background:linear-gradient(90deg,#94a3b8,#8a94a6);box-shadow:0 2px 6px rgba(100,116,139,.2)}
.yk-btn.red{background:linear-gradient(90deg,#f06a6a,#e05252);box-shadow:0 2px 6px rgba(224,82,82,.25)}
.yk-btn.sm{padding:4px 12px;font-size:12px}
table.yk-table{width:100%;border-collapse:collapse;background:#fff;border-radius:8px;overflow:hidden}
.yk-table th,.yk-table td{border:1px solid #eef1f5;padding:10px 12px;text-align:left;font-size:13px}
.yk-table th{background:#f8fafc;color:#5c6a7d;font-weight:600}
.yk-table tr:hover td{background:#f8faff}
.yk-form .row{margin-bottom:16px;display:flex;align-items:flex-start}
.yk-form label{width:130px;padding-top:8px;color:#5c6a7d;flex-shrink:0;font-weight:600}
.yk-form .ipt{flex:1;max-width:640px}
.yk-form input[type=text],.yk-form input[type=password],.yk-form input[type=number],.yk-form select,.yk-form textarea{width:100%;padding:8px 12px;border:1px solid #dbe2ec;border-radius:6px;font-size:14px;font-family:inherit;transition:border .2s,box-shadow .2s}
.yk-form input:focus,.yk-form select:focus,.yk-form textarea:focus{border-color:#3b82f6;box-shadow:0 0 0 3px rgba(59,130,246,.12);outline:none}
.yk-form textarea{min-height:120px;resize:vertical}
.yk-form .tip{color:#999;font-size:12px;margin-top:4px}
.yk-check label{width:auto;padding-top:0;margin-right:18px;color:#333;font-weight:400}
.yk-toolbar{margin-bottom:6px}
.yk-toolbar button{padding:4px 10px;margin-right:4px;border:1px solid #dbe2ec;background:#f8fafc;border-radius:4px;cursor:pointer;font-size:13px}
.yk-toolbar button:hover{background:#e8eef7}
.yk-pager{margin-top:16px}
.yk-pager a{display:inline-block;padding:5px 12px;border:1px solid #dbe2ec;background:#fff;margin-right:5px;border-radius:5px;color:#333}
.yk-pager a.on{background:linear-gradient(90deg,#3b82f6,#2563eb);color:#fff;border-color:#2563eb}
.yk-stats{display:flex;flex-wrap:wrap;gap:16px}
.yk-stat{flex:1;min-width:150px;background:linear-gradient(180deg,#fff,#f8faff);border-radius:12px;padding:20px;box-shadow:0 2px 14px rgba(31,45,61,.06);border:1px solid rgba(234,238,242,.7)}
.yk-stat .num{font-size:30px;font-weight:bold;background:linear-gradient(90deg,#3b82f6,#2563eb);-webkit-background-clip:text;background-clip:text;color:transparent;margin-top:6px}
.yk-grid{display:flex;flex-wrap:wrap;gap:14px}
.yk-grid .cell{width:160px;background:#fff;border:1px solid #eef1f5;border-radius:10px;padding:10px;text-align:center;transition:all .2s}
.yk-grid .cell:hover{box-shadow:0 4px 14px rgba(31,45,61,.1);transform:translateY(-2px)}
.yk-grid .cell img{max-width:100%;height:90px;object-fit:cover;border-radius:6px;background:#f0f2f5}
.yk-grid .cell .nm{font-size:12px;color:#666;word-break:break-all;margin:6px 0}
.yk-actions a{margin-right:8px;white-space:nowrap}
.yk-tabs{display:flex;gap:4px;margin-bottom:18px;background:#fff;border-radius:10px;padding:5px;box-shadow:0 2px 10px rgba(31,45,61,.05);width:fit-content}
.yk-tabs a{padding:8px 22px;border-radius:8px;color:#5c6a7d;font-size:14px;transition:all .2s}
.yk-tabs a:hover{text-decoration:none;color:#2563eb}
.yk-tabs a.on{background:linear-gradient(90deg,#3b82f6,#2563eb);color:#fff;box-shadow:0 2px 8px rgba(37,99,235,.3)}
@media(max-width:768px){
 .yk-layout{flex-direction:column}
 .yk-side{width:100%;height:auto;position:static}
 .yk-content{padding:12px}
 .yk-form .row{flex-direction:column}
 .yk-form label{width:100%;padding-bottom:5px}
}
</style>
</head>
<body>
<div class="yk-layout">
<div class="yk-side">
  <div class="logo">炎酷<span>CMS</span></div>
  <div class="yk-menu">
    <?php foreach ($ykMenus as $m): ?>
    <a href="<?php echo e($m[2]); ?>"<?php echo $active === $m[0] ? ' class="on"' : ''; ?>><?php echo e($m[1]); ?></a>
    <?php endforeach; ?>
    <div class="grp">系统工具</div>
    <?php foreach ($ykSysMenus as $m): ?>
    <a href="<?php echo e($m[2]); ?>"<?php echo $active === $m[0] ? ' class="on"' : ''; ?>><?php echo e($m[1]); ?></a>
    <?php endforeach; ?>
  </div>
</div>
<div class="yk-main">
  <div class="yk-topbar">
    <div class="tt"><?php echo e($page_title); ?></div>
    <div class="user">
      <a href="<?php echo e(ADMIN_URL); ?>/index.php">仪表盘</a>
      &nbsp;|&nbsp;<a href="<?php echo e(ADMIN_URL); ?>/system/cache.php">清理缓存</a>
      &nbsp;<a href="<?php echo e(SITE_URL); ?>/" target="_blank" style="display:inline-block;padding:5px 12px;background:#1a9b4c;color:#fff;border-radius:4px;font-size:13px">首页预览</a>
      <a href="<?php echo e(ADMIN_URL); ?>/system/upgrade.php" style="display:inline-block;padding:5px 12px;background:#ff7d2a;color:#fff;border-radius:4px;font-size:13px;margin-left:8px">在线升级</a>
      &nbsp;当前账号：<b><?php echo e($ykAdmin ? $ykAdmin['username'] : ''); ?></b>
      &nbsp;|&nbsp;<a href="<?php echo e(ADMIN_URL); ?>/logout.php">退出登录</a>
    </div>
  </div>
  <div class="yk-content">
  <?php if ($ykFlash): ?>
  <div class="yk-flash <?php echo $ykFlash[1] === 'err' ? 'err' : 'ok'; ?>"><?php echo e($ykFlash[0]); ?></div>
  <?php endif; ?>
