/* MNHS Admin - Felles CSS */
/* Tema: Midtnorsk Helikopterservice cyan-blå #45B9EC */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --mnhs-primary: #45B9EC;
    --mnhs-primary-dark: #2A9FD6;
    --mnhs-sidebar: #0f1720;
    --mnhs-sidebar-hover: #1a2636;
    --mnhs-sidebar-border: #1e2d3d;
    --mnhs-text: #333;
    --mnhs-heading: #0f1720;
}

/* OM-A referanse-badge */
.oma-ref {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500;
    background: #f0f4f8; color: #475569; border: 1px solid #cbd5e1;
    text-decoration: none; white-space: nowrap; vertical-align: middle;
    margin-left: 8px;
}
.oma-ref:hover { background: #e2e8f0; color: #1e293b; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: var(--mnhs-text);
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: 220px;
    background: var(--mnhs-sidebar);
    color: #ecf0f1;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: width 0.2s;
}
.sidebar-bg {
    margin-top: auto;
    padding: 10px;
    opacity: 0.35;
    transition: opacity 0.3s;
    flex-shrink: 1;
    overflow: hidden;
    min-height: 0;
}
.sidebar-bg:hover { opacity: 0.65; }
.sidebar-bg img {
    width: 100%;
    border-radius: 6px;
    display: block;
}
.sidebar-logo {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--mnhs-sidebar-border);
}
.sidebar-logo img {
    display: block;
    margin: 0 auto;
}
.sidebar-section {
    padding: 8px 0 0;
    font-size: 11px;
    color: #4a6070;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 15px;
    margin-top: 10px;
}
.sidebar nav { padding: 5px 0; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    color: #7a8d9c;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover {
    background: var(--mnhs-sidebar-hover);
    color: #cde;
}
.sidebar nav a.active {
    background: var(--mnhs-sidebar-hover);
    color: var(--mnhs-primary);
    border-left-color: var(--mnhs-primary);
}
.sidebar nav a .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.sidebar nav a.has-submenu {
    position: relative;
}
.sidebar nav a .submenu-arrow {
    margin-left: auto;
    font-size: 14px;
    transition: transform 0.2s;
}
.sidebar nav a.expanded .submenu-arrow {
    transform: rotate(180deg);
}
.sidebar .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    background: rgba(0,0,0,0.15);
}
.sidebar .submenu.open {
    max-height: 300px;
}
.sidebar .submenu a {
    display: block;
    padding: 8px 15px 8px 48px;
    color: #6a7d8c;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.sidebar .submenu a:hover {
    background: var(--mnhs-sidebar-hover);
    color: #cde;
}
.sidebar .submenu a.active {
    color: var(--mnhs-primary);
    border-left-color: var(--mnhs-primary);
}

