/* --- 1. Globale Variabler og Grundlæggende Styling --- */

:root {
    --primary-color: #4a69bd;
    --background-color: #f4f7fa;
    --sidebar-bg: #ffffff;
    --text-color: #323f4e;
    --border-color: #e0e0e0;
    --danger-color: #e74c3c;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

html {
    height: 100%;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Raleway', Arial, Verdana, Tahoma, Trebuchet MS;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    height: 100%;
}

h1, h2, h3 {
    font-weight: 900;
    color: var(--text-color);
}

h1 { font-size: 1.8em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.2em; }

a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}
a:hover {
    text-decoration: underline;
}


/* --- 2. Hovedlayout (Sidebar og Main Content) --- */

/* Gælder for alle sider UNDTAGEN login-siden */
body:not(.login-page) {
    display: flex;
}

.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 23px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h3 {
    margin: 0;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.nav-links a {
    display: block;
    padding: 12px 20px;
    color: var(--text-color);
    border-left: 3px solid transparent;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
}

.nav-links a:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
    text-decoration: none;
}

.main-content {
    flex-grow: 1;
    padding-top: 0px;    
    padding-right: 20px;  
    padding-bottom: 20px; 
    padding-left: 20px;   
    margin-left: 240px; 
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

.content-area {
    margin-top: 20px;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}


/* --- 3. Genbrugelige Komponenter (Knapper, Formularer, Tabeller) --- */

/* Knapper */
.btn {
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Raleway', Arial, Verdana, Tahoma, Trebuchet MS;
    font-weight: 500;
    transition: background-color 0.2s ease;
    margin-left: 10px;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: #3b5998; }
.btn-secondary { background-color: #e0e0e0; color: var(--text-color); }
.btn-secondary:hover { background-color: #c7c7c7; }
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-danger:hover { background-color: #c0392b; }

/* Formularer */
input[type="text"],
input[type="date"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1em;
    box-sizing: border-box;
}

.action-box {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    flex-grow: 1;
}
.action-box h3 {
    margin-top: 0;
    margin-bottom: 15px;
}

/* Tabeller */
.table-container {
    width: 100%;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
thead th {
    background-color: var(--background-color);
    position: sticky;
    top: 0;
    z-index: 1;
}
tbody tr:hover {
    background-color: #f9f9f9;
}


/* --- 4. Side-specifik Styling --- */

/* --- Login-siden --- */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
}
.login-box {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.login-header {
    text-align: center;
    margin-bottom: 25px;
}
.login-header h1 {
    margin: 10px 0 0 0;
    font-size: 1.5em;
}
#loginform {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}
#loginform .form-group {
    width: 100%;
    max-width: 300px;
    margin-bottom: 5px;
}
#loginform label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    text-align: left;
}
#loginform .btn {
    width: 100%;
    max-width: 300px;
    padding: 12px;
    margin-top: 10px;
}

/* --- Analytics-siden --- */
.analytics-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
}
.analytics-controls .stats-overview span { margin-left: 1.5em; }
.analytics-controls .stats-overview em { font-style: normal; font-weight: bold; color: var(--primary-color); }
.chart-container {
    position: relative;
    width: 100%;
    height: 70vh;
}
.yearly-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-size: 1.1em;
}
.yearly-stats em { font-style: normal; font-weight: bold; }

.date-picker {
    display: flex;        
    flex-wrap: nowrap;     
    align-items: center;  
    gap: 8px;             
}

/* Styling for labels (teksten) */
.date-picker label {
    font-weight: bold;
    white-space: nowrap;   
    flex-shrink: 0;        
}

/* Fælles styling for selve boksene (input og select) */
.date-picker input[type="date"],
.date-picker select {
    padding: 6px 10px;      
    font-size: 14px;        
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #fff;
    width: auto; 
    flex-grow: 1;           
    max-width: 200px;       
}

/* --- Licenses-siden --- */
.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.form-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.activations-row td {
    padding: 0 !important;
    background-color: #f8f9fa; /* En let baggrundsfarve for at adskille den */
    border-top: 1px solid #007bff; /* En blå top-kant for at vise "åben" tilstand */
}

.activations-content {
    padding: 1.5em;
}

.activations-content h4 {
    margin-top: 0;
}

.inner-table {
    width: 100%;                      /* Beholder fleksibiliteten på mindre skærme */
    max-width: 750px;                 /* NYT: Sætter en grænse for, hvor bred tabellen kan blive */
    border-collapse: collapse;
    margin-bottom: 1em;               /* Lidt ekstra plads i bunden */
}

.inner-table th, .inner-table td {
    text-align: left;
    padding: 12px 15px;               /* Justeret for en lidt mere luftig fornemmelse */
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

/* Definerer faste bredder for kolonnerne i den nye rækkefølge */
.inner-table th:nth-child(1), 
.inner-table td:nth-child(1) {
    width: 15%; /* Giver 'Action' passende plads */
    text-align: left; /* Standard venstrestilling */
}

.inner-table th:nth-child(2), 
.inner-table td:nth-child(2) {
    width: 70%; /* Giver 'Nickname' mest plads */
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

/* --- Forbedret styling for Modal og dens form-grid --- */

/* Selve modal-containeren (baggrunds-overlay) */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Selve pop-up boksen */
.modal-container .action-box {
    background-color: #fffbe6;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 600px;
}

/* Hoved-grid container i modalen */
.modal-container .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Styling for hver label-input gruppe */
.modal-container .form-group {
    display: flex;
    flex-direction: column;
}

.modal-container .form-group label {
    margin-bottom: 6px;
    font-weight: bold;
    font-size: 13px;
    color: #555;
    text-align: left;
}

/* Får "Notes" gruppen til at spænde over BEGGE kolonner */
.modal-container .form-grid .form-group:nth-of-type(3) {
    grid-column: 1 / -1;
}

/* Container for knapperne, der spænder over begge kolonner i bunden */
.modal-container .form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Specifik styling for Annuller-knappen for at flytte den til venstre */
.modal-container .form-actions .btn-secondary {
    margin-right: auto;
}

/* Styling for den klikbare licensnøgle */
.clickable-key {
    margin-left: 10px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer; /* VIGTIGT: Viser en hånd, når musen er over */
    transition: background-color 0.2s ease;
}

/* Giver en diskret baggrundsfarve, når brugeren peger på nøglen */
.clickable-key:hover {
    background-color: #e9eff5; 
}

/* Styling for feedback-teksten "Key Copied!" */
.copied-feedback {
    font-weight: bold;
    color: #28a745; /* En positiv grøn farve */
}

.copied-feedback:hover {
    background-color: transparent; /* Ingen hover-effekt på feedback-teksten */
}

/* --- Notifications-siden --- */
.notification-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: center;
}
.notification-form textarea,
.notification-form button {
    grid-column: 1 / -1;
}
.notification-form input[type="file"] { border: none; padding: 0; }

/* --- Library-siden --- */
.column-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.column {
    flex: 1;
}
.column h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.drag-drop {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background-color: var(--background-color);
    transition: background-color 0.2s ease, border-color 0.2s ease;
    position: relative;
}
.drag-drop:hover {
    background-color: #e9eff5;
    border-color: var(--primary-color);
}
.drag-drop input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-list { margin-top: 15px; }