/* ===========================================================================
   Foundation ERP -- "Warm Orange" design system
   A light orange + white palette layered on top of Bootstrap 5.
   =========================================================================== */

:root {
    /* Brand ramp */
    --brand-50:  #FFF8F2;
    --brand-100: #FFEFE0;
    --brand-200: #FFDCBE;
    --brand-300: #FDBF8B;
    --brand-400: #FB9B4E;
    --brand-500: #F97316;
    --brand-600: #EA6206;
    --brand-700: #C24E05;

    /* Neutrals */
    --ink:        #1F2733;
    --ink-soft:   #55606E;
    --ink-muted:  #8A94A3;
    --line:       #F0E6DC;
    --line-strong:#E4D6C8;
    --surface:    #FFFFFF;
    --canvas:     #FFFAF5;

    /* Semantic accents kept in the same warm family */
    --success: #129C6E;
    --success-soft: #E6F7F1;
    --warning: #D98A00;
    --warning-soft: #FFF4DE;
    --danger:  #DC4B4B;
    --danger-soft: #FDECEC;
    --info:    #3A7BD5;
    --info-soft: #EAF2FD;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(31, 39, 51, .05);
    --shadow: 0 4px 18px rgba(194, 78, 5, .07);
    --shadow-lg: 0 14px 40px rgba(194, 78, 5, .12);

    --sidebar-w: 264px;

    /* Bootstrap overrides */
    --bs-primary: var(--brand-500);
    --bs-primary-rgb: 249, 115, 22;
    --bs-link-color: var(--brand-600);
    --bs-link-hover-color: var(--brand-700);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--line);
    --bs-focus-ring-color: rgba(249, 115, 22, .25);
}

* { -webkit-font-smoothing: antialiased; }

body {
    background: var(--canvas);
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: .925rem;
    overflow-x: hidden;
}

a { text-decoration: none; }

/* --------------------------------------------------------------- Sidebar */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(120deg, var(--brand-50), var(--surface));
}

.app-brand .brand-mark {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 6px 14px rgba(234, 98, 6, .28);
    flex: 0 0 auto;
}

/* When the tile holds an actual logo (uploaded or the bundled SVG) it sits on
   white rather than the orange gradient chip, so brand colours stay true. */
.app-brand .brand-mark-plain {
    background: transparent;
    box-shadow: none;
    padding: 2px;
}

.app-brand .brand-text { line-height: 1.15; min-width: 0; }
.app-brand .brand-title { font-weight: 800; font-size: 1rem; color: var(--ink); display: block; }
.app-brand .brand-sub { font-size: .7rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .09em; }

.app-nav { flex: 1; overflow-y: auto; padding: .75rem .75rem 2rem; }
.app-nav::-webkit-scrollbar { width: 6px; }
.app-nav::-webkit-scrollbar-thumb { background: var(--brand-200); border-radius: 8px; }

.nav-section {
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .11em;
    color: var(--ink-muted);
    font-weight: 700;
    padding: 1rem .75rem .4rem;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: .855rem;
    margin-bottom: 2px;
    position: relative;
    transition: background .16s ease, color .16s ease;
}

.nav-item-link i { width: 20px; text-align: center; font-size: .95rem; color: var(--ink-muted); transition: color .16s ease; }
.nav-item-link:hover { background: var(--brand-50); color: var(--brand-700); }
.nav-item-link:hover i { color: var(--brand-500); }

.nav-item-link.active {
    background: linear-gradient(90deg, var(--brand-100), var(--brand-50));
    color: var(--brand-700);
}
.nav-item-link.active i { color: var(--brand-600); }
.nav-item-link.active::before {
    content: '';
    position: absolute; left: -.75rem; top: 20%; bottom: 20%;
    width: 4px; border-radius: 0 4px 4px 0;
    background: var(--brand-500);
}

.nav-item-link .nav-count {
    margin-left: auto;
    background: var(--brand-100);
    color: var(--brand-700);
    border-radius: 20px;
    padding: .1rem .45rem;
    font-size: .68rem;
    font-weight: 700;
}

/* --------------------------------------------------------------- Topbar */
.app-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: .8rem 1.5rem;
    display: flex; align-items: center; gap: 1rem;
}

