/* =============================================================================
   COOPRA — Cooperative Management System
   Design system: Deep Blue #1557A0 · Sky #55A8E8 · Teal #16816B
   ========================================================================== */

:root {
    --coop-primary: #1557A0;
    --coop-primary-dark: #0F3F76;
    --coop-primary-light: #E8F1FA;
    --coop-secondary: #55A8E8;
    --coop-accent: #16816B;
    --coop-accent-light: #E6F4F1;
    --coop-bg: #F5F7FA;
    --coop-text: #172B4D;
    --coop-muted: #6B7A99;
    --coop-border: #E3E8F0;
    --coop-white: #FFFFFF;
    --coop-danger: #C62828;
    --coop-warning: #B26A00;
    --coop-success: #16816B;
    --sidebar-width: 260px;
    --sidebar-collapsed: 74px;
    --topbar-height: 64px;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(23, 43, 77, .06), 0 1px 3px rgba(23, 43, 77, .04);
    --shadow-md: 0 4px 12px rgba(23, 43, 77, .08);
    --shadow-lg: 0 12px 32px rgba(23, 43, 77, .12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    background: var(--coop-bg);
    color: var(--coop-text);
    font-size: 14.5px;
    line-height: 1.55;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--coop-text); font-weight: 600; letter-spacing: -.01em; }
a { color: var(--coop-primary); text-decoration: none; }
a:hover { color: var(--coop-primary-dark); }

.text-muted { color: var(--coop-muted) !important; }
.fw-semibold { font-weight: 600; }
.mono { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; }

