/* ═══════════════════════════════════════════════
   Dashboard CSS — Canifa AI System
   Uses CSS variables from lab.css
   ═══════════════════════════════════════════════ */

body{display:flex;flex-direction:row}

/* ═══ SIDEBAR ═══ */
.sidebar{width:240px;height:100vh;background:var(--s);border-right:1px solid var(--b);display:flex;flex-direction:column;position:fixed;top:0;bottom:0;left:0;z-index:100;overflow:hidden}
.sidebar-brand{padding:18px 20px;border-bottom:1px solid var(--b);display:flex;align-items:center;gap:12px;flex-shrink:0}
.brand-icon{width:40px;height:40px;background:var(--t);border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:1.3em;flex-shrink:0}
.brand-text h2{font-size:1em;font-weight:700;color:var(--t)}
.brand-text span{font-size:.7em;color:var(--m)}
.nav-group{padding:16px 12px 8px}
.nav-group-label{font-size:.65em;font-weight:700;text-transform:uppercase;letter-spacing:1.5px;color:var(--m);padding:0 12px;margin-bottom:8px}
.nav-item{display:flex;align-items:center;gap:12px;padding:10px 16px;border-radius:var(--rs);color:var(--m);text-decoration:none;font-size:.88em;font-weight:500;transition:all .2s;margin-bottom:2px;cursor:pointer}
.nav-item:hover{background:var(--bg);color:var(--t)}
.nav-item.active{background:var(--gold-l);color:var(--gold);font-weight:700;border-left:3px solid var(--gold)}
.nav-icon{font-size:1.1em;width:22px;text-align:center;flex-shrink:0}
.nav-badge{margin-left:auto;font-size:.7em;padding:2px 8px;border-radius:999px;font-weight:600}
.badge-live{background:var(--green-l);color:var(--green)}
.badge-new{background:var(--gold-l);color:var(--gold)}
.badge-beta{background:var(--orange-l);color:var(--orange)}
.badge-count{background:var(--blue-l);color:var(--blue)}
.sidebar-footer{margin-top:auto;padding:16px;border-top:1px solid var(--b);flex-shrink:0}
.version-info{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--bg);border-radius:var(--rs);border:1px solid var(--b)}
.version-dot{width:8px;height:8px;border-radius:50%;background:#16A34A;animation:dotpulse 2s infinite}
@keyframes dotpulse{0%,100%{box-shadow:0 0 0 0 rgba(22,163,74,.4)}50%{box-shadow:0 0 0 6px rgba(22,163,74,0)}}
.version-text{font-size:.78em;color:var(--m)}
.version-text strong{color:var(--t);font-weight:600}

/* ═══ MAIN AREA ═══ */
.main{margin-left:240px;flex:1;min-height:100vh;display:flex;flex-direction:column}
.topbar{padding:14px 24px;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--b);background:var(--s);position:sticky;top:0;z-index:50}
.topbar-left h1{font-size:1.3em;font-weight:700;color:var(--t)}
.topbar-left p{font-size:.8em;color:var(--m);margin-top:2px}
.topbar-right{display:flex;align-items:center;gap:10px}
.refresh-btn{display:flex;align-items:center;gap:6px;padding:8px 16px;background:var(--s);border:1px solid var(--b);border-radius:var(--rs);color:var(--m);font-size:.82em;font-weight:500;cursor:pointer;transition:all .2s;font-family:inherit}
.refresh-btn:hover{background:var(--bg);color:var(--t)}
.refresh-btn.spinning .r-icon{animation:spin .6s linear infinite}
@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}
.status-pill{display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:999px;font-size:.78em;font-weight:600;background:var(--green-l);color:var(--green);border:1px solid #A7F3D0}
.status-pill .dot{width:6px;height:6px;border-radius:50%;background:#16A34A;animation:dotpulse 2s infinite}
.content{flex:1;padding:24px;overflow-y:auto}

/* ═══ TABS ═══ */
.tab-bar{display:flex;gap:4px;margin-bottom:24px;background:var(--s);border:1px solid var(--b);padding:4px;border-radius:10px;width:fit-content}
.tab-btn{padding:8px 20px;border-radius:var(--rs);border:none;background:transparent;color:var(--m);font-family:inherit;font-size:.85em;font-weight:500;cursor:pointer;transition:all .2s;display:flex;align-items:center;gap:6px}
.tab-btn:hover{color:var(--t);background:var(--bg)}
.tab-btn.active{background:var(--gold-l);color:var(--gold);font-weight:700}
.tab-content{display:none}
.tab-content.active{display:block}

/* ═══ STATS ═══ */
.stats-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;margin-bottom:20px}
.stat-card{background:var(--s);border:1px solid var(--b);border-radius:var(--r);padding:18px;transition:all .25s}
.stat-card:hover{border-color:var(--gold);transform:translateY(-2px);box-shadow:0 4px 12px rgba(0,0,0,.06)}
.stat-label{font-size:.72em;font-weight:600;text-transform:uppercase;letter-spacing:1px;color:var(--m);margin-bottom:6px}
.stat-value{font-family:'Fraunces',serif;font-size:1.5em;font-weight:700;color:var(--t)}
.stat-value.purple{color:var(--diamond)}
.stat-value.blue{color:var(--blue)}
.stat-value.green{color:var(--green)}
.stat-value.amber{color:var(--gold)}
.stat-value.pink{color:#DB2777}
.stat-sub{font-size:.78em;color:var(--m);margin-top:4px}

/* ═══ CARDS ═══ */
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(380px,1fr));gap:14px;margin-bottom:20px}
.grid-full{grid-template-columns:1fr}
.card{background:var(--s);border:1px solid var(--b);border-radius:var(--r);overflow:hidden;transition:all .25s}
.card:hover{border-color:var(--gold)}
.card-head{display:flex;justify-content:space-between;align-items:center;padding:14px 18px;border-bottom:1px solid var(--b)}
.card-head h3{font-size:.9em;font-weight:700;color:var(--t);display:flex;align-items:center;gap:8px}
.card-head .tag{font-size:.7em;padding:2px 10px;border-radius:999px;font-weight:700}
.tag-green{background:var(--green-l);color:var(--green)}
.tag-amber{background:var(--gold-l);color:var(--gold)}
.tag-red{background:var(--red-l);color:var(--red)}
.card-body{padding:16px 18px}