.app-topbar .page-title { font-weight: 800; font-size: 1.08rem; margin: 0; letter-spacing: -.01em; }
.app-topbar .page-sub { font-size: .77rem; color: var(--ink-muted); margin: 0; }

.topbar-icon-btn {
    width: 38px; height: 38px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    display: grid; place-items: center;
    transition: all .16s ease;
}
.topbar-icon-btn:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-600); }

.user-chip {
    display: flex; align-items: center; gap: .6rem;
    padding: .3rem .7rem .3rem .35rem;
    border-radius: 40px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600; font-size: .82rem;
}
.user-chip:hover { border-color: var(--brand-300); background: var(--brand-50); }

.avatar-initials {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
    color: #fff; display: grid; place-items: center;
    font-size: .72rem; font-weight: 800; letter-spacing: .02em;
    flex: 0 0 auto;
}

.app-content { padding: 1.5rem; flex: 1; }

/* --------------------------------------------------------------- Cards */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.25rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.card-header h5, .card-header h6 { margin: 0; font-weight: 800; font-size: .98rem; }
.card-body { padding: 1.25rem; }

.card-hover { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand-200); }

/* Stat tiles */
.stat-card { position: relative; overflow: hidden; }
.stat-card::after {
    content: ''; position: absolute; right: -28px; top: -28px;
    width: 96px; height: 96px; border-radius: 50%;
    background: var(--brand-50);
}
.stat-card > * { position: relative; z-index: 1; }
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-muted); font-weight: 700; }

/* The little arrow hint on clickable tiles; the whole card is the link. */
.stat-go { color: var(--brand-300); font-size: .78rem; margin-top: .25rem; transition: color .16s ease, transform .16s ease; }
.stat-card:hover .stat-go { color: var(--brand-600); transform: translateX(2px); }

/* Tiles sit four-up next to a 264px sidebar, so they get narrow well before
   phone widths. Ease the label spacing wherever the tile is tight. */
@media (max-width: 1399.98px) {
    .stat-label { letter-spacing: .03em; }
}

@media (max-width: 575.98px) {
    .stat-label { letter-spacing: .02em; font-size: .7rem; }
    .stat-card::after { display: none; }
    .stat-value { font-size: 1.45rem; }
}
.stat-value { font-size: 1.7rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.stat-foot { font-size: .75rem; color: var(--ink-muted); }

.icon-tile {
    width: 46px; height: 46px; border-radius: 13px;
    display: grid; place-items: center; font-size: 1.05rem; flex: 0 0 auto;
    background: var(--brand-100); color: var(--brand-600);
}
.icon-tile.tile-success { background: var(--success-soft); color: var(--success); }
.icon-tile.tile-warning { background: var(--warning-soft); color: var(--warning); }
.icon-tile.tile-danger  { background: var(--danger-soft);  color: var(--danger); }
.icon-tile.tile-info    { background: var(--info-soft);    color: var(--info); }
.icon-tile.tile-solid   { background: linear-gradient(135deg, var(--brand-400), var(--brand-600)); color: #fff; }
.icon-tile.sm { width: 36px; height: 36px; border-radius: 10px; font-size: .85rem; }

/* --------------------------------------------------------------- Buttons */
.btn { border-radius: var(--radius-sm); font-weight: 650; font-size: .85rem; padding: .48rem .95rem; }
.btn i { font-size: .8rem; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    border-color: var(--brand-600);
    box-shadow: 0 4px 12px rgba(234, 98, 6, .22);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    border-color: var(--brand-700);
}

.btn-soft {
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    color: var(--brand-700);
}
.btn-soft:hover { background: var(--brand-100); color: var(--brand-700); border-color: var(--brand-300); }

.btn-outline-primary { color: var(--brand-600); border-color: var(--brand-300); }
.btn-outline-primary:hover { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }

.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }

.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; }