/* ------------------------------------------------------------------ buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    padding: .5rem .95rem;
    transition: all .15s ease;
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn-primary { background: var(--coop-primary); border-color: var(--coop-primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--coop-primary-dark); border-color: var(--coop-primary-dark); color: #fff; }
.btn-accent { background: var(--coop-accent); border-color: var(--coop-accent); color: #fff; }
.btn-accent:hover { background: #116B58; color: #fff; }
.btn-outline-primary { color: var(--coop-primary); border-color: #c9dbef; }
.btn-outline-primary:hover { background: var(--coop-primary); border-color: var(--coop-primary); }
.btn-sm { padding: .3rem .65rem; font-size: 13px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ------------------------------------------------------------------ layout */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0F3F76 0%, #1557A0 100%);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease, width .25s ease;
    overflow: hidden;
}
.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    flex-shrink: 0;
}
.sidebar-brand img, .sidebar-brand .brand-logo { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.brand-sub { font-size: 10.5px; opacity: .75; letter-spacing: .08em; text-transform: uppercase; display: block; margin-top: -3px; }

.sidebar-scroll { overflow-y: auto; flex: 1; padding: .85rem .6rem 1.5rem; scrollbar-width: thin; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

.nav-section {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .1em;
    opacity: .55;
    padding: 1.1rem .8rem .35rem;
    font-weight: 600;
}
.sidebar .nav-link {
    color: rgba(255, 255, 255, .82);
    padding: .52rem .8rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: 14px;
    margin-bottom: 2px;
    transition: background .12s, color .12s;
}
.sidebar .nav-link i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar .nav-link.active { background: rgba(255, 255, 255, .18); color: #fff; font-weight: 600; }
.sidebar .nav-link .badge { margin-left: auto; font-size: 10px; }
.sidebar-footer { padding: .8rem; border-top: 1px solid rgba(255,255,255,.12); font-size: 11.5px; opacity: .8; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--coop-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar-title { font-size: 16px; font-weight: 600; margin: 0; }
.topbar .search-box { max-width: 320px; flex: 1; }
.topbar .search-box input { background: var(--coop-bg); border: 1px solid var(--coop-border); border-radius: 8px; padding: .42rem .8rem .42rem 2.1rem; }
.topbar .search-box i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--coop-muted); }

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

/* ------------------------------------------------------------------ cards */
.card {
    border: 1px solid var(--coop-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: #fff;
    margin-bottom: 1.25rem;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--coop-border);
    padding: .85rem 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-header h5, .card-header h6 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 1.15rem; }
.card-footer { background: #fff; border-top: 1px solid var(--coop-border); padding: .85rem 1.15rem; border-radius: 0 0 var(--radius) var(--radius); }

/* Stat cards */
.stat-card {
    border: 1px solid var(--coop-border);
    border-radius: var(--radius);
    background: #fff;
    padding: 1.05rem 1.15rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    height: 100%;
    transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .stat-icon {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: .8rem;
}
.stat-card .stat-label {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--coop-muted); font-weight: 600;
}
.stat-card .stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: .15rem; letter-spacing: -.02em; }
.stat-card .stat-meta { font-size: 12px; color: var(--coop-muted); margin-top: .25rem; }
.stat-card::after {
    content: ''; position: absolute; right: -20px; top: -20px;
    width: 80px; height: 80px; border-radius: 50%;
    background: currentColor; opacity: .045;
}

/* ------------------------------------------------------------------ tables */
.table { font-size: 14px; }
.table > :not(caption) > * > * { padding: .68rem .8rem; vertical-align: middle; }
.table thead th {
    background: var(--coop-bg);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--coop-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--coop-border);
    white-space: nowrap;
}
.table tbody tr:hover { background: #FAFBFD; }
.table .table-actions { white-space: nowrap; text-align: right; }
table.dataTable { border-collapse: collapse !important; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--coop-border); border-radius: 8px; padding: .35rem .6rem; font-size: 13.5px;
}
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { font-size: 13px; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }

/* ------------------------------------------------------------------ badges */
.badge { font-weight: 600; border-radius: 6px; }
.badge-soft-primary { background: var(--coop-primary-light); color: var(--coop-primary); }
.badge-soft-success { background: var(--coop-accent-light); color: var(--coop-accent); }

/* ------------------------------------------------------------------ forms */
.form-label { font-size: 13px; font-weight: 600; color: var(--coop-text); margin-bottom: .3rem; }
.form-control, .form-select {
    border: 1px solid var(--coop-border);
    border-radius: 8px;
    padding: .48rem .75rem;
    font-size: 14px;
    color: var(--coop-text);
}
.form-control:focus, .form-select:focus {
    border-color: var(--coop-secondary);
    box-shadow: 0 0 0 .2rem rgba(85, 168, 232, .18);
}
.form-control:disabled, .form-control[readonly] { background: var(--coop-bg); }
.form-text { font-size: 12px; color: var(--coop-muted); }
.invalid-feedback { font-size: 12.5px; }
.required-field::after { content: ' *'; color: var(--coop-danger); }
fieldset.fieldset-box { border: 1px solid var(--coop-border); border-radius: var(--radius); padding: 1rem 1.15rem 1.15rem; margin-bottom: 1.25rem; }
fieldset.fieldset-box legend { float: none; width: auto; padding: 0 .5rem; font-size: 13px; font-weight: 700; color: var(--coop-primary); }

/* ------------------------------------------------------------------ misc components */
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--coop-primary-light); color: var(--coop-primary);
    font-weight: 700; font-size: 13px; flex-shrink: 0;
    object-fit: cover;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--coop-muted); }
.empty-state i { font-size: 44px; opacity: .3; display: block; margin-bottom: .85rem; }
.empty-state h6 { color: var(--coop-text); margin-bottom: .3rem; }

.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--coop-border); }
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item::before {
    content: ''; position: absolute; left: -1.6rem; top: 5px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #fff; border: 2px solid var(--coop-secondary);
}
.timeline-item.completed::before { background: var(--coop-accent); border-color: var(--coop-accent); }
.timeline-item.rejected::before { background: var(--coop-danger); border-color: var(--coop-danger); }

.notification-item { padding: .7rem 1rem; border-bottom: 1px solid var(--coop-border); display: flex; gap: .7rem; }
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background: #F7FAFE; }
.notification-item .ni-title { font-weight: 600; font-size: 13.5px; }
.notification-item .ni-message { font-size: 12.5px; color: var(--coop-muted); }

.kv-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .85rem 1.5rem; }
.kv-item .kv-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--coop-muted); font-weight: 600; }
.kv-item .kv-value { font-size: 14.5px; font-weight: 500; }

.breadcrumb { font-size: 12.5px; margin-bottom: .5rem; }
.breadcrumb-item a { color: var(--coop-muted); }

