/* ==========================================================================
   OmniCRM — design system
   Bygget på /green-app-design ("Slack sidebar + Notion content"), tilpasset
   OmniShare-brandet: dyb blå sidebar, mint-grøn accent, pink sekundær accent.
   Kræver Montserrat (Google Fonts) + Bootstrap Icons (CDN) i <head>.
   ========================================================================== */

:root {
    /* Brand (OmniShare) */
    --oc-primary:       #173F77;  /* dyb blå — sidebar / overskrifter */
    --oc-primary-light: #1f4f93;  /* hover på mørke flader */
    --oc-accent:        #4EE1B1;  /* mint — aktiv/hover highlight */
    --oc-green:         #12a877;  /* solid CTA / success / badge */
    --oc-pink:          #FF80B0;  /* sekundær accent */
    --oc-warn:          #f59e0b;
    --oc-danger:        #e23d52;
    --oc-gradient: linear-gradient(90deg, #173F77, #4EE1B1); /* signatur-gradient */

    /* Surfaces */
    --oc-bg:        #f0f8ff;
    --oc-surface:   #ffffff;
    --oc-border:    #e2e8f0;
    --oc-text:      #1f2d3d;
    --oc-muted:     #64748b;

    /* Sidebar-tekst (på dyb blå) */
    --oc-sidebar-text:  #b9cfe8;
    --oc-sidebar-muted: #7e9cbf;

    /* Metrics */
    --oc-radius:         10px;
    --oc-sidebar-width:  260px;
    --oc-bottomnav-height: 3.75rem;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Montserrat', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--oc-bg);
    color: var(--oc-text);
    font-size: 15px;
}

h1 { font-size: 1.5rem; font-weight: 700; color: var(--oc-primary); letter-spacing: -0.02em; margin: 0 0 0.25rem; }
h1:focus { outline: none; }
h2 { font-size: 1.2rem; font-weight: 700; color: var(--oc-primary); margin: 0 0 0.5rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.5rem; }
h5 { font-weight: 600; }

a { color: #0f6d8f; text-decoration: none; }
a:hover { color: var(--oc-primary); }

.muted { color: var(--oc-muted); font-size: 0.85rem; }
.text-danger { color: var(--oc-danger); }
.text-success { color: var(--oc-green); }
.text-center { text-align: center; }
.text-end { text-align: right; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--oc-sidebar-width);
    flex-shrink: 0;
    background-color: var(--oc-primary);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-inner { display: flex; flex-direction: column; min-height: 100%; padding: 1rem 0.75rem; }

.sidebar-brand {
    display: flex; align-items: center; gap: 0.6rem;
    color: #fff; font-weight: 700; font-size: 1.1rem;
    padding: 0.25rem 0.5rem 0.1rem;
}

.brand-mark {
    width: 16px; height: 16px; border-radius: 4px;
    background-image: var(--oc-gradient); flex-shrink: 0;
}

.sidebar-version {
    color: var(--oc-sidebar-muted); font-size: 0.72rem;
    padding: 0 0.5rem 1rem 1.6rem; display: block;
}
.sidebar-version:hover { color: var(--oc-accent); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
    display: flex; align-items: center; gap: 0.6rem;
    color: var(--oc-sidebar-text); font-size: 0.9rem;
    padding: 0.5rem 0.75rem; border-radius: 8px; text-decoration: none;
}
.sidebar-link:hover { background-color: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background-color: rgba(78,225,177,0.20); color: #fff; }
.sidebar-link i { font-size: 1rem; width: 1.1rem; text-align: center; }

.sidebar-section { margin-top: 1.25rem; }
.sidebar-section-header {
    color: var(--oc-sidebar-muted); font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; padding: 0 0.75rem 0.35rem;
}

.sidebar-spacer { flex: 1; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-wrap { padding: 2rem 2.5rem 3rem; width: 100%; }

.mobile-topbar { display: none; }
.bottom-nav { display: none; }

/* --------------------------------------------------------------------------
   Cards, toolbar, layout helpers
   -------------------------------------------------------------------------- */

.card {
    background-color: var(--oc-surface);
    border: 1px solid var(--oc-border);
    border-radius: var(--oc-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.card-tight { padding: 1rem 1.1rem; }

.toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.toolbar-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.d-flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.35rem; } .gap-2 { gap: 0.6rem; } .gap-3 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 0.35rem; } .mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1rem; } .mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.35rem; } .mt-2 { margin-top: 0.75rem; } .mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.ms-auto { margin-left: auto; }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--oc-surface); border: 1px solid var(--oc-border);
    border-radius: var(--oc-radius); padding: 1.1rem 1.25rem;
}
.stat-card .stat-label { color: var(--oc-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--oc-primary); margin-top: 0.25rem; }
.stat-card .stat-sub { color: var(--oc-muted); font-size: 0.8rem; }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.empty-state { text-align: center; color: var(--oc-muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2rem; display: block; margin-bottom: 0.5rem; color: var(--oc-border); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    font-weight: 600; border-radius: 8px; padding: 0.5rem 1rem;
    border: 1px solid transparent; cursor: pointer; font-size: 0.9rem;
    font-family: inherit; line-height: 1.2; text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.btn-primary {
    color: #fff; border: 0;
    background-image: var(--oc-gradient); background-size: 200% 100%;
    background-position: left bottom; transition: background-position 300ms ease;
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { color: #fff; background-position: right bottom; }

.btn-outline { color: var(--oc-green); border-color: var(--oc-green); background: transparent; }
.btn-outline:hover { color: #fff; background-color: var(--oc-green); }

.btn-quiet { color: var(--oc-muted); border-color: var(--oc-border); background: var(--oc-surface); }
.btn-quiet:hover { color: var(--oc-primary); background-color: #eef3f9; }

.btn-danger { color: #fff; background-color: var(--oc-danger); }
.btn-danger:hover { color: #fff; background-color: #c62f43; }

.btn-icon { padding: 0.35rem 0.5rem; }

/* --------------------------------------------------------------------------
   Forms + focus ring
   -------------------------------------------------------------------------- */

.form-control, .form-select {
    border: 1px solid var(--oc-border); border-radius: 8px;
    padding: 0.5rem 0.75rem; font-size: 0.95rem; width: 100%;
    background: #fff; color: var(--oc-text); font-family: inherit;
}
textarea.form-control { min-height: 5rem; resize: vertical; }
.form-control:focus, .form-select:focus { border-color: var(--oc-accent); outline: none; }
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--oc-primary); display: block; margin-bottom: 0.25rem; }
.form-group { margin-bottom: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check input { width: 1rem; height: 1rem; }

.btn:focus-visible, a:focus-visible, .form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(78, 225, 177, 0.35);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap { background: var(--oc-surface); border: 1px solid var(--oc-border); border-radius: var(--oc-radius); overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; color: var(--oc-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; padding: 0.7rem 1rem; border-bottom: 1px solid var(--oc-border); }
.table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--oc-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f7fbff; }
.table .row-link { cursor: pointer; }

/* --------------------------------------------------------------------------
   Avatar + badges
   -------------------------------------------------------------------------- */

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; color: #fff; font-weight: 600;
    background-color: var(--oc-primary-light); overflow: hidden; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 0.75rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.25rem; }

.badge {
    display: inline-block; background-color: var(--oc-green); color: #fff;
    border-radius: 999px; font-size: 0.7rem; font-weight: 600; padding: 0.18rem 0.6rem;
    white-space: nowrap;
}
.badge-muted { background-color: #e2e8f0; color: var(--oc-muted); }
.badge-blue { background-color: var(--oc-primary); }
.badge-pink { background-color: var(--oc-pink); }
.badge-won { background-color: var(--oc-green); }
.badge-lost { background-color: var(--oc-danger); }
.badge-open { background-color: #e2e8f0; color: var(--oc-primary); }
.badge-warn { background-color: var(--oc-warn); }

.tag {
    display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem;
    color: var(--oc-muted); background: #f1f5f9; border-radius: 6px; padding: 0.15rem 0.5rem;
}

/* --------------------------------------------------------------------------
   Auth pages
   -------------------------------------------------------------------------- */

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card {
    background: var(--oc-surface); border: 1px solid var(--oc-border);
    border-radius: 14px; padding: 2rem; width: 100%; max-width: 26rem;
}
.auth-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.3rem; color: var(--oc-primary); margin-bottom: 1.25rem; }
.auth-intro { color: var(--oc-muted); margin-bottom: 1.25rem; }
.auth-switch { margin-top: 1.25rem; font-size: 0.9rem; color: var(--oc-muted); }

.alert { border-radius: 8px; padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-danger { background: #fdecee; color: #b3263a; border: 1px solid #f6c9d0; }
.alert-success { background: #e7f9f1; color: #0c7a56; border: 1px solid #bfece0; }
.alert-info { background: #eaf3fb; color: #1c5a91; border: 1px solid #cfe3f5; }

/* --------------------------------------------------------------------------
   Kanban (pipeline)
   -------------------------------------------------------------------------- */

.kanban { display: flex; gap: 1rem; align-items: flex-start; overflow-x: auto; padding-bottom: 1rem; }
.kanban-col {
    flex: 0 0 270px; background: #eef3f9; border: 1px solid var(--oc-border);
    border-radius: var(--oc-radius); display: flex; flex-direction: column; max-height: calc(100vh - 13rem);
}
.kanban-col.drop-target { outline: 2px dashed var(--oc-accent); outline-offset: -2px; background: #e6fbf3; }
.kanban-col-header { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--oc-border); display: flex; align-items: center; justify-content: space-between; }
.kanban-col-title { font-weight: 700; font-size: 0.85rem; color: var(--oc-primary); }
.kanban-col-sum { color: var(--oc-muted); font-size: 0.75rem; }
.kanban-col-body { padding: 0.6rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.5rem; min-height: 3rem; }

.deal-card {
    background: var(--oc-surface); border: 1px solid var(--oc-border); border-radius: 8px;
    padding: 0.65rem 0.75rem; cursor: grab; border-left: 3px solid var(--oc-accent);
}
.deal-card:hover { border-color: var(--oc-accent); }
.deal-card.dragging { opacity: 0.5; }
.deal-card .deal-title { font-weight: 600; font-size: 0.88rem; color: var(--oc-text); }
.deal-card .deal-value { color: var(--oc-green); font-weight: 700; font-size: 0.85rem; }
.deal-card .deal-meta { color: var(--oc-muted); font-size: 0.78rem; margin-top: 0.2rem; }
.deal-card-move { display: flex; justify-content: space-between; margin-top: 0.4rem; }
.deal-card-move button { background: none; border: 0; color: var(--oc-muted); cursor: pointer; font-size: 0.9rem; padding: 0 0.25rem; }
.deal-card-move button:hover { color: var(--oc-primary); }
.deal-card-move button:disabled { opacity: 0.25; cursor: default; }

/* --------------------------------------------------------------------------
   Activity / note lists, dialog
   -------------------------------------------------------------------------- */

.list-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--oc-border); }
.list-row:last-child { border-bottom: 0; }
.list-row .list-icon { width: 2rem; height: 2rem; border-radius: 8px; background: #eef3f9; color: var(--oc-primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list-row.done .list-main { text-decoration: line-through; color: var(--oc-muted); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 0.9rem; }
.list-sub { color: var(--oc-muted); font-size: 0.8rem; }
.overdue { color: var(--oc-danger); }

.note { background: #f8fafc; border: 1px solid var(--oc-border); border-radius: 8px; padding: 0.7rem 0.85rem; margin-bottom: 0.6rem; }
.note .note-body { white-space: pre-wrap; font-size: 0.9rem; }
.note .note-meta { color: var(--oc-muted); font-size: 0.75rem; margin-top: 0.35rem; }

.dialog-backdrop {
    position: fixed; inset: 0; background: rgba(15,30,55,0.45); display: flex;
    align-items: center; justify-content: center; padding: 1rem; z-index: 1050;
}
.dialog {
    background: var(--oc-surface); border-radius: 14px; padding: 1.5rem;
    width: 100%; max-width: 30rem; max-height: 90vh; overflow-y: auto;
}
.dialog.dialog-wide { max-width: 42rem; }
.dialog h2 { margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

.validation-message, .text-danger.field-error { color: var(--oc-danger); font-size: 0.8rem; }

.sidebar-search { display: flex; align-items: center; gap: 0.4rem; background: rgba(255,255,255,0.08); border-radius: 8px; padding: 0.35rem 0.6rem; margin: 0.25rem 0 0.75rem; }
.sidebar-search i { color: var(--oc-sidebar-muted); font-size: 0.85rem; }
.sidebar-search input { background: transparent; border: 0; outline: none; color: #fff; font-family: inherit; font-size: 0.85rem; width: 100%; }
.sidebar-search input::placeholder { color: var(--oc-sidebar-muted); }

.org-switcher { position: relative; margin-bottom: 0.75rem; }
.org-switcher-btn { display: flex; align-items: center; gap: 0.6rem; width: 100%; background: rgba(255,255,255,0.06); border: 0; color: #fff; padding: 0.5rem 0.6rem; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 1rem; }
.org-switcher-btn:hover { background: rgba(255,255,255,0.12); }
.org-switcher-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: left; }
.org-switcher-btn .bi-chevron-down { font-size: 0.8rem; opacity: 0.8; }
.org-icon { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; background: #fff; flex-shrink: 0; }
.org-icon.sm { width: 22px; height: 22px; }
.org-icon.lg { width: 56px; height: 56px; border-radius: 12px; border: 1px solid var(--oc-border); }
.org-logo { max-height: 64px; max-width: 220px; object-fit: contain; }
.org-dropdown { position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--oc-surface); border: 1px solid var(--oc-border); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,30,55,0.18); z-index: 1200; overflow: hidden; max-height: 60vh; overflow-y: auto; }
.org-dropdown-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; background: none; border: 0; padding: 0.55rem 0.7rem; cursor: pointer; font-family: inherit; font-size: 0.88rem; color: var(--oc-text); text-align: left; }
.org-dropdown-item:hover { background: #eef3f9; }
.org-dropdown-item.active { font-weight: 700; color: var(--oc-primary); }

.lang-switch { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; }
.lang-switch a { color: var(--oc-muted); }
.lang-switch a.active { color: var(--oc-primary); font-weight: 700; }
.sidebar .lang-switch a { color: var(--oc-sidebar-muted); }
.sidebar .lang-switch a.active { color: #fff; }

/* --------------------------------------------------------------------------
   Responsive: sidebar -> top bar + bottom nav at 768px
   -------------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    .sidebar { display: none; }
    .content-wrap { padding: 1.25rem 1rem calc(var(--oc-bottomnav-height) + 1.5rem); }

    .mobile-topbar {
        display: flex; align-items: center; justify-content: space-between;
        background-color: var(--oc-primary); color: #fff; padding: 0.5rem 1rem;
        position: sticky; top: 0; z-index: 1010;
    }
    .mobile-topbar .sidebar-brand { padding: 0; color: #fff; }
    .mobile-topbar .org-switcher { margin-bottom: 0; }

    .bottom-nav {
        display: flex; justify-content: space-around; align-items: center;
        position: fixed; bottom: 0; left: 0; right: 0; height: var(--oc-bottomnav-height);
        background-color: var(--oc-surface); border-top: 1px solid var(--oc-border);
        padding-bottom: env(safe-area-inset-bottom); z-index: 1010;
    }
    .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; font-size: 0.68rem; color: var(--oc-muted); }
    .bottom-nav a.active { color: var(--oc-green); }
    .bottom-nav a i { font-size: 1.25rem; }

    .detail-grid { grid-template-columns: 1fr; }
    .kanban-col { max-height: none; }
}

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff3cd; color: #664d03; padding: 0.75rem 1.25rem; z-index: 1100;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.1);
}
#blazor-error-ui .reload { color: #664d03; text-decoration: underline; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