/* --------------------------------------------------------------- Forms */
.form-label { font-weight: 650; font-size: .8rem; color: var(--ink-soft); margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--line-strong);
    padding: .5rem .75rem;
    font-size: .87rem;
    background-color: var(--surface);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .14);
}
.form-control::placeholder { color: #B9C0CA; }
.input-group-text { background: var(--brand-50); border-color: var(--line-strong); color: var(--brand-700); font-weight: 600; }
.form-check-input:checked { background-color: var(--brand-500); border-color: var(--brand-500); }
.form-switch .form-check-input:focus { box-shadow: 0 0 0 3px rgba(249, 115, 22, .14); }

.form-section-title {
    font-size: .78rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
    color: var(--brand-700); display: flex; align-items: center; gap: .5rem;
    margin: 0 0 1rem;
}
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* --------------------------------------------------------------- Tables */
.table { --bs-table-bg: transparent; margin: 0; font-size: .862rem; }
.table > thead th {
    background: var(--brand-50);
    color: var(--brand-700);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 800;
    border-bottom: 1px solid var(--line);
    padding: .7rem 1rem;
    white-space: nowrap;
}
.table > tbody td { padding: .72rem 1rem; border-color: var(--line); vertical-align: middle; }
.table > tbody tr:hover > td { background: var(--brand-50); }
.table-plain > tbody tr:hover > td { background: transparent; }

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--ink-muted); }
.empty-state i { font-size: 2.4rem; color: var(--brand-200); margin-bottom: .75rem; display: block; }
.empty-state h6 { color: var(--ink); font-weight: 700; }

