/* ==========================================
   SayFlow Design System — app.css
   Modern CSS framework with utility classes
   ========================================== */

/* Base Variables */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --info: #0ea5e9;
    --info-hover: #0284c7;
    --secondary: #64748b;

    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;

    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-text: #f1f5f9;
    --sidebar-width: 260px;

    --border-color: #e2e8f0;
    --card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --transition: all 0.2s ease-in-out;
    --radius: 0.375rem;
    --radius-lg: 0.5rem;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   LAYOUT
   ========================================== */

.layout-wrapper {
    display: flex;
    min-height: 100vh;
    /* The wrapper is the full width of the viewport and nothing inside it may
       exceed that — otherwise the whole page scrolls sideways on a phone. */
    max-width: 100%;
    overflow-x: clip;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    max-width: 85vw;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo {
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo:hover {
    color: white;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-label {
    padding: 0.5rem 1.5rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: #cbd5e1;
    transition: var(--transition);
    font-size: 0.875rem;
    border-left: 3px solid transparent;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(99, 102, 241, 0.1);
    color: white;
    border-left-color: var(--primary);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar.small {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}

.user-role {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* Names long enough to overflow the sidebar footer get ellipsised instead. */
.user-details {
    min-width: 0;
}

.user-details .user-name,
.user-details .user-role {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dims the page behind the off-canvas sidebar and gives a tap target to
   close it — without one, the only way out was the small × in the corner. */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    /* min-width:0 lets this flex child shrink below the width of its widest
       child (a table); without it the child dictates the page width. */
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: 60px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Page Content */
.content-container {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

/* ==========================================
   GRID SYSTEM
   ========================================== */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Gutters come from a custom property so a row can ask for a tighter one with
   .g-1 … .g-4 — the columns pick it up without knowing which row they are in. */
.row {
    --gutter: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    margin: calc(var(--gutter) / -2);
}

.row.g-0 { --gutter: 0; }
.row.g-1 { --gutter: 0.5rem; }
.row.g-2 { --gutter: 0.75rem; }
.row.g-3 { --gutter: 1rem; }
.row.g-4 { --gutter: 1.5rem; }

/* min-width:0 is what stops a wide table or an unbroken string from forcing a
   flex column past its share and pushing the page into horizontal scroll. */
[class^="col-"],
[class*=" col-"] {
    width: 100%;
    min-width: 0;
    padding: calc(var(--gutter, 1.5rem) / 2);
}

.col-1  { width: 8.3333%; }
.col-2  { width: 16.6667%; }
.col-3  { width: 25%; }
.col-4  { width: 33.3333%; }
.col-5  { width: 41.6667%; }
.col-6  { width: 50%; }
.col-7  { width: 58.3333%; }
.col-8  { width: 66.6667%; }
.col-9  { width: 75%; }
.col-10 { width: 83.3333%; }
.col-11 { width: 91.6667%; }
.col-12 { width: 100%; }

@media (min-width: 576px) {
    .col-sm-1  { width: 8.3333%; }
    .col-sm-2  { width: 16.6667%; }
    .col-sm-3  { width: 25%; }
    .col-sm-4  { width: 33.3333%; }
    .col-sm-5  { width: 41.6667%; }
    .col-sm-6  { width: 50%; }
    .col-sm-7  { width: 58.3333%; }
    .col-sm-8  { width: 66.6667%; }
    .col-sm-9  { width: 75%; }
    .col-sm-10 { width: 83.3333%; }
    .col-sm-11 { width: 91.6667%; }
    .col-sm-12 { width: 100%; }
}

@media (min-width: 768px) {
    .col-md-1  { width: 8.3333%; }
    .col-md-2  { width: 16.6667%; }
    .col-md-3  { width: 25%; }
    .col-md-4  { width: 33.3333%; }
    .col-md-5  { width: 41.6667%; }
    .col-md-6  { width: 50%; }
    .col-md-7  { width: 58.3333%; }
    .col-md-8  { width: 66.6667%; }
    .col-md-9  { width: 75%; }
    .col-md-10 { width: 83.3333%; }
    .col-md-11 { width: 91.6667%; }
    .col-md-12 { width: 100%; }
}

@media (min-width: 992px) {
    .col-lg-1  { width: 8.3333%; }
    .col-lg-2  { width: 16.6667%; }
    .col-lg-3  { width: 25%; }
    .col-lg-4  { width: 33.3333%; }
    .col-lg-5  { width: 41.6667%; }
    .col-lg-6  { width: 50%; }
    .col-lg-7  { width: 58.3333%; }
    .col-lg-8  { width: 66.6667%; }
    .col-lg-9  { width: 75%; }
    .col-lg-10 { width: 83.3333%; }
    .col-lg-11 { width: 91.6667%; }
    .col-lg-12 { width: 100%; }
}

@media (min-width: 1200px) {
    .col-xl-1  { width: 8.3333%; }
    .col-xl-2  { width: 16.6667%; }
    .col-xl-3  { width: 25%; }
    .col-xl-4  { width: 33.3333%; }
    .col-xl-5  { width: 41.6667%; }
    .col-xl-6  { width: 50%; }
    .col-xl-7  { width: 58.3333%; }
    .col-xl-8  { width: 66.6667%; }
    .col-xl-9  { width: 75%; }
    .col-xl-10 { width: 83.3333%; }
    .col-xl-11 { width: 91.6667%; }
    .col-xl-12 { width: 100%; }
}

/* ==========================================
   DISPLAY & FLEXBOX
   ========================================== */

.d-flex {
    display: flex !important;
}

.d-inline {
    display: inline !important;
}

.d-block {
    display: block !important;
}

.d-inline-block {
    display: inline-block !important;
}

.d-none {
    display: none !important;
}

.d-inline-flex {
    display: inline-flex !important;
}

.d-grid {
    display: grid !important;
}

.d-table-cell {
    display: table-cell !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.flex-nowrap {
    flex-wrap: nowrap !important;
}

.flex-column {
    flex-direction: column !important;
}

.flex-row {
    flex-direction: row !important;
}

.flex-grow-1 {
    flex-grow: 1 !important;
}

.flex-shrink-0 {
    flex-shrink: 0 !important;
}

.flex-fill {
    flex: 1 1 auto !important;
}

.align-items-center {
    align-items: center !important;
}

.align-items-end {
    align-items: flex-end !important;
}

.align-items-start {
    align-items: flex-start !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.justify-content-center {
    justify-content: center !important;
}

.justify-content-start {
    justify-content: flex-start !important;
}

.justify-content-end {
    justify-content: flex-end !important;
}

.align-self-center {
    align-self: center !important;
}

.align-middle {
    vertical-align: middle !important;
}

.gap-0 {
    gap: 0 !important;
}

.gap-1 {
    gap: 0.25rem !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

.gap-4 {
    gap: 1.5rem !important;
}

/* ==========================================
   SPACING
   ========================================== */

.m-0 {
    margin: 0 !important;
}

.m-1 {
    margin: 0.25rem !important;
}

.m-2 {
    margin: 0.5rem !important;
}

.m-3 {
    margin: 1rem !important;
}

.mt-auto {
    margin-top: auto !important;
}

.mx-1 {
    margin-left: 0.25rem !important;
    margin-right: 0.25rem !important;
}

.mx-2 {
    margin-left: 0.5rem !important;
    margin-right: 0.5rem !important;
}

.mx-auto {
    margin-left: auto !important;
    margin-right: auto !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mt-1 {
    margin-top: 0.25rem !important;
}

.mt-2 {
    margin-top: 0.5rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mt-5 {
    margin-top: 3rem !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-2 {
    margin-bottom: 0.5rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mb-5 {
    margin-bottom: 3rem !important;
}

.ms-1 {
    margin-left: 0.25rem !important;
}

.ms-2 {
    margin-left: 0.5rem !important;
}

.ms-3 {
    margin-left: 1rem !important;
}

.ms-auto {
    margin-left: auto !important;
}

.me-1 {
    margin-right: 0.25rem !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.me-3 {
    margin-right: 1rem !important;
}

.p-0 {
    padding: 0 !important;
}

.p-1 {
    padding: 0.25rem !important;
}

.p-2 {
    padding: 0.5rem !important;
}

.p-3 {
    padding: 1rem !important;
}

.p-4 {
    padding: 1.5rem !important;
}

.p-5 {
    padding: 3rem !important;
}

.px-0 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.py-0 {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.px-2 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

.px-3 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

.px-4 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
}

.py-1 {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
}

.py-2 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.py-3 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

.py-4 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
}

.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

.pt-3 {
    padding-top: 1rem !important;
}

.pt-5 {
    padding-top: 3rem !important;
}

/* ==========================================
   SIZING
   ========================================== */

.w-100 {
    width: 100% !important;
}

.w-auto {
    width: auto !important;
}

.mw-100 {
    max-width: 100% !important;
}

.min-w-0 {
    min-width: 0 !important;
}

.h-100 {
    height: 100% !important;
}

.min-vh-100 {
    min-height: 100vh !important;
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

.h1,
h1 {
    font-size: 2rem;
    font-weight: 700;
}

.h2,
h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.h3,
h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.h4 {
    font-size: 1.1rem;
    font-weight: 600;
}

.h5 {
    font-size: 0.95rem;
    font-weight: 600;
}

.h6 {
    font-size: 0.85rem;
    font-weight: 600;
}

.fs-1 {
    font-size: 2.5rem !important;
}

.fs-2 {
    font-size: 2rem !important;
}

.fs-3 {
    font-size: 1.5rem !important;
}

.fs-4 {
    font-size: 1.25rem !important;
}

.fs-5 {
    font-size: 1rem !important;
}

.fs-6 {
    font-size: 0.875rem !important;
}

.fw-light {
    font-weight: 300 !important;
}

.fw-normal {
    font-weight: 400 !important;
}

.fw-medium {
    font-weight: 500 !important;
}

.fw-semibold {
    font-weight: 600 !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.fst-italic {
    font-style: italic !important;
}

.text-capitalize {
    text-transform: capitalize !important;
}

.text-uppercase {
    text-transform: uppercase !important;
}

.text-start {
    text-align: left !important;
}

.text-center {
    text-align: center !important;
}

.text-end {
    text-align: right !important;
}

.small {
    font-size: 0.8rem !important;
}

.text-sm {
    font-size: 0.8rem !important;
}

.text-nowrap {
    white-space: nowrap !important;
}

.text-break {
    overflow-wrap: break-word !important;
    word-break: break-word !important;
}

.text-truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* ==========================================
   COLORS
   ========================================== */

.text-primary {
    color: var(--primary) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-info {
    color: var(--info) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-dark {
    color: var(--text-main) !important;
}

.text-white {
    color: #fff !important;
}

.bg-light {
    background-color: var(--bg-light) !important;
}

.bg-white {
    background-color: var(--bg-white) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.bg-success {
    background-color: var(--success) !important;
}

.bg-danger {
    background-color: var(--danger) !important;
}

.bg-warning {
    background-color: var(--warning) !important;
}

.bg-info {
    background-color: var(--info) !important;
}

.bg-secondary {
    background-color: var(--secondary) !important;
}

.bg-transparent {
    background-color: transparent !important;
}

/* ==========================================
   BORDERS
   ========================================== */

.border {
    border: 1px solid var(--border-color) !important;
}

.border-0 {
    border: 0 !important;
}

.border-top {
    border-top: 1px solid var(--border-color) !important;
}

.border-bottom {
    border-bottom: 1px solid var(--border-color) !important;
}

.border-start {
    border-left: 1px solid var(--border-color) !important;
}

.border-start-0 {
    border-left: 0 !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.border-success {
    border-color: var(--success) !important;
}

.border-danger {
    border-color: var(--danger) !important;
}

.border-warning {
    border-color: var(--warning) !important;
}

.border-info {
    border-color: var(--info) !important;
}

.border-light {
    border-color: var(--border-color) !important;
}

.border-opacity-25 {
    --border-opacity: 0.25;
    border-color: rgba(0, 0, 0, 0.25) !important;
}

.rounded {
    border-radius: var(--radius) !important;
}

.rounded-circle {
    border-radius: 50% !important;
}

/* ==========================================
   SHADOWS & EFFECTS
   ========================================== */

.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}

.shadow {
    box-shadow: var(--shadow-md) !important;
}

.shadow-none {
    box-shadow: none !important;
}

.opacity-25 {
    opacity: 0.25 !important;
}

.opacity-50 {
    opacity: 0.5 !important;
}

.opacity-75 {
    opacity: 0.75 !important;
}

/* ==========================================
   POSITION
   ========================================== */

.position-relative {
    position: relative !important;
}

.position-absolute {
    position: absolute !important;
}

.overflow-hidden {
    overflow: hidden !important;
}

.overflow-visible {
    overflow: visible !important;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

.sidebar-toggle,
.sidebar-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-main);
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
}

.sidebar-toggle:hover {
    background-color: var(--bg-light);
}

.sidebar-close {
    color: white;
}

/* Below the large breakpoint the sidebar is off-canvas. It used to switch at
   768px, which left a 260px sidebar eating a third of a small tablet. */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    /* The page behind the open sidebar must not scroll under it. */
    body.sidebar-open {
        overflow: hidden;
    }
}

@media (min-width: 992px) {
    /* Desktop keeps the sidebar pinned, so the backdrop can never appear. */
    .sidebar-backdrop {
        display: none;
    }
}

/* Display utilities follow the usual "hidden from this breakpoint up" /
   "shown from this breakpoint up" pairing, so `d-none d-md-flex` works. */
@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-inline { display: inline !important; }
    .d-sm-inline-block { display: inline-block !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-inline { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
    .d-md-table-cell { display: table-cell !important; }
    .flex-md-row { flex-direction: row !important; }
    .text-md-end { text-align: right !important; }
    .w-md-auto { width: auto !important; }
    .mb-md-0 { margin-bottom: 0 !important; }
    .p-md-4 { padding: 1.5rem !important; }
    .p-md-5 { padding: 3rem !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-inline-block { display: inline-block !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }
}

/* ==========================================
   MOBILE TUNING
   ========================================== */

@media (max-width: 767.98px) {
    .content-container {
        padding: 1rem;
    }

    /* Full-bleed action buttons read as tap targets rather than stray chips. */
    .w-sm-100 {
        width: 100% !important;
    }
}

@media (max-width: 575.98px) {
    .content-container {
        padding: 0.75rem;
    }

    .topbar {
        padding: 0 0.75rem;
    }

    /* "Saypeace Solutions Ltd · Financial Reports" cannot fit; the page name is
       the half that tells you where you are, so the company name gives way. */
    .page-title {
        font-size: 1rem;
    }

    .page-title .company-name,
    .page-title .title-sep {
        display: none;
    }

    .page-title .page-name {
        color: var(--text-main) !important;
        font-weight: 700 !important;
    }

    .h1, h1 { font-size: 1.6rem; }
    .h2, h2 { font-size: 1.3rem; }
    .h3, h3 { font-size: 1.1rem; }

    .fs-1 { font-size: 1.9rem !important; }
    .fs-2 { font-size: 1.6rem !important; }
    .fs-3 { font-size: 1.3rem !important; }

    /* 3rem of padding on a 360px screen is most of the screen. */
    .p-5 { padding: 1.5rem !important; }
    .py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
}