/* ═══ SERVICES ═══ */
.svc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
.svc{padding:12px;background:var(--bg);border:1px solid var(--b);border-radius:var(--rs);transition:all .2s}
.svc:hover{border-color:var(--gold)}
.svc.ok{border-left:3px solid var(--green)}
.svc.fail{border-left:3px solid var(--red)}
.svc-name{font-size:.78em;font-weight:600;color:var(--m);margin-bottom:4px}
.svc-status{font-size:.82em;font-weight:500}
.svc-status.ok{color:var(--green)}
.svc-status.fail{color:var(--red)}
.hbar{margin-top:14px}
.hbar-bg{width:100%;height:6px;background:var(--bg);border-radius:999px;overflow:hidden}
.hbar-fill{height:100%;border-radius:999px;background:linear-gradient(90deg,#16A34A,#22C55E);transition:width 1s}
.hbar-label{display:flex;justify-content:space-between;font-size:.72em;color:var(--m);margin-top:6px}

/* ═══ KEY/CONFIG ═══ */
.key-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:10px}
.key-item{padding:12px;background:var(--bg);border:1px solid var(--b);border-radius:var(--rs)}
.key-label{font-size:.68em;font-weight:600;text-transform:uppercase;letter-spacing:.5px;color:var(--m);margin-bottom:4px}
.key-val{font-size:.85em;font-family:'JetBrains Mono',monospace}
.key-val.set{color:var(--green)}
.key-val.unset{color:var(--red)}
.cfg-table{width:100%;border-collapse:collapse}
.cfg-table tr{border-bottom:1px solid var(--b)}
.cfg-table tr:hover{background:var(--bg)}
.cfg-table tr:last-child{border-bottom:none}
.cfg-table td{padding:10px 8px;font-size:.85em}
.cfg-table td:first-child{color:var(--m);font-weight:500;width:180px}
.cfg-table td:last-child{color:var(--t);font-family:'JetBrains Mono',monospace;font-size:.82em}

/* ═══ FEEDBACK ═══ */
.fb-row{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}
.fb-card{background:var(--bg);border:1px solid var(--b);border-radius:10px;padding:16px;text-align:center;transition:all .2s}
.fb-card:hover{border-color:var(--gold);transform:translateY(-2px)}
.fb-num{font-family:'Fraunces',serif;font-size:1.8em;font-weight:700;margin-bottom:2px}
.fb-lbl{font-size:.72em;color:var(--m);text-transform:uppercase;letter-spacing:1px;font-weight:600}
.fb-total .fb-num{color:var(--blue)}
.fb-like .fb-num{color:var(--green)}
.fb-dislike .fb-num{color:var(--red)}
.fb-pending .fb-num{color:var(--gold)}

/* ═══ ROUTES ═══ */
.routes-list{max-height:350px;overflow-y:auto}
.route{display:flex;align-items:center;gap:10px;padding:8px 10px;border-bottom:1px solid var(--b);transition:background .15s}
.route:hover{background:var(--bg)}
.route:last-child{border-bottom:none}
.method{font-size:.65em;font-weight:700;padding:2px 7px;border-radius:4px;min-width:44px;text-align:center}
.m-GET{background:var(--green-l);color:var(--green)}
.m-POST{background:var(--blue-l);color:var(--blue)}
.m-PUT{background:var(--gold-l);color:var(--gold)}
.m-DELETE{background:var(--red-l);color:var(--red)}
.m-HEAD{background:var(--diamond-l);color:var(--diamond)}
.m-PATCH{background:#FDF2F8;color:#DB2777}
.route-path{font-family:'JetBrains Mono',monospace;font-size:.82em;color:var(--t)}

/* ═══ NOTES ═══ */
.notes-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}
.notes-header h2{font-size:1.1em;font-weight:700;color:var(--t);display:flex;align-items:center;gap:8px}
.notes-actions{display:flex;gap:8px}
.btn{padding:8px 16px;border-radius:var(--rs);border:1px solid var(--b);background:var(--s);color:var(--m);font-family:inherit;font-size:.82em;font-weight:500;cursor:pointer;transition:all .2s;display:flex;align-items:center;gap:6px}
.btn:hover{background:var(--bg);color:var(--t)}
.btn-primary{background:var(--t);border-color:transparent;color:#fff}
.btn-primary:hover{opacity:.9;transform:translateY(-1px)}
.btn-danger{border-color:#FCA5A5;color:var(--red)}
.btn-danger:hover{background:var(--red-l)}
.btn-sm{padding:5px 10px;font-size:.75em}
.notes-filter{display:flex;gap:6px;margin-bottom:16px;flex-wrap:wrap}
.filter-chip{padding:5px 12px;border-radius:999px;border:1px solid var(--b);background:transparent;color:var(--m);font-family:inherit;font-size:.75em;font-weight:600;cursor:pointer;transition:all .2s}
.filter-chip:hover{border-color:var(--gold);color:var(--t)}
.filter-chip.active{background:var(--gold-l);color:var(--gold);border-color:var(--gold-b)}
.notes-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:14px}
.note-card{background:var(--s);border:1px solid var(--b);border-radius:var(--r);overflow:hidden;transition:all .25s;position:relative}
.note-card:hover{border-color:var(--gold);transform:translateY(-2px);box-shadow:0 4px 12px rgba(0,0,0,.06)}
.note-card.pinned{border-color:var(--gold-b)}
.note-card.pinned::after{content:'📌';position:absolute;top:12px;right:12px;font-size:.9em}
.note-color-bar{height:3px;width:100%}
.note-body{padding:16px}
.note-cat{display:inline-flex;align-items:center;gap:4px;font-size:.65em;font-weight:700;text-transform:uppercase;letter-spacing:1px;padding:2px 8px;border-radius:4px;margin-bottom:10px}
.cat-note{background:var(--blue-l);color:var(--blue)}
.cat-doc{background:var(--diamond-l);color:var(--diamond)}
.cat-todo{background:var(--gold-l);color:var(--gold)}
.cat-announcement{background:var(--red-l);color:var(--red)}
.note-title{font-size:.95em;font-weight:700;color:var(--t);margin-bottom:8px;line-height:1.4}
.note-content{font-size:.82em;color:var(--m);line-height:1.6;margin-bottom:12px;max-height:120px;overflow:hidden;white-space:pre-wrap;word-break:break-word}
.note-footer{display:flex;justify-content:space-between;align-items:center;padding-top:10px;border-top:1px solid var(--b)}
.note-meta{font-size:.7em;color:var(--f)}
.note-actions{display:flex;gap:4px}
.note-act-btn{width:28px;height:28px;border-radius:6px;border:1px solid var(--b);background:transparent;color:var(--f);font-size:.82em;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s}
.note-act-btn:hover{background:var(--bg);color:var(--t)}
.note-act-btn.pin-active{color:var(--gold);border-color:var(--gold-b)}

/* ═══ LINKS ═══ */
.link-card{background:var(--s);border:1px solid var(--b);border-radius:var(--r);padding:16px;transition:all .25s;position:relative;display:flex;gap:14px;align-items:flex-start}
.link-card:hover{border-color:var(--gold);transform:translateY(-2px);box-shadow:0 4px 12px rgba(0,0,0,.06)}
.link-card.pinned{border-color:var(--gold-b)}
.link-icon{width:42px;height:42px;border-radius:10px;background:var(--bg);display:flex;align-items:center;justify-content:center;font-size:1.3em;flex-shrink:0;border:1px solid var(--b)}
.link-info{flex:1;min-width:0}
.link-cat-tag{display:inline-flex;font-size:.6em;font-weight:700;text-transform:uppercase;letter-spacing:1px;padding:1px 6px;border-radius:3px;margin-bottom:6px}
.lcat-tool{background:var(--green-l);color:var(--green)}
.lcat-doc{background:var(--diamond-l);color:var(--diamond)}
.lcat-design{background:#FDF2F8;color:#DB2777}
.lcat-api{background:var(--blue-l);color:var(--blue)}
.lcat-repo{background:var(--gold-l);color:var(--gold)}
.lcat-other{background:var(--bg);color:var(--m)}
.link-title{font-size:.92em;font-weight:700;color:var(--t);margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.link-url{font-size:.75em;color:var(--blue);font-family:'JetBrains Mono',monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:4px;cursor:pointer}
.link-url:hover{text-decoration:underline}
.link-desc{font-size:.78em;color:var(--m);line-height:1.5;max-height:40px;overflow:hidden}
.link-actions-row{display:flex;gap:4px;flex-shrink:0;align-self:center}
.link-act{width:28px;height:28px;border-radius:6px;border:1px solid var(--b);background:transparent;color:var(--f);font-size:.78em;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s}
.link-act:hover{background:var(--bg);color:var(--t)}

/* ═══ CHANGELOG ═══ */
.changelog-form{display:flex;gap:10px;margin-bottom:20px;background:var(--s);border:1px solid var(--b);border-radius:var(--r);padding:14px}
.changelog-form input{flex:1}
.changelog-form .author-input{max-width:140px}
.changelog-entry{display:flex;gap:14px;padding:14px 0;border-bottom:1px solid var(--b);position:relative}
.changelog-entry:last-child{border-bottom:none}
.cl-dot{width:10px;height:10px;border-radius:50%;background:var(--gold);margin-top:5px;flex-shrink:0;box-shadow:0 0 6px rgba(180,83,9,.3)}
.cl-body{flex:1;min-width:0}
.cl-meta{display:flex;gap:10px;align-items:center;margin-bottom:4px}
.cl-author{font-weight:700;color:var(--t);font-size:.85em}
.cl-time{font-size:.75em;color:var(--f)}
.cl-content{font-size:.88em;color:var(--m);line-height:1.6}
.cl-delete{position:absolute;right:0;top:14px;width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--f);font-size:.7em;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s;opacity:0}
.changelog-entry:hover .cl-delete{opacity:1}
.cl-delete:hover{background:var(--red-l);color:var(--red)}
.cl-line{position:absolute;left:4px;top:24px;bottom:0;width:2px;background:var(--b)}

/* ═══ ROLE MODAL ═══ */
.role-modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.4);z-index:300;display:none;align-items:center;justify-content:center;backdrop-filter:blur(4px)}
.role-modal-overlay.show{display:flex}
.role-modal{background:var(--s);border:1px solid var(--b);border-radius:16px;width:450px;max-width:90vw;box-shadow:0 20px 60px rgba(0,0,0,.15);animation:modalIn .2s ease-out}
.role-user-row{display:flex;justify-content:space-between;align-items:center;padding:10px 16px;border-bottom:1px solid var(--b)}
.role-user-row:last-child{border-bottom:none}
.role-user-name{color:var(--t);font-weight:600;font-size:.9em}
.role-badge{padding:2px 10px;border-radius:10px;font-size:.75em;font-weight:700}
.role-badge.admin{background:var(--gold-l);color:var(--gold)}
.role-badge.user{background:var(--bg);color:var(--m)}
.role-remove-btn{background:none;border:none;color:var(--f);cursor:pointer;font-size:.9em}
.role-remove-btn:hover{color:var(--red)}
.role-add-form{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--b)}
.role-add-form input,.role-add-form select{padding:8px 12px;background:var(--bg);border:1px solid var(--b);border-radius:var(--rs);color:var(--t);font-family:inherit;font-size:.85em}
.role-add-form input{flex:1}
.role-add-form select{width:100px}
.role-add-form button{padding:8px 16px;background:var(--t);border:none;border-radius:var(--rs);color:#fff;font-weight:700;cursor:pointer;font-size:.85em}
.settings-btn{background:none;border:1px solid var(--b);border-radius:var(--rs);color:var(--m);padding:8px 14px;cursor:pointer;font-size:.85em;transition:all .2s;font-family:inherit}
.settings-btn:hover{background:var(--bg);color:var(--t)}

/* ═══ MODALS ═══ */
.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.4);z-index:200;display:none;align-items:center;justify-content:center;backdrop-filter:blur(4px)}
.modal-overlay.show{display:flex}
.modal{background:var(--s);border:1px solid var(--b);border-radius:16px;width:550px;max-width:90vw;box-shadow:0 20px 60px rgba(0,0,0,.15);animation:modalIn .2s ease-out}
@keyframes modalIn{from{transform:scale(.95) translateY(10px);opacity:0}to{transform:scale(1) translateY(0);opacity:1}}
.modal-head{padding:20px 24px;border-bottom:1px solid var(--b);display:flex;justify-content:space-between;align-items:center}
.modal-head h3{font-size:1em;font-weight:700;color:var(--t)}
.modal-close{background:none;border:none;color:var(--f);font-size:1.3em;cursor:pointer;transition:color .15s;padding:4px}
.modal-close:hover{color:var(--red)}
.modal-body{padding:24px}
.form-group{margin-bottom:16px}
.form-label{display:block;font-size:.78em;font-weight:600;color:var(--m);margin-bottom:6px}
.form-input,.form-textarea,.form-select{width:100%;padding:10px 14px;background:var(--bg);border:1px solid var(--b);border-radius:var(--rs);color:var(--t);font-family:inherit;font-size:.88em;transition:all .2s}
.form-input:focus,.form-textarea:focus,.form-select:focus{outline:none;border-color:var(--gold);box-shadow:0 0 0 3px rgba(180,83,9,.1)}
.form-textarea{min-height:120px;resize:vertical;line-height:1.6}
.form-select{cursor:pointer}
.form-select option{background:var(--s)}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.color-dots{display:flex;gap:8px;margin-top:6px}
.color-dot{width:24px;height:24px;border-radius:50%;border:2px solid transparent;cursor:pointer;transition:all .15s}
.color-dot:hover{transform:scale(1.2)}
.color-dot.active{border-color:var(--t);box-shadow:0 0 0 2px rgba(0,0,0,.1)}
.modal-foot{padding:16px 24px;border-top:1px solid var(--b);display:flex;justify-content:flex-end;gap:10px}

