/* style.css v2 — Partsplanner RMA — mobilvenlig */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #2A7D4F;
    --green-light: #e8f5ee;
    --green-dark: #1e5c39;
    --gray: #6B7280;
    --gray-light: #F3F4F6;
    --gray-border: #E5E7EB;
    --text: #111827;
    --text-muted: #6B7280;
    --white: #ffffff;
    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;
    --blue: #3B82F6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: #F9FAFB;
    min-height: 100vh;
}

/* HEADER */
.site-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-border);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.site-header .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--green);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.site-header nav { display: flex; align-items: center; gap: 6px; }

.site-header nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: var(--radius);
    white-space: nowrap;
}

.site-header nav a:hover { background: var(--gray-light); color: var(--text); }

/* MOBILE NAV — bottom bar for customers */
.mobile-nav {
    display: none; /* Skjult som standard — vises kun på mobil via media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-border);
    z-index: 200;
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}

.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 8px;
    flex: 1;
    transition: color 0.15s;
}

.mobile-nav a.active { color: var(--green); }
.mobile-nav a span.icon { font-size: 20px; line-height: 1; }

@media (max-width: 640px) {
    .mobile-nav { display: flex; }
    .desktop-nav { display: none !important; }
    body { padding-bottom: 70px; }
}

/* CONTAINER */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px;
}

.container-wide {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* CARDS */
.card {
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-border);
    flex-wrap: wrap;
    gap: 8px;
}

.card-title { font-size: 16px; font-weight: 600; }

/* FORMS */
.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
}

label .required { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    font-size: 15px;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    -webkit-appearance: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(42,125,79,0.12);
}

textarea { resize: vertical; min-height: 90px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 560px) {
    .form-row { grid-template-columns: 1fr; }
}

/* RADIO CARDS */
.radio-group { display: flex; flex-direction: column; gap: 10px; }

