/* ============================================================
   PhpCMS - Main Stylesheet
   ============================================================ */

:root {
  --primary:     #4f46e5;
  --primary-dark:#3730a3;
  --primary-light:#e0e7ff;
  --secondary:   #06b6d4;
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --dark:        #1e293b;
  --gray-900:    #0f172a;
  --gray-800:    #1e293b;
  --gray-700:    #334155;
  --gray-600:    #475569;
  --gray-500:    #64748b;
  --gray-400:    #94a3b8;
  --gray-300:    #cbd5e1;
  --gray-200:    #e2e8f0;
  --gray-100:    #f1f5f9;
  --gray-50:     #f8fafc;
  --white:       #ffffff;
  --header-h:    64px;
  --footer-h:    56px;
  --nav-h:       48px;
  --sidebar-w:   260px;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--header-h) + var(--nav-h));
  padding-bottom: var(--footer-h);
}

/* ===== HEADER ===== */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--dark);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1000;
  gap: 1rem;
  box-shadow: var(--shadow-md);
}

#site-header .logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}

#site-header .logo span {
  color: var(--primary);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.header-right a, .header-right button {
  color: var(--gray-300);
  text-decoration: none;
  font-size: .875rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem .75rem;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}

.header-right a:hover, .header-right button:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.header-right .btn-admin {
  background: var(--primary);
  color: #fff;
}

.header-right .btn-admin:hover {
  background: var(--primary-dark);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all .3s;
}

/* ===== NAVIGATION ===== */
#site-nav {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--nav-h);
  background: var(--primary);
  z-index: 999;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

.nav-list {
  list-style: none;
  display: flex;
  gap: .25rem;
  height: 100%;
  align-items: center;
  flex-wrap: wrap;
}

.nav-item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-item > a {
  color: rgba(255,255,255,.9);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  padding: .5rem .875rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: .4rem;
  transition: background .15s;
  white-space: nowrap;
}

.nav-item > a:hover,
.nav-item > a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
}

.nav-item.has-children > a::after {
  content: '▾';
  font-size: .7rem;
  margin-left: .2rem;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  z-index: 1100;
  overflow: hidden;
}

.nav-item:hover .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: .6rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  font-size: .875rem;
  transition: background .1s;
}

.dropdown-menu a:hover {
  background: var(--gray-100);
  color: var(--primary);
}

/* Mobile Nav */
#mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: var(--dark);
  z-index: 998;
  padding: 1rem;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
}

#mobile-nav a {
  display: block;
  padding: .6rem 1rem;
  color: var(--gray-300);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: .9rem;
}

#mobile-nav a:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ===== MAIN CONTENT ===== */
#site-main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== FOOTER ===== */
#site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  background: var(--dark);
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  z-index: 1000;
  gap: 1.5rem;
}

#site-footer a {
  color: var(--gray-400);
  text-decoration: none;
}

#site-footer a:hover { color: var(--gray-200); }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h2, .card-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gray-800);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: .4rem;
}

