/* ===== Global Styling og Temaer ===== */
:root {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-header: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #f8fafc;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s ease-in-out;
}

body.dark-theme {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-header: #020617;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-light: #1e3a8a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Layout ===== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.app-main {
    flex: 1;
    padding: 24px 0;
}

/* ===== Header ===== */
.app-header {
    background-color: var(--bg-header);
    color: var(--text-light);
    padding: 16px 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 2rem;
    color: #60a5fa;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ===== Knapper & Skjemaer ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--accent-color);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

body.light-theme .btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

body.light-theme .btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-success {
    background-color: #10b981;
    color: #ffffff;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ===== Kontrollpanel Card ===== */
.controls-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.controls-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.flex-grow {
    flex: 1 1 280px;
}

.select-with-btn {
    display: flex;
    gap: 8px;
}

.view-toggle {
    display: flex;
    background-color: var(--bg-primary);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.toggle-btn {
    border: none;
    background: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.toggle-btn.active {
    background-color: var(--accent-color);
    color: #ffffff;
}

.controls-secondary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-info {
    background-color: var(--accent-light);
    color: var(--accent-color);
}

/* ===== Horisontal Tidslinje ===== */
.horizontal-wrapper {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
}

.timeline-navigation {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-arrow {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 5;
    flex-shrink: 0;
}

.nav-arrow:hover {
    background-color: var(--accent-color);
    color: #ffffff;
    border-color: var(--accent-color);
}

.horizontal-track-container {
    flex: 1;
    overflow-x: auto;
    position: relative;
    padding: 80px 20px 40px 20px;
    scrollbar-width: thin;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--accent-color);
    z-index: 1;
    border-radius: 2px;
}

.horizontal-events-track {
    display: flex;
    gap: 60px;
    position: relative;
    z-index: 2;
    min-width: max-content;
}

.h-event-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 220px;
    position: relative;
    cursor: pointer;
}

.h-event-node .node-dot {
    width: 18px;
    height: 18px;
    background-color: var(--bg-card);
    border: 4px solid var(--accent-color);
    border-radius: 50%;
    transition: var(--transition);
    margin: 12px 0;
    box-shadow: 0 0 0 4px var(--bg-card);
}

.h-event-node:hover .node-dot {
    transform: scale(1.3);
    background-color: var(--accent-color);
}

.h-event-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    transition: var(--transition);
    text-align: left;
}

.h-event-node:hover .h-event-card {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.node-year {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
    display: block;
    margin-bottom: 2px;
}

.node-title {
    font-size: 0.925rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
}

.node-summary {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Alternerende plassering (opp/ned) */
.h-event-node:nth-child(even) {
    flex-direction: column-reverse;
}

/* ===== Vertikal Tidslinje ===== */
.vertical-wrapper {
    padding: 20px 0;
}

.vertical-timeline {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

.vertical-timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background-color: var(--accent-color);
    transform: translateX(-50%);
    border-radius: 2px;
}

.v-event-item {
    display: flex;
    justify-content: flex-end;
    padding-right: 30px;
    position: relative;
    margin-bottom: 40px;
    width: 50%;
}

.v-event-item:nth-child(even) {
    align-self: flex-end;
    justify-content: flex-start;
    padding-right: 0;
    padding-left: 30px;
    margin-left: 50%;
}

.v-event-dot {
    position: absolute;
    top: 16px;
    right: -9px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 4px solid var(--accent-color);
    z-index: 2;
}

.v-event-item:nth-child(even) .v-event-dot {
    right: auto;
    left: -9px;
}

.v-event-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    transition: var(--transition);
    position: relative;
}

.v-event-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.v-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.v-card-year {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-color);
}

.v-card-category {
    font-size: 0.725rem;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: var(--accent-light);
    color: var(--accent-color);
    font-weight: 600;
}

.v-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.v-card-summary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.v-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

/* ===== Modaler ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 20px;
    font-size: 1.6rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-header-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 18px;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.required {
    color: #ef4444;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Modal Detaljevisning */
.event-detail-img {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.event-detail-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.event-detail-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.event-detail-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
}

/* ===== Footer ===== */
.app-footer {
    background-color: var(--bg-header);
    color: #94a3b8;
    padding: 20px 0;
    text-align: center;
    font-size: 0.85rem;
    margin-top: auto;
}

.app-footer a {
    color: #60a5fa;
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* ===== Responsive Adaptabilitet ===== */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    .btn-text {
        display: none;
    }
    .vertical-timeline::before {
        left: 20px;
    }
    .v-event-item, .v-event-item:nth-child(even) {
        width: 100%;
        margin-left: 0;
        padding-left: 50px;
        padding-right: 0;
    }
    .v-event-dot, .v-event-item:nth-child(even) .v-event-dot {
        left: 11px;
        right: auto;
    }
}

/* ===== Utskriftsmodus (Print/PDF) ===== */
@media print {
    .app-header, .controls-card, .nav-arrow, .v-card-actions, .app-footer, .modal {
        display: none !important;
    }
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
    .vertical-timeline::before {
        background-color: #000000 !important;
    }
    .v-event-dot {
        border-color: #000000 !important;
    }
    .v-event-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
}