/* --------------------------------------------------------------- Badges */
.badge { font-weight: 700; font-size: .68rem; padding: .34em .62em; border-radius: 7px; letter-spacing: .02em; }
.badge-soft-primary { background: var(--brand-100); color: var(--brand-700); }
.badge-soft-success { background: var(--success-soft); color: var(--success); }
.badge-soft-warning { background: var(--warning-soft); color: var(--warning); }
.badge-soft-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-soft-info    { background: var(--info-soft);    color: var(--info); }
.badge-soft-muted   { background: #F1F3F5; color: var(--ink-soft); }

/* --------------------------------------------------------- Utilities */
/* Bootstrap has no min-width utility; flex children need it to shrink and
   wrap instead of overflowing their card. */
.min-width-0 { min-width: 0; }

/* --------------------------------------------------------------- Misc */
.progress { height: 7px; border-radius: 10px; background: var(--brand-100); }
.progress-bar { background: linear-gradient(90deg, var(--brand-400), var(--brand-600)); border-radius: 10px; }
.progress-bar.bar-danger { background: linear-gradient(90deg, #F08A8A, var(--danger)); }
.progress-bar.bar-success { background: linear-gradient(90deg, #5FD0AB, var(--success)); }

.alert { border-radius: var(--radius-sm); border: 1px solid transparent; font-size: .86rem; }
.alert-success { background: var(--success-soft); border-color: #BFE9DA; color: #0B6B4C; }
.alert-danger  { background: var(--danger-soft);  border-color: #F5C9C9; color: #A32E2E; }
.alert-warning { background: var(--warning-soft); border-color: #F3DCA6; color: #8A5B00; }
.alert-info    { background: var(--brand-50);     border-color: var(--brand-200); color: var(--brand-700); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.breadcrumb { font-size: .78rem; margin: 0; }
.breadcrumb-item + .breadcrumb-item::before { content: '›'; color: var(--ink-muted); }
.breadcrumb-item a { color: var(--ink-muted); }
.breadcrumb-item.active { color: var(--brand-700); font-weight: 650; }

.filter-bar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin-bottom: 1.15rem;
}

.nav-tabs { border-bottom: 1px solid var(--line); gap: .25rem; }
.nav-tabs .nav-link {
    border: none; border-bottom: 2px solid transparent;
    color: var(--ink-soft); font-weight: 650; font-size: .86rem;
    padding: .6rem .9rem; border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--brand-600); border-bottom-color: var(--brand-200); }
.nav-tabs .nav-link.active { color: var(--brand-700); border-bottom-color: var(--brand-500); background: transparent; }

.dropdown-menu { border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .86rem; padding: .35rem; }
.dropdown-item { border-radius: 8px; padding: .45rem .65rem; font-weight: 600; color: var(--ink-soft); }
.dropdown-item:hover { background: var(--brand-50); color: var(--brand-700); }
.dropdown-item i { width: 18px; color: var(--ink-muted); }
.dropdown-item:hover i { color: var(--brand-500); }

.page-link { color: var(--brand-600); border-color: var(--line); border-radius: 8px !important; margin: 0 2px; font-size: .82rem; font-weight: 650; }
.page-item.active .page-link { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }

.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content: ''; position: absolute; left: .42rem; top: .4rem; bottom: .4rem; width: 2px; background: var(--brand-100); }
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.35rem; top: .3rem;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--brand-500); border: 2px solid var(--surface);
    box-shadow: 0 0 0 2px var(--brand-200);
}
.timeline-item.is-muted::before { background: var(--line-strong); box-shadow: 0 0 0 2px var(--line); }

.kv-list { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .55rem 1rem; font-size: .85rem; }
.kv-list dt { color: var(--ink-muted); font-weight: 600; }
.kv-list dd { margin: 0; font-weight: 620; color: var(--ink); word-break: break-word; }

.chart-shell { position: relative; height: 280px; }
.chart-shell.sm { height: 210px; }

.qr-poster {
    background: var(--surface);
    border: 2px dashed var(--brand-300);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
}

.stepper { display: flex; gap: .4rem; flex-wrap: wrap; }
.step-pill {
    display: flex; align-items: center; gap: .4rem;
    padding: .35rem .7rem; border-radius: 30px;
    background: #F4F6F8; color: var(--ink-muted);
    font-size: .74rem; font-weight: 700;
}
.step-pill.done { background: var(--success-soft); color: var(--success); }
.step-pill.current { background: linear-gradient(135deg, var(--brand-500), var(--brand-600)); color: #fff; }

/* Form builder */
.field-row {
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand-300);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: .9rem;
    margin-bottom: .75rem;
}
.field-row .drag-handle { cursor: grab; color: var(--ink-muted); }

/* Certificate rendering */
.cert-canvas {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.cert-frame {
    border: 10px solid var(--brand-500);
    outline: 2px solid var(--brand-200);
    outline-offset: 8px;
    padding: 3rem 2.5rem;
    text-align: center;
    font-family: Georgia, 'Times New Roman', serif;
    background: linear-gradient(160deg, #fff, var(--brand-50));
    min-height: 460px;
    display: flex; flex-direction: column; justify-content: center; gap: .35rem;
}
.cert-eyebrow { letter-spacing: .28em; text-transform: uppercase; font-size: .75rem; color: var(--brand-700); font-weight: 700; }
.cert-title { font-size: 2.2rem; margin: .5rem 0; color: var(--ink); letter-spacing: .02em; }
.cert-lead { color: var(--ink-soft); font-size: .95rem; margin: .2rem 0; }
.cert-name { font-size: 2rem; color: var(--brand-700); margin: .4rem 0; }
.cert-course { font-size: 1.35rem; color: var(--ink); margin: .3rem 0; }
.cert-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 2.5rem; font-size: .78rem; text-align: left; gap: 1rem; }
.cert-sign-name { font-weight: 700; border-top: 1px solid var(--ink-soft); padding-top: .3rem; }
.cert-sign-role { color: var(--ink-muted); }
.cert-meta { text-align: right; color: var(--ink-muted); line-height: 1.6; }

/* Auth screens */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-aside {
    background: linear-gradient(150deg, var(--brand-500), var(--brand-700));
    color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-aside::after {
    content: ''; position: absolute; right: -120px; bottom: -120px;
    width: 380px; height: 380px; border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
.auth-aside::before {
    content: ''; position: absolute; left: -90px; top: -90px;
    width: 260px; height: 260px; border-radius: 50%;
    background: rgba(255, 255, 255, .07);
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-feature { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; font-size: .88rem; }
.auth-feature i { margin-top: .2rem; opacity: .9; }

/* Responsive */
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .sidebar-backdrop.show {
        display: block; position: fixed; inset: 0;
        background: rgba(31, 39, 51, .45); z-index: 1035;
    }
    .kv-list { grid-template-columns: 1fr; gap: .2rem .5rem; }
    .kv-list dd { margin-bottom: .6rem; }
}

@media print {
    .app-sidebar, .app-topbar, .no-print, .btn { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { border: none; box-shadow: none; }
}
