/* ── HubSpot-Inspired Design System ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');

:root {
    /* HubSpot Colors */
    --hs-orange: var(--primary);
    --hs-orange-dark: var(--primary-dark, #c0542f);
    --hs-orange-light: #fff4f1;
    --hs-navy: #2d3e50;
    --hs-navy-dark: #1e2c3a;
    --hs-navy-mid: #3d5166;
    --hs-blue: #0091ae;
    --hs-blue-light: #ebf7fa;
    --hs-success: #00bda5;
    --hs-success-light: #e5f8f6;
    --hs-warning: #f5c26b;
    --hs-warning-light: #fef9ec;
    --hs-danger: #f2545b;
    --hs-danger-light: #fef0f0;

    /* Backgrounds */
    --bg: #f5f8fa;
    --bg-white: #ffffff;
    --bg-hover: #f0f4f8;

    /* Text */
    --text-main: #33475b;
    --text-muted: #516f90;
    --text-light: #7c98b6;
    --text-sidebar: #cbd6e2;
    --text-white: #ffffff;

    /* Borders */
    --border-color: #dfe3eb;
    --border-focus: #00a4bd;

    /* Sidebar */
    --sidebar-bg: #2d3e50;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);

    /* Shadows */
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Primary is the tenant's brand color (injected by layout.php) */
    --primary: #ff7a59;
    --primary-dark: #e8694b;
}

/* ── Reset & Base ──────────────────────────────────────────── */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Lexend', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    font-size: 0.9375rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: none;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.sidebar .brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
}

.sidebar .brand img {
    max-height: 30px;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.brand-icon {
    width: 30px;
    height: 30px;
    background: var(--hs-orange);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

.brand-icon i {
    color: #fff;
    font-size: 1rem;
}

.brand-text {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.01em;
}

.sidebar .nav-section {
    padding: 0.75rem 0;
}

.sidebar .nav-section-title {
    padding: 0.5rem 1.25rem 0.35rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--text-sidebar);
    opacity: 0.6;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
    border-radius: 0;
    margin: 0 0.5rem;
    border-radius: var(--radius-sm);
}

.sidebar a:hover {
    background: var(--sidebar-active-bg);
    color: #fff;
}

.sidebar a.active {
    background: rgba(255, 122, 89, 0.15);
    color: var(--hs-orange);
    font-weight: 500;
}

.sidebar a i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    margin-left: 240px;
    padding: 2rem 2.5rem;
    min-height: 100vh;
    background: var(--bg);
}

.main-content::before {
    display: none;
}

/* ── Page Header ───────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.02em;
}

.header .header-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0.15rem 0 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card,
.stat-card,
.table-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.card {
    padding: 1.5rem;
}

.card:hover,
.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card {
    padding: 1.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-card {
    padding: 0;
    overflow: hidden;
}

.table-card .card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-white);
}

.table-card .card-header h5,
.table-card .card-header h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 0.75rem 1rem;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.9rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #fafbfc;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-oneclick,
.btn-premium {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.875rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-oneclick {
    background: var(--hs-orange);
    color: #fff;
    border-color: var(--hs-orange);
}

.btn-oneclick:hover {
    background: var(--hs-orange-dark);
    border-color: var(--hs-orange-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 122, 89, 0.3);
    transform: none;
}

.btn-oneclick.btn-success-grad {
    background: var(--hs-success);
    border-color: var(--hs-success);
    color: #fff;
}

.btn-oneclick.btn-success-grad:hover {
    background: #009f8e;
    border-color: #009f8e;
}

.btn-oneclick.btn-secondary,
.btn-outline {
    background: var(--bg-white);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-oneclick.btn-secondary:hover,
.btn-outline:hover {
    background: var(--bg-hover);
    border-color: #b8c4ce;
    color: var(--text-main);
}

.btn.btn-primary {
    background: var(--hs-orange);
    border-color: var(--hs-orange);
    color: #fff;
}

.btn.btn-primary:hover {
    background: var(--hs-orange-dark);
    border-color: var(--hs-orange-dark);
}

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8125rem;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-label .required {
    color: var(--hs-danger);
    margin-left: 2px;
}

.form-control,
.form-control-premium,
.form-select {
    display: block;
    width: 100%;
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus,
.form-control-premium:focus,
.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 164, 189, 0.15);
}

.form-control::placeholder,
.form-control-premium::placeholder {
    color: var(--text-light);
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.form-check-premium {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.9rem;
}

.form-check-premium:hover {
    background: var(--bg-hover);
    border-color: #b8c4ce;
}

.form-preview-box {
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* ── Flash Messages ──────────────────────────────────────────── */
.flash-success {
    background: var(--hs-success-light);
    border: 1px solid #00bda5;
    color: #007760;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flash-error {
    background: var(--hs-danger-light);
    border: 1px solid #f2545b;
    color: #b5203f;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge-stage {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

/* ── Kanban ──────────────────────────────────────────────────── */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    min-height: 400px;
}