/* ═══ EMPTY/LOADING ═══ */
.empty-state{text-align:center;padding:60px 20px;color:var(--m)}
.empty-state .empty-icon{font-size:3em;margin-bottom:12px;opacity:.5}
.empty-state p{font-size:.9em;margin-bottom:16px}
.loading{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:80px;color:var(--m)}
.loading .spinner{width:36px;height:36px;border:3px solid var(--b);border-top-color:var(--gold);border-radius:50%;animation:spin .7s linear infinite;margin-bottom:16px}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar{width:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--b);border-radius:3px}
::-webkit-scrollbar-thumb:hover{background:var(--m)}

/* ═══ RESPONSIVE ═══ */
@media(max-width:1024px){
    .sidebar{width:64px}
    .sidebar .brand-text,.sidebar .nav-group-label,.sidebar .nav-item span,.sidebar .nav-badge,.sidebar .version-text,.sidebar .version-dot{display:none}
    .sidebar .nav-item{justify-content:center;padding:12px}
    .sidebar-brand{justify-content:center;padding:16px}
    .main{margin-left:64px}
    .grid{grid-template-columns:1fr}
    .fb-row{grid-template-columns:repeat(2,1fr)}
}

/* ═══ IFRAME MODE: hide sidebar when embedded ═══ */
html.in-iframe .sidebar{display:none!important}
html.in-iframe .main{margin-left:0!important}