.form-control {
  width: 100%;
  padding: .6rem .875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

textarea.form-control { resize: vertical; min-height: 120px; }

.form-hint {
  font-size: .78rem;
  color: var(--gray-500);
  margin-top: .3rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200);  color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline   { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg        { padding: .75rem 1.5rem; font-size: 1rem; }

/* ===== ALERTS ===== */
.alert {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .9rem;
}

.alert-icon { font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  text-align: left;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tr:hover td { background: var(--gray-50); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-success { background: #ecfdf5; color: #059669; }
.badge-danger  { background: #fef2f2; color: #dc2626; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-info    { background: #eff6ff; color: #3b82f6; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-purple  { background: #f5f3ff; color: #7c3aed; }

/* ===== CHANGELOG ===== */
.changelog-container { max-width: 800px; }

.changelog-version {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}

.changelog-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}

.changelog-header:hover { background: var(--gray-50); }

.changelog-version-num {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: .25rem .75rem;
  border-radius: 999px;
  white-space: nowrap;
}

.changelog-title { font-weight: 600; flex: 1; }
.changelog-date  { font-size: .8rem; color: var(--gray-500); }

.changelog-arrow {
  color: var(--gray-400);
  transition: transform .2s;
  font-size: .8rem;
}

.changelog-version.open .changelog-arrow { transform: rotate(180deg); }

.changelog-body {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--gray-100);
}

.changelog-version.open .changelog-body { display: block; }

.changelog-body ul {
  list-style: none;
  margin-top: .75rem;
}

.changelog-body li {
  padding: .3rem 0 .3rem 1.5rem;
  position: relative;
  font-size: .875rem;
  color: var(--gray-700);
}

.changelog-body li::before {
  content: '•';
  position: absolute;
  left: .5rem;
  color: var(--primary);
  font-weight: 700;
}

.changelog-tag {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  margin-right: .4rem;
  text-transform: uppercase;
}

.tag-new     { background: #ecfdf5; color: #059669; }
.tag-fix     { background: #fef2f2; color: #dc2626; }
.tag-improve { background: #eff6ff; color: #3b82f6; }
.tag-security{ background: #fdf4ff; color: #9333ea; }

/* ===== ADMIN LAYOUT ===== */
.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h) - var(--nav-h) - var(--footer-h));
}

.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  padding: 1.5rem 0;
  border-radius: var(--radius);
}

.admin-content {
  flex: 1;
  padding: 0 0 0 1.5rem;
  min-width: 0;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-400);
  padding: 0 1.25rem;
  margin-bottom: .4rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: var(--gray-700);
  text-decoration: none;
  font-size: .875rem;
  transition: all .1s;
}

.sidebar-nav a:hover { background: var(--gray-100); color: var(--primary); }
.sidebar-nav a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-nav a .icon { font-size: 1rem; width: 18px; text-align: center; }

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  font-size: 1.75rem;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; }
.stat-icon.green  { background: #ecfdf5; }
.stat-icon.orange { background: #fff7ed; }
.stat-icon.purple { background: #f5f3ff; }

.stat-label { font-size: .78rem; color: var(--gray-500); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-800); }

/* ===== PAGE/POST ===== */
.page-content {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.page-content h1 { font-size: 1.75rem; margin-bottom: 1rem; }
.page-content h2 { font-size: 1.4rem; margin: 1.5rem 0 .75rem; }
.page-content h3 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
.page-content p  { line-height: 1.7; margin-bottom: 1rem; }
.page-content ul, .page-content ol { margin: .75rem 0 1rem 1.5rem; }
.page-content li { margin-bottom: .3rem; }
.page-content a  { color: var(--primary); }
.page-content code { background: var(--gray-100); padding: .1rem .4rem; border-radius: 4px; font-size: .85em; }
.page-content pre { background: var(--gray-800); color: var(--gray-100); padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin-bottom: 1rem; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .8rem;
  color: var(--gray-500);
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

/* ===== AUTH PAGES ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--gray-100);
}

.auth-card {
  background: var(--white);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 1.75rem;
  color: var(--primary);
  font-weight: 800;
}

.auth-logo p { color: var(--gray-500); font-size: .9rem; margin-top: .25rem; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  gap: .25rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  font-size: .875rem;
  text-decoration: none;
  transition: all .15s;
}

.pagination a { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-200); }
.pagination a:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border: 1px solid var(--primary); }

/* ===== GRID ===== */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ===== CODE EDITOR ===== */
.editor-toolbar {
  background: var(--gray-800);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: .5rem .75rem;
  display: flex;
  gap: .5rem;
  align-items: center;
}

.editor-toolbar span {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
}

.editor-toolbar span:nth-child(1) { background: #ef4444; }
.editor-toolbar span:nth-child(2) { background: #f59e0b; }
.editor-toolbar span:nth-child(3) { background: #10b981; }

.code-editor {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: .85rem;
  background: var(--gray-900);
  color: #e2e8f0;
  border: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1rem;
  line-height: 1.6;
  width: 100%;
  min-height: 300px;
  resize: vertical;
}

.code-editor:focus { outline: none; box-shadow: 0 0 0 2px var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .admin-sidebar { display: none; }
  .admin-layout  { display: block; }
  .admin-content { padding: 0; }
  .grid-3        { grid-template-columns: repeat(2, 1fr); }
  .grid-4        { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --header-h: 56px;
    --nav-h:    0px;
  }

  body { padding-top: var(--header-h); }

  #site-nav   { display: none; }
  .hamburger  { display: flex; }

  #site-main  { padding: 1rem; }

  .auth-card  { padding: 1.5rem; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .grid-2     { grid-template-columns: 1fr; }
  .grid-3     { grid-template-columns: 1fr; }
  .grid-4     { grid-template-columns: repeat(2, 1fr); }

  #site-footer {
    gap: .75rem;
    font-size: .75rem;
    padding: 0 1rem;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--footer-h);
    position: fixed;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .grid-4     { grid-template-columns: 1fr; }
  #site-header .logo span.tagline { display: none; }
}

/* ===== MISC ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gray-500); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.w-100 { width: 100%; }

.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 1.25rem 0;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--gray-400);
}

.empty-state .icon { font-size: 3rem; display: block; margin-bottom: 1rem; }
