/* =========================================================
   SDAA GLOBAL STYLESHEET
   Clean responsive base for sidebar/topbar/admin/member pages
========================================================= */

/* =========================================================
   ROOT
========================================================= */

:root {
    --green-dark: #1f4d36;
    --green-main: #2f6b4f;
    --green-light: #edf5ef;
    --green-soft: #f4faf6;

    --cream: #f7f4ea;

    --border: #d8e0d6;

    --text: #1f2a22;
    --muted: #6c746f;

    --white: #ffffff;

    --red: #d9534f;
    --amber: #e3a008;
    --blue: #2563eb;
    --grey: #7b8794;

    --shadow: 0 10px 30px rgba(0,0,0,0.08);
    --shadow-soft: 0 6px 18px rgba(0,0,0,0.06);

    --radius: 18px;
    --sidebar-width: 260px;
}

/* =========================================================
   RESET / BASE
========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;
    background: var(--cream);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* =========================================================
   LAYOUT
========================================================= */

.layout-shell {
    min-height: 100vh;
}

.page-shell {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: var(--sidebar-width);
    background: var(--green-dark);
    color: white;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-inner {
    padding: 28px 20px;
}

.sidebar-heading {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.sidebar-nav {
    display: block;
}

.sidebar-section {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.7;
    margin: 28px 0 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 6px;
    transition: 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link:focus {
    background: rgba(255,255,255,0.08);
}

.sidebar-icon {
    width: 42px;
    min-width: 42px;
    text-align: center;
    font-size: 0.72rem;
    opacity: 0.75;
}

.sidebar-link-text {
    flex: 1;
}

/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    min-height: 72px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 500;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
}

.topbar-link {
    color: var(--muted);
    font-size: 0.95rem;
    white-space: nowrap;
}

.topbar-link:hover {
    color: var(--green-main);
}

.topbar-menu-button {
    display: none;
    border: 0;
    background: transparent;
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
}

/* =========================================================
   TOPBAR NOTIFICATION BADGE
========================================================= */

.topbar-notification-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.topbar-notification-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.topbar-notification-badge {
    position: absolute;
    top: -9px;
    right: -11px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #d93c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* =========================================================
   TASK STRIP
========================================================= */

.task-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 14px 22px;
    background: linear-gradient(90deg, #1f5f2c, #2f7a3d);
    color: white;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.task-strip-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.task-strip-left span {
    opacity: 0.92;
    font-size: 0.92rem;
}

.task-strip-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    background: white;
    color: #5f561f;
    border-radius: 10px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.task-strip-button:hover {
    opacity: 0.92;
}

/* =========================================================
   MAIN CONTENT
========================================================= */

.main-content {
    flex: 1;
    width: 100%;
    padding: 28px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.page-header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.page-description {
    color: var(--muted);
}

/* =========================================================
   CARDS
========================================================= */

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text);
}

/* =========================================================
   BUTTONS
========================================================= */

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    border: 0;
    background: var(--green-main);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
    font: inherit;
}

.button:hover,
button.button:hover {
    opacity: 0.92;
}

.button-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.button-red {
    background: var(--red);
    color: white;
}

.button-amber {
    background: var(--amber);
    color: white;
}

/* =========================================================
   STATUS BADGES
========================================================= */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-green {
    background: rgba(47,107,79,0.12);
    color: var(--green-main);
}

.status-red {
    background: rgba(217,83,79,0.12);
    color: var(--red);
}

.status-amber {
    background: rgba(227,160,8,0.14);
    color: var(--amber);
}

.status-blue {
    background: rgba(37,99,235,0.12);
    color: var(--blue);
}

.status-grey {
    background: rgba(123,135,148,0.14);
    color: var(--grey);
}

/* =========================================================
   TABLES
========================================================= */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.table th {
    font-size: 0.82rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.04em;
}

/* =========================================================
   FORMS
========================================================= */

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    font: inherit;
}

.form-textarea,
textarea {
    min-height: 140px;
    resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(47,107,79,0.18);
    border-color: var(--green-main);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

/* =========================================================
   COMMON GRIDS
========================================================= */

.dashboard-stats-grid,
.dashboard-quick-grid,
.dashboard-panels-grid,
.member-dashboard-stats,
.member-dashboard-quick-grid,
.member-dashboard-grid,
.rep-dashboard-stats,
.rep-dashboard-quick-grid,
.incident-view-grid,
.rep-incident-view-grid,
.member-incident-view-grid,
.task-view-grid,
.message-view-grid {
    min-width: 0;
}

.dashboard-stats-grid,
.dashboard-quick-grid,
.member-dashboard-stats,
.member-dashboard-quick-grid,
.rep-dashboard-stats,
.rep-dashboard-quick-grid {
    display: grid;
    gap: 18px;
}

/* =========================================================
   MOBILE OVERLAY
========================================================= */

.sidebar-backdrop {
    display: none;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1100px) {
    .dashboard-stats-grid,
    .dashboard-quick-grid,
    .rep-dashboard-stats,
    .rep-dashboard-quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .dashboard-panels-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 900px) {

    :root {
        --sidebar-width: 260px;
    }

    body {
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 9999;
        box-shadow: 8px 0 24px rgba(0,0,0,0.18);
    }

    .sidebar.mobile-open,
    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .page-shell {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .topbar {
        width: 100%;
        min-height: 64px;
        padding: 10px 14px;
        gap: 10px;
        overflow: visible;
    }

    .topbar-menu-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar-left {
        min-width: 0;
        gap: 10px;
    }

    .topbar-right {
        gap: 10px;
        font-size: 0.9rem;
        min-width: 0;
    }

    .topbar-brand {
        font-size: 1rem;
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-link {
        font-size: 0.88rem;
    }

    .topbar-notification-text {
        display: none;
    }

    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding: 18px !important;
    }

    .page-header,
    .card {
        width: 100%;
        max-width: 100%;
    }

    .page-title {
        font-size: 1.65rem;
        line-height: 1.2;
        word-break: normal;
    }

    .page-header-flex {
        flex-direction: column;
    }

    .card {
        padding: 18px;
        border-radius: 16px;
    }

    .button,
    button.button {
        width: 100%;
    }

    .page-header-actions,
    .task-strip,
    .task-strip-left {
        width: 100%;
    }

    .task-strip {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 18px;
    }

    .task-strip-button {
        width: 100%;
    }

    .form-grid,
    .dashboard-stats-grid,
    .dashboard-quick-grid,
    .dashboard-panels-grid,
    .member-dashboard-stats,
    .member-dashboard-quick-grid,
    .member-dashboard-grid,
    .rep-dashboard-stats,
    .rep-dashboard-quick-grid,
    .incident-view-grid,
    .rep-incident-view-grid,
    .member-incident-view-grid,
    .task-view-grid,
    .message-view-grid,
    .message-create-grid,
    .incident-create-grid,
    .member-report-grid,
    .task-create-grid {
        grid-template-columns: 1fr !important;
    }

    .table-wrapper,
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .hide-mobile {
        display: none !important;
    }
}

@media (max-width: 560px) {

    .topbar {
        padding: 8px 10px;
    }

    .topbar-right {
        gap: 8px;
    }

    .topbar-link {
        font-size: 0.82rem;
    }

    .topbar-brand {
        max-width: 76px;
    }

    .main-content {
        padding: 14px !important;
    }

    .page-title {
        font-size: 1.45rem;
    }

    .card {
        padding: 16px;
    }

    .status-badge {
        font-size: 0.78rem;
    }
}

/* =========================================================
   PRINT
========================================================= */

@media print {
    .sidebar,
    .topbar,
    .task-strip,
    .button,
    button {
        display: none !important;
    }

    .page-shell {
        margin-left: 0 !important;
    }

    .main-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}