/* ============================================================
   APCA Compliance DMS — SharePoint-Inspired Layout
   ============================================================ */

/* -- Variables -- */
:root {
    --apca: #EB4D25;
    --apca-dark: #c13b1a;
    --apca-light: #fceae6;
    --suite: #1b1b1f;
    --suite-text: #cdcdcf;
    --sidebar: #f3f3f4;
    --sidebar-hover: #e7e7e8;
    --sidebar-active: var(--apca-light);
    --sidebar-width: 220px;
    --white: #ffffff;
    --bg: #f8f9fa;
    --border: #e1e3e5;
    --text: #1b1b1f;
    --text-muted: #656973;
    --text-light: #96999e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 6px 16px rgba(0,0,0,.08);
    --radius: 6px;
    --radius-sm: 4px;
    --topbar-height: 48px;
}

/* -- Base -- */
* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Segoe UI Variable', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    font-size: .85rem;
    line-height: 1.5;
}

/* -- Suite bar (top thin bar) -- */
.suitebar {
    height: 32px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: .72rem;
    gap: 1rem;
}
.suitebar-brand {
    color: var(--apca);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    font-size: .78rem;
}
.suitebar-brand img { height: 18px; width: auto; }
.suitebar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* -- Top bar -- */
.topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 90;
    gap: .75rem;
    box-shadow: var(--shadow-sm);
}
.topbar-toggle {
    background: none;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: .25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.topbar-toggle:hover { background: var(--sidebar-hover); color: var(--text); }
.tb-icon { font-size: 1.1rem; line-height: 1; }
.topbar-breadcrumb { font-size: .85rem; color: var(--text-muted); }
.topbar-breadcrumb strong { color: var(--text); font-weight: 600; }
.topbar-breadcrumb span { margin: 0 .35rem; }
.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* -- Layout: sidebar + content -- */
.app-layout {
    display: flex;
    min-height: calc(100vh - 80px);
}
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: .5rem 0;
    overflow-y: auto;
    height: calc(100vh - 80px);
    position: sticky;
    top: 48px;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.sidebar-group {
    padding: .5rem .75rem .15rem;
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-light);
    font-weight: 600;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .75rem .5rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-size: .82rem;
    border-radius: 0 20px 20px 0;
    margin-right: .5rem;
    transition: all .1s ease;
    font-weight: 450;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--text);
}
.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--apca);
    font-weight: 600;
    border-right: 2px solid var(--apca);
}
.sidebar-link .sl-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    flex-shrink: 0;
}
.sidebar-link.active .sl-icon { color: var(--apca); }
.sidebar-link .sl-badge {
    margin-left: auto;
    background: var(--apca);
    color: #fff;
    font-size: .65rem;
    padding: .1rem .45rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.content-area {
    flex: 1;
    padding: 1.25rem 1.5rem;
    max-width: 1240px;
}

/* -- Content header -- */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.content-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}
.content-header .ch-subtitle {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

/* -- Brand accent -- */
.text-apca { color: var(--apca); }
.bg-apca { background: var(--apca); }
.bg-apca-light { background: var(--apca-light); }
.border-apca { border-color: var(--apca); }

.btn-apca {
    background: var(--apca);
    border-color: var(--apca);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: .4rem 1rem;
    font-size: .85rem;
    transition: all .12s ease;
}
.btn-apca:hover {
    background: var(--apca-dark);
    border-color: var(--apca-dark);
    color: #fff;
}
.btn-outline-apca {
    color: var(--apca);
    border-color: var(--apca);
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.btn-outline-apca:hover {
    background: var(--apca);
    border-color: var(--apca);
    color: #fff;
}

/* -- Card (SharePoint-like web part) -- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 0 0 0 rgba(0,0,0,0);
    margin-bottom: 1rem;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: .7rem 1rem;
    font-weight: 600;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: 1rem; }
.card-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: .6rem 1rem;
    font-size: .78rem;
    color: var(--text-muted);
}
.card:hover {
    box-shadow: var(--shadow);
}

/* -- Table (SharePoint list style) -- */
.table {
    font-size: .83rem;
    margin-bottom: 0;
}
.table thead th {
    font-weight: 600;
    color: var(--text);
    font-size: .78rem;
    padding: .65rem .85rem;
    border-bottom: 2px solid var(--border);
    background: var(--white);
}
.table td {
    padding: .6rem .85rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
.table-hover tbody tr:hover { background: #f0f0f1; }
.table-striped tbody tr:nth-child(odd) { background: #fafafa; }

/* -- Stats / KPI tiles -- */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    transition: box-shadow .12s ease;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
}
.stat-label {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 500;
    margin-top: .05rem;
}

/* -- Forms -- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid #c6c9ce;
    font-size: .85rem;
    padding: .4rem .7rem;
    background: var(--white);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--apca);
    box-shadow: 0 0 0 3px rgba(235, 77, 37, .1);
}
.form-label {
    font-weight: 500;
    font-size: .78rem;
    color: var(--text-muted);
    margin-bottom: .2rem;
}
.form-check-input:checked {
    background-color: var(--apca);
    border-color: var(--apca);
}

/* -- Buttons -- */
.btn {
    font-size: .85rem;
    border-radius: var(--radius-sm);
    padding: .38rem .95rem;
    font-weight: 500;
    transition: all .12s ease;
}
.btn-sm { padding: .25rem .6rem; font-size: .78rem; }
.btn-primary {
    background: var(--apca);
    border-color: var(--apca);
    color: #fff;
}
.btn-primary:hover {
    background: var(--apca-dark);
    border-color: var(--apca-dark);
    color: #fff;
}
.btn-outline-secondary { border-color: var(--border); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text); }

/* -- Badges -- */
.badge { font-weight: 500; font-size: .68rem; padding: .2em .55em; border-radius: 3px; }

/* -- Alerts -- */
.alert { border-radius: var(--radius-sm); font-size: .83rem; border: 0; padding: .6rem 1rem; }
.alert-danger { background: #fef2f2; color: #dc2626; }
.alert-success { background: #f0fdf4; color: #16a34a; }

/* -- Notice items -- */
.notice-item {
    padding: .85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .65rem;
    transition: border-color .12s ease;
}
.notice-item:hover { border-color: var(--apca); }
.notice-item.unread {
    background: var(--apca-light);
    border-left: 3px solid var(--apca);
}
.notice-date { font-size: .72rem; color: var(--text-muted); }

/* -- Activity -- */
.activity-item {
    padding: .55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .8rem;
}
.activity-item:last-child { border-bottom: 0; }
.activity-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    margin-right: .6rem;
    flex-shrink: 0;
}

/* -- Doc viewer layout -- */
.doc-sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--white);
    border-right: 1px solid var(--border);
}
.doc-list-item {
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .1s ease;
    display: flex;
    align-items: center;
    gap: .55rem;
}
.doc-list-item:hover { background: var(--apca-light); }
.doc-list-item.active { background: var(--apca-light); border-left: 3px solid var(--apca); }
.doc-layout { display: flex; min-height: calc(100vh - 80px); }
.doc-preview { flex: 1; background: var(--white); display: flex; flex-direction: column; }

/* -- Utility -- */
.page-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; letter-spacing: -.01em; }
.section-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding: .65rem .85rem .25rem;
    border-bottom: 1px solid var(--border);
}
.text-muted { color: var(--text-muted) !important; }

