/* ================================================================
   SOFTWARE KATALOG – KoncernIT
   Theme colour: #5a1158
   ================================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --primary:            #5a1158;
    --primary-dark:       #3e0b3c;
    --primary-light:      #7b1878;
    --primary-xlight:     #f4ecf4;
    --primary-glass:      rgba(90, 17, 88, 0.08);

    --text:               #1a1a2e;
    --text-sec:           #555768;
    --text-muted:         #8a8fa8;

    --bg:                 #f6f6f9;
    --surface:            #ffffff;
    --border:             #e2e2ea;
    --border-light:       #f0f0f5;

    --shadow-xs:          0 1px 2px rgba(0,0,0,0.06);
    --shadow-sm:          0 2px 6px rgba(0,0,0,0.08);
    --shadow-md:          0 4px 18px rgba(0,0,0,0.10);
    --shadow-lg:          0 10px 36px rgba(0,0,0,0.14);

    --r:                  8px;
    --r-lg:               12px;
    --ease:               0.18s ease;

    /* Status */
    --ok-fg:              #166534;
    --ok-bg:              #dcfce7;
    --no-fg:              #991b1b;
    --no-bg:              #fee2e2;
    --pending-fg:         #854d0e;
    --pending-bg:         #fef9c3;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.header {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow-md);
}
.header-content {
    width: 100%;                 /* ← was max-width: 1440px */
    padding: 0 32px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.logo-placeholder {
    width: 38px; height: 38px;
    border-radius: var(--r);
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.28);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.logo-text { font-weight: 800; font-size: 12px; letter-spacing: .06em; color: #fff; }
.logo-img  { width: 90px; height: 90px; object-fit: contain; border-radius: 6px; }
.header-titles { display: flex; flex-direction: column; line-height: 1.2; }
.header-org   { font-size: .7rem; opacity: .7; letter-spacing: .08em; text-transform: uppercase; }
.header-title { font-size: 1.1rem; font-weight: 700; }

.header-user { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-name {
    font-size: .85rem; opacity: .88;
    max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-badge {
    font-size: .65rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    padding: 2px 9px; border-radius: 20px;
    background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.35); color: #fff;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--r);
    font-size: .875rem; font-weight: 500; cursor: pointer;
    transition: background var(--ease), box-shadow var(--ease);
    white-space: nowrap; font-family: inherit;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid rgba(90,17,88,.45); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(90,17,88,.35); }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-outline {
    background: rgba(255,255,255,.1); color: #fff;
    border: 1px solid rgba(255,255,255,.3);
}
.btn-outline:hover { background: rgba(255,255,255,.2); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }

/* ---------- Layout ---------- */
.main-content {
    width: 100%;                 /* ← was max-width: 1440px */
    padding: 28px 32px;
}

/* ---------- Loading ---------- */
.loading-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 320px; gap: 18px; color: var(--text-sec);
}
.spinner {
    width: 42px; height: 42px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Not-authenticated ---------- */
.auth-required {
    display: flex; justify-content: center; align-items: center; min-height: 440px;
}
.auth-card {
    background: var(--surface); border-radius: var(--r-lg); padding: 52px 44px;
    text-align: center; max-width: 420px;
    box-shadow: var(--shadow-md); border: 1px solid var(--border-light);
}
.auth-icon { font-size: 3rem; margin-bottom: 18px; }
.auth-card h2 { font-size: 1.2rem; margin-bottom: 12px; }
.auth-card p  { color: var(--text-sec); margin-bottom: 26px; font-size: .9rem; }

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.search-container { position: relative; flex: 1; min-width: 220px; max-width: 400px; }
.search-icon {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    pointer-events: none;
}
.search-input {
    width: 100%; padding: 9px 12px 9px 36px;
    border: 1px solid var(--border); border-radius: var(--r);
    font-size: .875rem; font-family: inherit; background: var(--surface);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.search-input:focus {
    outline: none; border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glass);
}
.filter-container { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: .85rem; color: var(--text-sec); white-space: nowrap; }
.filter-select {
    padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--r);
    font-size: .875rem; font-family: inherit; background: var(--surface); cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--primary-light); }
.results-count { font-size: .8rem; color: var(--text-muted); white-space: nowrap; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Table ---------- */
.table-wrapper {
    background: var(--surface); border-radius: var(--r-lg);
    border: 1px solid var(--border-light); box-shadow: var(--shadow-sm);
    overflow: auto;
}
.catalog-table {
    width: 100%; border-collapse: collapse; font-size: .875rem;
    min-width: 640px;
}
.catalog-table thead { background: var(--primary); color: #fff; }
.catalog-table th {
    padding: 13px 16px; text-align: left;
    font-size: .75rem; font-weight: 700;
    letter-spacing: .05em; text-transform: uppercase;
    white-space: nowrap; user-select: none;
}
.catalog-table tbody tr { border-bottom: 1px solid var(--border-light); transition: background var(--ease); }
.catalog-table tbody tr:last-child { border-bottom: none; }
.catalog-table tbody tr:hover { background: var(--primary-xlight); }
.catalog-table td { padding: 12px 16px; vertical-align: middle; max-width: 280px; }
.cell-truncate {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; cursor: help;
}

/* ---------- Status Badges ---------- */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 11px; border-radius: 20px;
    font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.badge-approved { background: var(--ok-bg);      color: var(--ok-fg);      }
.badge-rejected { background: var(--no-bg);      color: var(--no-fg);      }
.badge-review   { background: var(--pending-bg); color: var(--pending-fg); }
.badge-default  { background: var(--border);     color: var(--text-sec);   }

/* ---------- Empty State ---------- */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 72px 32px; color: var(--text-muted); gap: 12px;
}
.empty-icon { font-size: 2.5rem; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.42);
    display: flex; align-items: center; justify-content: center;
    z-index: 500; padding: 16px; backdrop-filter: blur(3px);
}
.modal {
    background: var(--surface); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 820px;
    max-height: 92vh; display: flex; flex-direction: column;
    animation: popIn .17s ease;
}
@keyframes popIn {
    from { opacity: 0; transform: scale(.97) translateY(8px); }
    to   { opacity: 1; transform: scale(1)  translateY(0);    }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 26px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
    background: none; border: none; font-size: 1.3rem; line-height: 1;
    cursor: pointer; color: var(--text-muted); padding: 4px 8px;
    border-radius: 6px; transition: background var(--ease);
}
.modal-close:hover { background: var(--bg); }
.modal-body { overflow-y: auto; padding: 26px; flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.form-section-title {
    font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--primary); margin-bottom: 18px; padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-xlight);
}
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: .8rem; font-weight: 600;
    color: var(--text-sec); margin-bottom: 5px;
}
.required { color: var(--no-fg); }
.form-input {
    width: 100%; padding: 8px 11px;
    border: 1px solid var(--border); border-radius: var(--r);
    font-size: .875rem; font-family: inherit; background: var(--surface);
    resize: vertical; transition: border-color var(--ease), box-shadow var(--ease);
}
.form-input:focus {
    outline: none; border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glass);
}
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 20px; margin-top: 8px;
    border-top: 1px solid var(--border);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 26px; right: 26px;
    padding: 14px 22px; border-radius: var(--r);
    color: #fff; font-size: .9rem; font-weight: 500;
    box-shadow: var(--shadow-lg); z-index: 9999; max-width: 380px;
    animation: slideUp .22s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.toast-success { background: var(--ok-fg);  }