.kanban-column {
    min-width: 250px;
    max-width: 280px;
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    color: var(--bg-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: 0.01em;
}

.kanban-drop-zone {
    flex: 1;
    min-height: 60px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    padding: 2px;
}

.kanban-drop-zone.drag-over {
    background: rgba(0, 145, 174, 0.05);
    border: 2px dashed var(--hs-blue);
    border-radius: var(--radius-md);
}

.kanban-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.15s;
    user-select: none;
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card.dragging {
    opacity: 0.5;
    transform: scale(0.97);
    box-shadow: 0 0 0 2px var(--hs-blue);
}

.kanban-card .card-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
    margin-bottom: 3px;
}

.kanban-card .card-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.kanban-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.kanban-card-link:hover {
    color: inherit;
}

.kanban-placeholder {
    text-align: center;
    color: var(--text-light);
    font-size: 0.8rem;
    padding: 20px 10px;
    display: none;
}

.kanban-drop-zone:empty+.kanban-placeholder,
.kanban-drop-zone .kanban-placeholder:only-child {
    display: block;
}

.kanban-drop-zone.drag-over .kanban-placeholder {
    display: block;
    color: var(--hs-blue);
    font-weight: 600;
}

/* ── Toast ───────────────────────────────────────────────────── */
.kanban-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s, transform 0.25s;
    box-shadow: var(--shadow-lg);
}

.kanban-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.kanban-toast-success {
    background: var(--hs-success);
}

.kanban-toast-danger {
    background: var(--hs-danger);
}

/* ── Timeline ────────────────────────────────────────────────── */
.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-left: 2px solid var(--border-color);
    margin-left: 10px;
    padding-left: 20px;
    position: relative;
}

.timeline-item::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hs-blue);
    position: absolute;
    left: -5px;
    top: 14px;
}

.timeline-item .timeline-body {
    font-size: 0.875rem;
}

.timeline-item .timeline-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Complete Task ───────────────────────────────────────────── */
.btn-complete-task {
    color: #b8c4ce;
    background-color: transparent;
    border: 1px solid var(--border-color);
    transition: all 0.15s;
}

.btn-complete-task:hover {
    color: #fff;
    background-color: var(--hs-success);
    border-color: var(--hs-success);
}

.btn-complete-task .check-filled {
    display: none;
}

.btn-complete-task .check-empty {
    display: inline-block;
}

.btn-complete-task:hover .check-empty {
    display: none;
}

.btn-complete-task:hover .check-filled {
    display: inline-block;
}

/* ── Checklist ───────────────────────────────────────────────── */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.checklist-item.done {
    opacity: 0.55;
}

.checklist-item.done .checklist-label {
    text-decoration: line-through;
}

/* ── Misc Overrides ───────────────────────────────────────────── */
a {
    color: var(--hs-blue);
}

a:hover {
    color: var(--hs-navy-dark);
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-primary {
    color: var(--hs-orange) !important;
}

.bg-primary {
    background: var(--hs-orange) !important;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar a span,
    .sidebar .brand span,
    .sidebar .nav-section-title {
        display: none;
    }

    .main-content {
        margin-left: 60px;
        padding: 1.5rem;
    }
}