.radio-card {
    border: 2px solid var(--gray-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.radio-card input[type="radio"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--green);
}

.radio-card:has(input:checked) {
    border-color: var(--green);
    background: var(--green-light);
}

.radio-card-body { flex: 1; }
.radio-card-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.radio-card-desc  { font-size: 13px; color: var(--text-muted); line-height: 1.4; }

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { opacity: 0.75; }
.btn-primary   { background: var(--green); color: white; }
.btn-secondary { background: var(--gray-light); color: var(--text); border: 1px solid var(--gray-border); }
.btn-danger    { background: var(--danger); color: white; }
.btn-warning   { background: var(--warning); color: white; }
.btn-outline   { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn-lg  { padding: 13px 24px; font-size: 16px; }
.btn-sm  { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}

.badge-modtaget         { background: #EFF6FF; color: #1D4ED8; }
.badge-under_behandling { background: #FFFBEB; color: #92400E; }
.badge-godkendt         { background: #ECFDF5; color: #065F46; }
.badge-afvist           { background: #FEF2F2; color: #991B1B; }
.badge-krediteret       { background: #EDE9FE; color: #4C1D95; }

/* ALERTS */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.alert-info    { background: #EFF6FF; border-color: var(--blue);    color: #1E40AF; }
.alert-success { background: #ECFDF5; border-color: var(--success); color: #065F46; }
.alert-danger  { background: #FEF2F2; border-color: var(--danger);  color: #991B1B; }
.alert-warning { background: #FFFBEB; border-color: var(--warning); color: #92400E; }

/* STEPS */
.steps {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.step { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.step-number {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gray-border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step.active .step-number { background: var(--green); color: white; }
.step.done .step-number   { background: var(--green-dark); color: white; }
.step-label { font-size: 13px; color: var(--text-muted); }
.step.active .step-label  { color: var(--text); font-weight: 500; }
.step.done .step-label    { color: var(--green-dark); }
.step-line { flex: 1; min-width: 20px; height: 1px; background: var(--gray-border); margin: 0 6px; }

/* TABLES */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 12px;
    background: var(--gray-light);
    border-bottom: 1px solid var(--gray-border);
    white-space: nowrap;
}
.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--gray-border);
    font-size: 14px;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

/* MOBILE TABLE → CARDS */
@media (max-width: 640px) {
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* IMAGE UPLOAD */
.image-upload-area {
    border: 2px dashed var(--gray-border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--gray-light);
}

.image-upload-area:hover,
.image-upload-area.dragover {
    border-color: var(--green);
    background: var(--green-light);
}

.image-upload-area input[type="file"] {
    display: none;
}

.image-upload-icon { font-size: 32px; margin-bottom: 8px; }
.image-upload-text { font-size: 14px; color: var(--text-muted); }
.image-upload-text strong { color: var(--green); }

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gray-light);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* IMAGE GALLERY (sag visning) */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.image-gallery a {
    display: block;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gray-light);
}

.image-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.15s;
}

.image-gallery a:hover img { opacity: 0.85; }

/* ITEMS TABLE */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 8px;
    border-bottom: 1px solid var(--gray-border);
}
.items-table td { padding: 6px 8px; }
.items-table .col-nr    { width: 140px; }
.items-table .col-antal { width: 70px; }
.items-table .col-del   { width: 36px; text-align: center; }

@media (max-width: 480px) {
    .items-table .col-nr { width: 100px; }
}

/* NOTE / COMMENT THREAD */
.note-item {
    padding: 12px;
    background: var(--gray-light);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.note-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.note-item-body { font-size: 14px; }

/* ATTACH LIST */
.attach-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 14px;
}

.attach-icon { font-size: 20px; flex-shrink: 0; }
.attach-name { flex: 1; font-weight: 500; word-break: break-all; }
.attach-size { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* PAGE TITLE */
.page-title    { font-size: 20px; font-weight: 700; margin-bottom: 2px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

/* AUTH */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F3F4F6;
    padding: 20px 16px;
}

.auth-box {
    background: white;
    border: 1px solid var(--gray-border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}

.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo h1 { font-size: 18px; font-weight: 700; margin-top: 10px; }
.auth-logo p  { font-size: 14px; color: var(--text-muted); }

/* SIDEBAR LAYOUT */
.layout-sidebar {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
    align-items: start;
}

@media (max-width: 760px) {
    .layout-sidebar { grid-template-columns: 1fr; }
    .sidebar-col { order: -1; }
}

/* FOOTER */
.site-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    padding: 24px 16px;
    border-top: 1px solid var(--gray-border);
    margin-top: 32px;
}

/* ADMIN SIDEBAR */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: calc(100vh - 56px);
}

.admin-sidebar {
    background: var(--white);
    border-right: 1px solid var(--gray-border);
    padding: 16px 0;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}

.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.1s, color 0.1s;
}

.admin-sidebar a:hover  { background: var(--gray-light); color: var(--text); }
.admin-sidebar a.active { background: var(--green-light); color: var(--green); font-weight: 600; }
.admin-sidebar .nav-section {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px 4px;
}

.admin-content { padding: 24px 20px; }

@media (max-width: 760px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--gray-border);
        display: flex;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }
    .admin-sidebar a { padding: 8px 12px; border-radius: 6px; }
    .admin-sidebar .nav-section { display: none; }
    .admin-content { padding: 16px; }
}

/* UTILS */
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 13px; }
.text-center  { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* v3 tilføjelser */
.badge-rma_indsendt { background: #EFF6FF; color: #1D4ED8; }
.badge-afsendt_leverandor    { background: #FFF7ED; color: #92400E; }
.badge-krediteret_leverandor { background: #F0FDF4; color: #14532D; }

/* Admin mobil optimering */
@media (max-width: 640px) {
    .phase-header { padding: 10px 0 6px; }
    .field-row-3 { grid-template-columns: 1fr 1fr; }
    .action-bar { padding: 10px 12px; }
    .action-bar .btn { font-size: 13px; padding: 8px 12px; }
    .vare-action-card { padding: 14px 8px; }
    .vare-action-card .icon { font-size: 20px; }
    /* Skjul PP kostpris kolonne på mobil */
    #admin-items-table th:nth-child(7),
    #admin-items-table td:nth-child(7) { display: none; }
    /* Kreditnota grid til én kolonne */
    .kn-grid-2 { grid-template-columns: 1fr !important; }
}

@media (max-width: 760px) {
    .layout-sidebar { grid-template-columns: 1fr; }
    .admin-content { padding: 12px; }
    /* Vandret scroll på varetabel */
    #admin-items-table { min-width: 600px; }
    .card { padding: 14px; }
}
.badge-afventer_modtagelse { background: #EFF6FF; color: #1D4ED8; }
.badge-modtaget            { background: #ECFDF5; color: #065F46; }
.badge-lagerfoert          { background: #EDE9FE; color: #4C1D95; }