/* === MAIN CONTENT === */
.main-content {
    margin-left: 220px;
    flex: 1;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: calc(100vw - 220px);
}
.topbar {
    background: #fff;
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 15px; }
.topbar-left .hamburger {
    font-size: 20px;
    cursor: pointer;
    color: #666;
    display: none;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right .user-info {
    font-size: 14px;
    color: #555;
}
.topbar-right .btn-logout {
    padding: 6px 12px;
    font-size: 13px;
    background: none;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    color: #666;
}
.topbar-right .btn-logout:hover { background: #f5f5f5; }

.content-area {
    padding: 25px;
}

/* === PAGE HEADER === */
.page-header {
    margin-bottom: 25px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 400;
    color: var(--mnhs-heading);
}
.page-header h1 + span {
    font-size: 14px;
    color: #999;
    margin-left: 10px;
}
.breadcrumb {
    font-size: 13px;
    color: #999;
    margin-bottom: 5px;
}
.breadcrumb a { color: var(--mnhs-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* === STAT CARDS === */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}
.stat-card {
    padding: 20px 25px;
    border-radius: 8px;
    color: #fff;
    position: relative;
}
.stat-card.blue { background: var(--mnhs-primary); }
.stat-card.red { background: #e74c3c; }
.stat-card.purple { background: #8e44ad; }
.stat-card.green { background: #27ae60; }
.stat-card.orange { background: #e67e22; }
.stat-card .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}
.stat-card .stat-number {
    font-size: 36px;
    font-weight: 700;
    margin-top: 5px;
}
.stat-card .stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    opacity: 0.3;
}

/* === CARDS === */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h2 {
    font-size: 16px;
    font-weight: 500;
    color: var(--mnhs-heading);
}
.card-body { padding: 20px; }

/* === TABLES === */
.table-container { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
table th {
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}
table tr:hover { background: #f8f9fa; }
table tr:last-child td { border-bottom: none; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn-primary { background: var(--mnhs-primary); color: #fff; }
.btn-primary:hover { background: var(--mnhs-primary-dark); }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: #ecf0f1; color: #555; }
.btn-secondary:hover { background: #ddd; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

/* === FORMS === */
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--mnhs-primary);
}

/* === MODAL === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: 10px;
    width: 600px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 18px; font-weight: 500; }
.modal-close {
    font-size: 20px;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
}
.modal-body { padding: 20px; }
.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* === TABS (in modal or detail) === */
.tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 15px;
}
.tab-btn {
    padding: 8px 16px;
    background: none;
    border: none;
    font-size: 14px;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab-btn.active { color: var(--mnhs-primary); border-bottom-color: var(--mnhs-primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === COLOR SWATCH === */
.color-swatch {
    width: 30px;
    height: 20px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.1);
}

/* === DETAIL VIEW (sidebar menu + content) === */
.detail-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 0;
}
.detail-menu {
    border-right: 1px solid #eee;
    padding: 15px 0;
}
.detail-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: #555;
    text-decoration: none;
    font-size: 14px;
}
.detail-menu a:hover { background: #f5f5f5; }
.detail-menu a.active { color: var(--mnhs-primary); background: #eef8fd; }
.detail-content { padding: 20px; }

/* === ALERT === */
.alert {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}
.alert-error { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }

/* === FOOTER === */
.footer {
    padding: 15px 25px;
    font-size: 12px;
    color: #999;
    text-align: center;
    border-top: 1px solid #eee;
    margin-top: auto;
}

/* === TOAST NOTIFICATIONS === */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 12px 20px 12px 16px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 420px;
    pointer-events: auto;
    animation: toast-in 0.3s ease;
}
.toast.toast-out { animation: toast-out 0.3s ease forwards; }
.toast-success { background: #27ae60; }
.toast-error { background: #e74c3c; }
.toast-warning { background: #e67e22; }
.toast-info { background: var(--mnhs-primary); }
@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* === BUTTON LOADING STATE === */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .sidebar.open { width: 220px; }
    .main-content { margin-left: 0; max-width: 100vw; overflow-x: hidden; }
    .topbar-left .hamburger { display: block; }
    .stat-cards { grid-template-columns: 1fr; }
    .detail-layout { grid-template-columns: 1fr; }
    .helix-header-text { font-size: 24px !important; }
    .helix-header-url { font-size: 16px !important; }

    /* Global: alle tabeller i hovedinnholdet blir horisontalt scrollbare på mobil.
       Bruk .no-mobile-scroll for å ekskludere (f.eks. layout-tabeller). */
    .content-area table:not(.no-mobile-scroll) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        white-space: nowrap;
    }
    /* Tillat at lange beskrivelser likevel kan brytes på <br> i celler */
    .content-area table:not(.no-mobile-scroll) td,
    .content-area table:not(.no-mobile-scroll) th {
        white-space: normal;
    }
}

@media (max-width: 480px) {
    .content-area { padding: 8px; }
    .modal-content { width: 95% !important; min-width: auto !important; }
    .helix-header-text { font-size: 20px !important; }
    .helix-header-url { font-size: 14px !important; }
    .dev-badge { font-size: 9px !important; padding: 3px 8px !important; }
    .topbar { padding: 6px 10px; }
    .user-info { font-size: 12px; }
    .btn-logout { font-size: 12px; padding: 4px 10px; }
}
