/* ═══════════════════════════════════════════════════════════════════════════
   SAGLIK CATALOG — Admin Panel Styles
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --accent:     #1d4ed8;
    --accent-lt:  #eff6ff;
    --text:       #1e293b;
    --text-muted: #64748b;
    --border:     #e2e8f0;
    --bg:         #f8fafc;
    --card:       #ffffff;
    --sidebar-w:  240px;
    --header-h:   64px;
    --danger:     #dc2626;
    --success:    #059669;
    --warning:    #d97706;
    --info:       #0284c7;
    --radius:     10px;
    --font:       'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.login-card {
    background: white; border-radius: 16px;
    padding: 2.5rem 2rem; width: 100%; max-width: 380px;
    box-shadow: 0 32px 64px rgba(0,0,0,.25);
    display: flex; flex-direction: column; gap: 1rem;
}
.login-logo { display: flex; align-items: center; gap: .75rem; justify-content: center; }
.login-logo img { height: 48px; object-fit: contain; }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.login-sub { text-align: center; font-size: .85rem; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: .75rem; }
.login-back { text-align: center; font-size: .8rem; color: var(--text-muted); margin-top: .5rem; }

/* ── Admin layout ────────────────────────────────────────────────────────── */
.admin-body {
    display: flex; min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.admin-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: #0f172a; color: white;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { height: 32px; filter: brightness(0) invert(1); object-fit: contain; }
.sidebar-name { font-weight: 800; font-size: 1rem; line-height: 1; }
.sidebar-sub  { font-size: .7rem; color: rgba(255,255,255,.4); margin-top: .15rem; }

.sidebar-nav {
    flex: 1; display: flex; flex-direction: column; gap: .25rem;
    padding: 1rem .75rem;
    overflow-y: auto;
}
.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem .9rem; border-radius: 8px;
    color: rgba(255,255,255,.65); text-decoration: none;
    font-size: .85rem; font-weight: 500;
    transition: all .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover  { background: rgba(255,255,255,.07); color: white; text-decoration: none; }
.nav-link.active { background: var(--accent); color: white; }

.sidebar-footer {
    padding: .75rem;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; flex-direction: column; gap: .35rem;
}
.sidebar-view-btn, .sidebar-logout {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .85rem; border-radius: 7px;
    font-size: .78rem; font-weight: 500; text-decoration: none;
    transition: all .15s; cursor: pointer; border: none;
    background: transparent;
}
.sidebar-view-btn svg, .sidebar-logout svg { width: 15px; height: 15px; }
.sidebar-view-btn { color: rgba(255,255,255,.5); }
.sidebar-view-btn:hover { background: rgba(255,255,255,.07); color: white; text-decoration: none; }
.sidebar-logout { color: rgba(220, 38, 38, .7); }
.sidebar-logout:hover { background: rgba(220,38,38,.1); color: #f87171; text-decoration: none; }

/* ── Main content ────────────────────────────────────────────────────────── */
.admin-main {
    flex: 1; min-width: 0;
    padding: 2rem;
    display: flex; flex-direction: column; gap: 1.5rem;
    max-width: 1100px;
}

.admin-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
}
.admin-header h1   { font-size: 1.6rem; font-weight: 800; }
.admin-header .subtitle { font-size: .875rem; color: var(--text-muted); margin-top: .2rem; }
.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1.1rem; background: var(--accent); color: white;
    border: none; border-radius: 7px; font-size: .85rem; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background .15s;
    white-space: nowrap;
}
.btn-primary:hover { background: #1e40af; text-decoration: none; color: white; }
.btn-primary.btn-full { width: 100%; justify-content: center; padding: .7rem; }

.btn-secondary {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1.1rem; background: white; color: var(--text);
    border: 1px solid var(--border); border-radius: 7px;
    font-size: .85rem; font-weight: 500; cursor: pointer;
    text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-secondary.btn-sm { padding: .4rem .8rem; font-size: .78rem; }

.btn-link { font-size: .82rem; font-weight: 500; color: var(--accent); }

.btn-xs {
    display: inline-flex; align-items: center;
    padding: .25rem .6rem; border-radius: 5px;
    font-size: .72rem; font-weight: 600; cursor: pointer;
    border: none; text-decoration: none; transition: all .15s;
}
.btn-edit     { background: #eff6ff; color: var(--accent); }
.btn-edit:hover { background: var(--accent); color: white; text-decoration: none; }
.btn-delete   { background: #fef2f2; color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: white; }
.btn-secondary-xs { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Fields ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label, .field-label { font-size: .82rem; font-weight: 600; color: var(--text); }
.small-label { font-size: .75rem; color: var(--text-muted); }

.input-full, textarea {
    width: 100%; padding: .55rem .8rem;
    border: 1px solid var(--border); border-radius: 7px;
    font-size: .875rem; font-family: var(--font); color: var(--text);
    background: white; transition: border-color .15s;
}
.input-full:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}
.input-sm {
    padding: .5rem .7rem;
    border: 1px solid var(--border); border-radius: 7px;
    font-size: .85rem; font-family: var(--font); color: var(--text);
    background: white;
}
.input-sm:focus { outline: none; border-color: var(--accent); }

textarea { resize: vertical; min-height: 80px; }

.color-input-wrap { display: flex; align-items: center; gap: .5rem; }
.color-input-wrap input[type="color"] {
    width: 38px; height: 38px; border: 1px solid var(--border);
    border-radius: 7px; cursor: pointer; padding: 2px; background: white;
}

.file-input { font-size: .82rem; color: var(--text-muted); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem; border-radius: 8px;
    font-size: .875rem; font-weight: 500;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Stats ───────────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: white; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; display: flex; align-items: center; gap: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.stat-icon {
    width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: #eff6ff; color: #1d4ed8; }
.stat-icon.green  { background: #f0fdf4; color: #059669; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.amber  { background: #fffbeb; color: #d97706; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

/* ── Quick actions ───────────────────────────────────────────────────────── */
.quick-actions {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
}
.qa-card {
    background: white; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; display: flex; align-items: center; gap: .75rem;
    text-decoration: none; color: var(--text);
    font-size: .85rem; font-weight: 500;
    transition: all .15s; box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.qa-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,.08); text-decoration: none; transform: translateY(-1px); }
.qa-icon {
    width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.qa-icon svg { width: 20px; height: 20px; }

/* ── Section headers ─────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { background: white; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
    background: var(--bg); padding: .65rem 1rem;
    text-align: left; font-size: .75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.admin-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fafafa; }
.td-order { width: 50px; font-weight: 700; color: var(--text-muted); }
.td-content { color: var(--text-muted); }
.td-actions { width: 120px; }

/* ── Type badges ─────────────────────────────────────────────────────────── */
.type-badge, .page-type-badge {
    display: inline-block; padding: .2rem .55rem; border-radius: 20px;
    font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.type-cover,     .page-type-badge.type-cover     { background: #1e293b; color: white; }
.type-toc,       .page-type-badge.type-toc       { background: #334155; color: white; }
.type-divider,   .page-type-badge.type-divider   { background: #dbeafe; color: #1e40af; }
.type-products,  .page-type-badge.type-products  { background: #dcfce7; color: #166534; }
.type-contact,   .page-type-badge.type-contact   { background: #fef3c7; color: #92400e; }
.type-back_cover,.page-type-badge.type-back_cover{ background: #1e293b; color: white; }
.type-blank,     .page-type-badge.type-blank     { background: #f1f5f9; color: #64748b; }
.type-supplier,  .page-type-badge.type-supplier  { background: #ccfbf1; color: #0f766e; }

/* ── Pages list (sortable) ───────────────────────────────────────────────── */
.pages-list { display: flex; flex-direction: column; gap: .5rem; }
.page-item {
    background: white; border: 1px solid var(--border); border-radius: var(--radius);
    display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04); transition: box-shadow .15s;
}
.page-item:hover  { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.page-item.sorting{ box-shadow: 0 8px 24px rgba(0,0,0,.15); opacity: .9; background: #f0f9ff; }
.page-drag {
    cursor: grab; color: var(--text-muted); flex-shrink: 0;
    opacity: .4; transition: opacity .15s;
}
.page-drag:active { cursor: grabbing; }
.page-item:hover .page-drag { opacity: 1; }
.page-drag svg { width: 18px; height: 18px; }
.page-order { width: 28px; font-weight: 700; font-size: .8rem; color: var(--text-muted); flex-shrink: 0; }
.page-info { flex: 1; min-width: 0; }
.page-info-title { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-info-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-actions { display: flex; gap: .35rem; align-items: center; flex-shrink: 0; }

/* ── Edit form ───────────────────────────────────────────────────────────── */
.edit-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-section { display: flex; flex-direction: column; gap: .4rem; flex: 1; min-width: 0; }
.form-section label { font-size: .8rem; font-weight: 600; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-section { flex: 1; min-width: 160px; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.form-card {
    background: white; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem;
}
.form-card-title { font-size: .875rem; font-weight: 700; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }

/* ── Product editor ──────────────────────────────────────────────────────── */
.items-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
#productsList { display: flex; flex-direction: column; gap: 1rem; }
.product-card-editor {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem;
}
.product-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .25rem; }
.prod-num { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }

.img-input-group { display: flex; flex-direction: column; gap: .75rem; }
.img-preview-wrap { display: flex; align-items: center; gap: .75rem; }
.img-preview {
    width: 100px; height: 70px; object-fit: cover; border-radius: 7px;
    border: 1px solid var(--border);
}
.img-options { display: flex; flex-direction: column; gap: .5rem; }
.img-option { display: flex; flex-direction: column; gap: .3rem; }

.toc-entry { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }

.current-logo-wrap { display: flex; align-items: center; gap: .75rem; }
.current-logo { height: 48px; object-fit: contain; border: 1px solid var(--border); border-radius: 7px; padding: .25rem; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .admin-sidebar { display: none; }
    .admin-main { padding: 1rem; }
    .admin-header { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .quick-actions { grid-template-columns: 1fr 1fr; }
}