.toast-error   { background: var(--no-fg);  }
.toast-info    { background: var(--primary); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .main-content { padding: 18px; }
    .header-content { padding: 0 18px; }
}
@media (max-width: 600px) {
    .user-name { display: none; }
    .header-org { display: none; }
    .toolbar-actions { margin-left: 0; }
}

/* ---------- Person cell ---------- */
.person-cell     { display: flex; align-items: center; gap: 8px; }
.person-avatar   { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.person-initials { width: 28px; height: 28px; border-radius: 50%;
                   background: #0369a1; color: #fff; font-size: 11px; font-weight: 600;
                   flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.person-name     { font-size: 14px; }


/* ---------- Column widths ---------- */
.catalog-table th:nth-child(1),
.catalog-table td:nth-child(1) { width: 300px; }   /* Navn */

.catalog-table th:nth-child(2),
.catalog-table td:nth-child(2) { width: 110px; }   /* Status — narrower */

.catalog-table th:nth-child(3),
.catalog-table td:nth-child(3) { width: auto; }    /* Beskrivelse — takes remaining space */

.catalog-table th:nth-child(4),
.catalog-table td:nth-child(4) { width: 250px; }   /* Ejer */

.catalog-table th:nth-child(2),
.catalog-table th:nth-child(3) { text-align: center; }
.catalog-table td:nth-child(2) { text-align: center; }