/* ============================================================================
   Velocity IoT — Public API · SiteAdmin stylesheet
   ----------------------------------------------------------------------------
   Single source of truth for the internal SiteAdmin pages. Loaded once from
   resources/views/siteadmin/layouts/app.blade.php (and from the standalone
   auth/login.blade.php), shared by every admin screen.

   Velocity Flex branding: navy surfaces, #3075BE brand blue, #49ABE9 accents.

   Sections:
     1. Base + shared header  (global)
     2. Login          — scoped under `body.sa-login`
     3. API logs list  — scoped under `.sa-logs`
     4. API log detail — scoped under `.sa-log-show`
     5. API endpoints  — scoped under `.sa-endpoints`
     6. Guide editor   — scoped under `.sa-guide-edit`

   Page rules are namespaced via a body class so the screens can reuse the same
   generic class names (.container, .card, .method, .btn, table…) without
   clashing.
   ============================================================================ */

/* ─────────────────────────────────────────────────────────────────────────
   1. BASE + SHARED HEADER
   ───────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; }

/* Admin app pages (everything except the standalone login) */
.sa-app { background: #f1f5f9; color: #1e293b; }

/* ── Shared SiteAdmin header (navy brand bar) ── */
.sa-header {
    background: #04182d; color: #fff; padding: 0 24px;
    display: flex; align-items: center; gap: 14px; min-height: 60px; flex-wrap: wrap;
    position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.sa-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.sa-logo-img { height: 34px; width: auto; display: block; }
.sa-logo {
    width: 34px; height: 34px; background: linear-gradient(135deg, #3075be, #49abe9);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #fff; letter-spacing: -1px; font-size: 14px;
}
.sa-titles { display: flex; flex-direction: column; line-height: 1.2; }
.sa-titles .t { font-size: 15px; font-weight: 700; color: #f8fafc; }
.sa-titles .s { font-size: 11px; color: #8aa0b8; }
.sa-sep { width: 1px; align-self: stretch; background: #163a5f; margin: 14px 2px; }
.sa-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.sa-nav a {
    color: #cbd5e1; text-decoration: none; font-size: 13px; font-weight: 500;
    padding: 7px 12px; border-radius: 7px; transition: background .15s, color .15s;
}
.sa-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sa-nav a.active { background: #3075be; color: #fff; }
.sa-nav a.ext { color: #49abe9; }
.sa-nav a.ext:hover { color: #fff; }
.sa-logout { margin: 0; }
.sa-logout button {
    background: #dc2626; border: none; color: #fff; font-size: 13px; font-weight: 600;
    padding: 7px 14px; border-radius: 7px; cursor: pointer; font-family: inherit;
}
.sa-logout button:hover { background: #b91c1c; }

@media (max-width: 760px) {
    .sa-titles .s { display: none; }
    .sa-nav { width: 100%; margin: 8px 0 12px; }
}

/* ─────────────────────────────────────────────────────────────────────────
   2. LOGIN  (route: /siteadmin/login)
   ───────────────────────────────────────────────────────────────────────── */
body.sa-login {
    background: #04182d; color: #e2e8f0;
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sa-login .login-card { width: 100%; max-width: 380px; background: #0b2b49; border: 1px solid #163a5f; border-radius: 12px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.sa-login .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sa-login .logo-img { height: 46px; width: auto; display: block; }
.sa-login .brand .logo-icon { width: 36px; height: 36px; background: linear-gradient(135deg, #3075be, #49abe9); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; letter-spacing: -1px; }
.sa-login .brand .name { font-size: 16px; font-weight: 700; color: #f8fafc; }
.sa-login .sub { font-size: 13px; color: #94a3b8; margin-bottom: 24px; }
.sa-login .error { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); border-radius: 8px; padding: 10px 14px; margin-bottom: 18px; font-size: 13px; }
.sa-login label { display: block; font-size: 12px; font-weight: 600; color: #cbd5e1; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.sa-login .field { margin-bottom: 16px; }
.sa-login input[type=email], .sa-login input[type=password] {
    width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #163a5f;
    background: #04182d; color: #e2e8f0; font-size: 14px;
}
.sa-login input[type=email]:focus, .sa-login input[type=password]:focus { outline: none; border-color: #3075be; }
.sa-login .remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #94a3b8; margin-bottom: 22px; }
.sa-login .remember input { width: 15px; height: 15px; }
.sa-login .btn { width: 100%; padding: 11px; border: none; border-radius: 8px; background: #3075be; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.sa-login .btn:hover { background: #245a9a; }
.sa-login .foot { text-align: center; margin-top: 20px; font-size: 11px; color: #475569; }

/* ─────────────────────────────────────────────────────────────────────────
   3. API ACTIVITY LOG — list  (route: /siteadmin/api-logs)
   ───────────────────────────────────────────────────────────────────────── */
.sa-logs .container { max-width: 1400px; margin: 24px auto; padding: 0 16px; }

.sa-logs .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.sa-logs .stat-card { background: #fff; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sa-logs .stat-card .value { font-size: 28px; font-weight: 700; line-height: 1; }
.sa-logs .stat-card .label { font-size: 12px; color: #64748b; margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.sa-logs .stat-card.errors .value { color: #dc2626; }
.sa-logs .stat-card.today .value { color: #3075be; }

.sa-logs .filters { background: #fff; border-radius: 8px; padding: 16px 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sa-logs .filters form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.sa-logs .filter-group { display: flex; flex-direction: column; gap: 4px; }
.sa-logs .filter-group label { font-size: 11px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.sa-logs .filter-group input, .sa-logs .filter-group select { border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 10px; font-size: 13px; background: #f8fafc; }
.sa-logs .btn { padding: 7px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
.sa-logs .btn-primary { background: #3075be; color: #fff; }
.sa-logs .btn-secondary { background: #e2e8f0; color: #475569; }

.sa-logs .card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; }
.sa-logs table { width: 100%; border-collapse: collapse; }
.sa-logs thead th { background: #04182d; color: #94a3b8; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px; text-align: left; }
.sa-logs tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.sa-logs tbody tr:hover { background: #f8fafc; }
.sa-logs tbody td { padding: 10px 14px; vertical-align: middle; }
.sa-logs .method { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.sa-logs .method.GET    { background: #dbeafe; color: #1d4672; }
.sa-logs .method.POST   { background: #dcfce7; color: #15803d; }
.sa-logs .method.DELETE { background: #fee2e2; color: #b91c1c; }
.sa-logs .method.PUT, .sa-logs .method.PATCH { background: #fef9c3; color: #92400e; }
.sa-logs .badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.sa-logs .badge-ok  { background: #dcfce7; color: #15803d; }
.sa-logs .badge-err { background: #fee2e2; color: #b91c1c; }
.sa-logs .badge-warn { background: #fef9c3; color: #92400e; }
.sa-logs .path { font-family: monospace; font-size: 12px; color: #334155; }
.sa-logs .user-cell { font-size: 12px; }
.sa-logs .user-cell .uid { font-weight: 600; }
.sa-logs .user-cell .mail { color: #64748b; }
.sa-logs .slow { color: #dc2626; font-weight: 600; }
.sa-logs .detail-link { color: #3075be; text-decoration: none; font-size: 12px; }
.sa-logs .detail-link:hover { text-decoration: underline; }
.sa-logs .empty { text-align: center; padding: 40px; color: #94a3b8; }

.sa-logs .pagination-wrap { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; }
.sa-logs .pagination-info { font-size: 12px; color: #64748b; }
.sa-logs .pagination { display: flex; gap: 4px; }
.sa-logs .pagination a, .sa-logs .pagination span { padding: 5px 10px; border-radius: 5px; font-size: 13px; border: 1px solid #e2e8f0; text-decoration: none; color: #475569; }
.sa-logs .pagination .active span { background: #3075be; color: #fff; border-color: #3075be; }

/* ─────────────────────────────────────────────────────────────────────────
   4. API LOG DETAIL  (route: /siteadmin/api-logs/{id})
   ───────────────────────────────────────────────────────────────────────── */
.sa-log-show .container { max-width: 900px; margin: 24px auto; padding: 0 16px; }
.sa-log-show .card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; margin-bottom: 20px; }
.sa-log-show .card-header { background: #04182d; color: #94a3b8; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 10px 20px; }
.sa-log-show .row { display: flex; border-bottom: 1px solid #f1f5f9; }
.sa-log-show .row:last-child { border-bottom: none; }
.sa-log-show .row .key { width: 180px; min-width: 180px; padding: 12px 20px; font-size: 12px; font-weight: 600; color: #64748b; background: #f8fafc; }
.sa-log-show .row .val { padding: 12px 20px; font-size: 13px; flex: 1; }
.sa-log-show .method { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.sa-log-show .method.GET    { background: #dbeafe; color: #1d4672; }
.sa-log-show .method.POST   { background: #dcfce7; color: #15803d; }
.sa-log-show .method.DELETE { background: #fee2e2; color: #b91c1c; }
.sa-log-show .method.PUT, .sa-log-show .method.PATCH { background: #fef9c3; color: #92400e; }
.sa-log-show .badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.sa-log-show .badge-ok   { background: #dcfce7; color: #15803d; }
.sa-log-show .badge-err  { background: #fee2e2; color: #b91c1c; }
.sa-log-show .badge-warn { background: #fef9c3; color: #92400e; }
.sa-log-show pre { background: #04182d; color: #e2e8f0; border-radius: 6px; padding: 16px; font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.sa-log-show .back-btn { display: inline-block; margin-bottom: 16px; padding: 7px 16px; background: #e2e8f0; border-radius: 6px; text-decoration: none; color: #475569; font-size: 13px; font-weight: 600; }

/* ─────────────────────────────────────────────────────────────────────────
   5. API ENDPOINT MANAGER  (route: /siteadmin/api-endpoints)
   ───────────────────────────────────────────────────────────────────────── */
.sa-endpoints .container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }

.sa-endpoints .flash { background: #dcfce7; color: #166534; border: 1px solid #86efac; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; }

.sa-endpoints .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.sa-endpoints .stat-card { background: #fff; border-radius: 8px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sa-endpoints .stat-card .value { font-size: 28px; font-weight: 700; line-height: 1; }
.sa-endpoints .stat-card .label { font-size: 12px; color: #64748b; margin-top: 4px; text-transform: uppercase; letter-spacing: .05em; }
.sa-endpoints .stat-card.warn .value { color: #dc2626; }

.sa-endpoints .hint { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4672; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; }
.sa-endpoints .hint code { background: #dbeafe; padding: 1px 5px; border-radius: 4px; }
.sa-endpoints .env-tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-weight: 700; font-size: 11px; background: #3075be; color: #fff; text-transform: uppercase; }

.sa-endpoints .group { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow: hidden; margin-bottom: 20px; }
.sa-endpoints .group-head { background: #04182d; color: #fff; padding: 12px 18px; font-size: 14px; font-weight: 600; }
.sa-endpoints table { width: 100%; border-collapse: collapse; }
.sa-endpoints thead th { background: #0b2b49; color: #94a3b8; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 9px 16px; text-align: left; }
.sa-endpoints thead th.env-col { text-align: center; width: 180px; border-left: 1px solid #163a5f; }
.sa-endpoints tbody tr { border-bottom: 1px solid #f1f5f9; }
.sa-endpoints tbody tr:last-child { border-bottom: none; }
.sa-endpoints tbody tr:hover { background: #f8fafc; }
.sa-endpoints tbody td { padding: 11px 16px; vertical-align: middle; }
.sa-endpoints tbody td.env-col { text-align: center; border-left: 1px solid #f1f5f9; white-space: nowrap; }
.sa-endpoints .method { display: inline-block; width: 64px; text-align: center; padding: 3px 0; border-radius: 4px; font-size: 11px; font-weight: 700; }
.sa-endpoints .method.GET    { background: #dbeafe; color: #1d4672; }
.sa-endpoints .method.POST   { background: #dcfce7; color: #15803d; }
.sa-endpoints .method.DELETE { background: #fee2e2; color: #b91c1c; }
.sa-endpoints .method.PUT, .sa-endpoints .method.PATCH { background: #fef9c3; color: #92400e; }
.sa-endpoints .path { font-family: monospace; font-size: 12.5px; color: #334155; }
.sa-endpoints .summary { color: #64748b; font-size: 12px; }
.sa-endpoints .badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 10.5px; font-weight: 700; margin-right: 8px; }
.sa-endpoints .badge-on  { background: #dcfce7; color: #15803d; }
.sa-endpoints .badge-off { background: #fee2e2; color: #b91c1c; }
.sa-endpoints .btn { padding: 5px 12px; border-radius: 6px; border: none; cursor: pointer; font-size: 12px; font-weight: 600; color: #fff; }
.sa-endpoints .btn-disable { background: #dc2626; }
.sa-endpoints .btn-enable  { background: #16a34a; }

/* ─────────────────────────────────────────────────────────────────────────
   6. USER GUIDE EDITOR  (route: /siteadmin/guide/edit)
   ───────────────────────────────────────────────────────────────────────── */
.sa-guide-edit .container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }

.sa-guide-edit .flash { background: #dcfce7; color: #166534; border: 1px solid #86efac; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; }
.sa-guide-edit .error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; }

.sa-guide-edit .hint { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4672; border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; }
.sa-guide-edit .hint code { background: #dbeafe; padding: 1px 5px; border-radius: 4px; }

.sa-guide-edit .card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 20px; }
.sa-guide-edit .meta { font-size: 12px; color: #64748b; margin-bottom: 14px; }

.sa-guide-edit .actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.sa-guide-edit .btn { padding: 9px 18px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; color: #fff; text-decoration: none; display: inline-block; }
.sa-guide-edit .btn-save { background: #3075be; }
.sa-guide-edit .btn-save:hover { background: #245a9a; }
.sa-guide-edit .btn-preview { background: #475569; }
.sa-guide-edit .btn-preview:hover { background: #334155; }
.sa-guide-edit .note { font-size: 12px; color: #94a3b8; margin-left: auto; }