.page-header { margin-bottom: 1.25rem; }
.page-header h4 { margin: 0; font-size: 20px; font-weight: 700; }
.page-header .page-subtitle { color: var(--coop-muted); font-size: 13.5px; }

.section-divider { height: 1px; background: var(--coop-border); margin: 1.25rem 0; }

/* Toast */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 1090; }

/* Auth / guest screens */
.auth-wrapper { min-height: 100vh; display: flex; }
.auth-side {
    background: linear-gradient(160deg, #0F3F76 0%, #1557A0 55%, #16816B 140%);
    color: #fff; padding: 3rem; flex: 1;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.auth-side::after {
    content: ''; position: absolute; right: -120px; bottom: -120px;
    width: 400px; height: 400px; border-radius: 50%;
    background: rgba(255,255,255,.05);
}
.auth-side h1 { color: #fff; font-size: 34px; font-weight: 700; line-height: 1.2; }
.auth-form-side { width: 480px; max-width: 100%; display: flex; align-items: center; justify-content: center; padding: 2.5rem; background: #fff; }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { width: 52px; height: 52px; border-radius: 12px; background: var(--coop-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 22px; margin-bottom: 1.25rem; }
.feature-list { list-style: none; padding: 0; margin-top: 2rem; }
.feature-list li { padding: .45rem 0; display: flex; align-items: center; gap: .65rem; opacity: .92; }
.feature-list i { color: #7FD1BE; font-size: 18px; }

/* Public marketing */
.public-nav { background: #fff; border-bottom: 1px solid var(--coop-border); position: sticky; top: 0; z-index: 1000; }
.hero {
    background: linear-gradient(135deg, #0F3F76 0%, #1557A0 60%, #16816B 160%);
    color: #fff; padding: 5rem 0 4.5rem;
}
.hero h1 { color: #fff; font-size: 44px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.hero p.lead { color: rgba(255,255,255,.88); font-size: 18px; }
.feature-card { background: #fff; border: 1px solid var(--coop-border); border-radius: var(--radius); padding: 1.5rem; height: 100%; transition: box-shadow .15s, transform .15s; }
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.feature-card .fc-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--coop-primary-light); color: var(--coop-primary); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 1rem; }
.plan-card { border: 1px solid var(--coop-border); border-radius: var(--radius); background: #fff; padding: 1.75rem; height: 100%; }
.plan-card.featured { border-color: var(--coop-primary); box-shadow: var(--shadow-md); position: relative; }
.plan-price { font-size: 32px; font-weight: 800; color: var(--coop-primary); }
.public-footer { background: #0F3F76; color: rgba(255,255,255,.8); padding: 2.5rem 0 1.5rem; }

/* Print / PDF */
@media print {
    .sidebar, .topbar, .no-print, .dataTables_filter, .dataTables_length, .dataTables_paginate { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff; font-size: 11px; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .page-content { padding: 0; }
}

.report-header { border-bottom: 2px solid var(--coop-primary); padding-bottom: .75rem; margin-bottom: 1.25rem; }
.report-header .rh-logo { max-height: 52px; }
.report-meta { font-size: 11px; color: #555; }
.report-table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.report-table th { background: var(--coop-primary); color: #fff; padding: 6px; text-align: left; font-size: 10px; text-transform: uppercase; }
.report-table td { padding: 5px 6px; border-bottom: 1px solid #e3e8f0; }
.report-table tr:nth-child(even) td { background: #f7f9fc; }
.report-footer { margin-top: 1.5rem; font-size: 9.5px; color: #777; border-top: 1px solid #ddd; padding-top: .5rem; text-align: center; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 63, 118, .45); z-index: 1035; }
    .sidebar-backdrop.show { display: block; }
    .topbar { padding: 0 .85rem; }
    .page-content { padding: 1rem .85rem; }
    .topbar .search-box { display: none; }
    .stat-card .stat-value { font-size: 19px; }
}
@media (max-width: 767.98px) {
    .auth-side { display: none; }
    .auth-form-side { width: 100%; padding: 1.5rem; }
    .hero { padding: 3rem 0 2.5rem; }
    .hero h1 { font-size: 30px; }
    .card-header { flex-direction: column; align-items: flex-start !important; }
    .table-responsive { font-size: 13px; }
}