/* -- Landing page -- */
.landing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
}
.landing-suite {
    height: 32px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    color: var(--text-muted);
    font-size: .72rem;
}
.landing-suite img { height: 16px; margin-right: .5rem; }
.landing-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg) 0%, var(--apca-light) 100%);
}
.landing-card {
    background: var(--white);
    border-radius: 8px;
    padding: 3rem 4rem;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,.06);
    max-width: 480px;
    width: 100%;
    border: 1px solid var(--border);
}
.landing-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: .35rem;
}
.landing-card p.tagline { color: var(--text-muted); font-size: .88rem; margin-bottom: 1.25rem; }
.landing-card .btn { min-width: 140px; }
.landing-card img.logo-main { height: 44px; margin-bottom: 1rem; }

/* -- Modal -- */
.modal-content {
    border-radius: var(--radius);
    border: 0;
    box-shadow: var(--shadow-md);
}

/* -- Responsive -- */
@media (max-width: 991.98px) {
    .sidebar { width: 56px; min-width: 56px; }
    .sidebar .sidebar-link span:not(.sl-icon) { display: none; }
    .sidebar .sidebar-group { display: none; }
    .sidebar-link { justify-content: center; padding: .6rem .75rem; margin-right: 0; border-radius: 0; }
    .sidebar-link.active { border-right: 0; border-left: 2px solid var(--apca); }
}
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 80px;
        left: 0;
        bottom: 0;
        width: 240px;
        min-width: auto;
        height: calc(100vh - 80px);
        z-index: 1000;
        background: var(--white);
        border-right: 1px solid var(--border);
        box-shadow: 0 8px 30px rgba(0,0,0,.15);
        padding: .5rem 0;
        display: block !important;
        transition: transform .2s ease;
        transform: translateX(-100%);
        overflow-y: auto;
    }
    .sidebar.collapse.show {
        transform: translateX(0);
    }
    .sidebar:not(.show) {
        transform: translateX(-100%);
    }
    .sidebar .sidebar-link span:not(.sl-icon) { display: inline; }
    .sidebar .sidebar-group { display: block; }
    .sidebar-link { justify-content: flex-start; padding: .5rem .75rem .5rem 1rem; margin-right: .5rem; border-radius: 0 20px 20px 0; }
    .sidebar-link.active { border-right: 2px solid var(--apca); border-left: 0; }
    /* Mobile backdrop */
    .sidebar-backdrop {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,.3);
        z-index: 999;
        display: none;
    }
    .sidebar-backdrop.show { display: block; }
    .doc-sidebar { width: 100%; min-width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
    .landing-card { padding: 2rem 1.5rem; }
}