/* css/components.css */

/* --- 1. BUTTONS & UI ELEMENTS --- */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer; font-weight: 600;
    transition: all 0.2s ease;
    background: var(--card-bg); color: var(--text);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { border-color: var(--primary-dark); color: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn.active { background-color: var(--primary-dark); color: white; border-color: var(--primary-dark); }

.btn-icon-only {
    background: transparent;
    border: 1px solid grey;
    border-radius: var(--radius);
    padding: 8px 7px 5px 7px;
    cursor: pointer;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: var(--bg);
}

.btn-del {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
}

.btn-del:hover {
    color: var(--danger)
}

.btn-big {
    height: 250px;
    width: 250px;
    display: block;
}

.btn-close {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    color: #9ca3af;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 10;
}
.btn-close:hover { background-color: #f3f4f6; color: #ef4444; transform: scale(1.1); }
.btn-close:focus { outline: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5); }

/* Felles styling for alle Lucide-ikoner */
.lucide,
[data-lucide] {
    width: 1.2em;
    height: 1.2em;
    stroke-width: 2px;
    vertical-align: middle;
    display: inline-block;
    color: var(--text);
}

/* Fargepalett for ikoner */
.icon-success { color: #10b981; } /* Grønn */
.icon-error   { color: #ef4444; } /* Rød */
.icon-warning { color: #f59e0b; } /* Oransje */
.icon-info    { color: #3b82f6; } /* Blå */
.icon-magic   { color: #a855f7; } /* Lilla */

/* Animasjon for laste-ikon */
.icon-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Spesialhåndtering for drag-handle (⋮⋮) */
.drag-handle {
    cursor: grab;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.drag-handle:hover { opacity: 1; }

.badge {
    font-size: 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success {
    background: var(--success);
    color: var(--bg);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* --- 1.5 FORMS --- */
.toolbar {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    display: block;
    box-sizing: border-box !important;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px var(--primary-dark-10);
}

/* iOS Date Fix */
input[type="date"].form-control {
    -webkit-appearance: none;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.search-wrapper {
    flex: 1;     
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper [data-lucide], 
.search-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #888;
    pointer-events: none;
    display: block;
}

.search-input {
    width: 100%;
    height: 40px;
    padding: 8px 12px 8px 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    line-height: 1;
}

.search-input:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 2px var(--border-dark);
}

.btn-group {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.btn-group .btn {
    border: none;
    border-right: 1px solid #ddd;
    border-radius: 0;
    padding: 8px 16px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.active { background: #007bff; color: white; }
.btn-group .btn:hover:not(.active) { background: #f8f9fa; }

.status-filter-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pill-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    user-select: none;
    padding: 6px 14px;
    border-radius: 20px;
    background: #f0f0f0;
    border: 1px solid transparent;
    transition: all 0.2s;
}
.pill-checkbox:has(input:checked) { background: #e7f3ff; border-color: #007bff; color: #0056b3; }
.pill-checkbox input { cursor: pointer; margin: 0; }

/* --- 2. VIEW CONTAINERS (Grid & List Wrappers) --- */
.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Standard grid størrelse */
    gap: 20px;
    padding-bottom: 20px;
}

.view-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

/* --- 3. UNIVERSAL CARDS (Catalog & Media) --- */
.data-card, .media-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative; /* Viktig for overlays */
}

.data-card:hover, .media-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-dark);
}

/* Bilde-container inni kortet */
.card-image, .media-thumb-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.card-image img, .media-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 4px;
}

/* Tekst-styling inni kort */
.card-title-lg { font-size: 0.95rem; font-weight: 700; color: var(--primary); margin: 0; line-height: 1.2; }
.card-subtitle { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.card-meta-row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 10px; }


/* --- 4. UNIVERSAL LIST ITEMS --- */
.data-list-item, .media-list-item {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.15s ease;
    cursor: pointer;
    align-items: stretch;
    height: 70px;
}

.data-list-item:hover, .media-list-item:hover {
    border-color: var(--primary-dark);
    background: #fafbfc;
}

.list-thumb {
    width: 70px;
    min-width: 70px;
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
}

.list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.list-content {
    flex-grow: 1;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0; /* Hindrer flex-child i å sprenge container */
}

.list-main-info { display: flex; flex-direction: column; gap: 2px; }
.list-primary-text { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.list-secondary-text { font-size: 0.8rem; color: var(--text-muted); }



/* --- LISTEVISNING (view-list) --- */
.view-list {
    display: flex;
    flex-direction: column;
    gap: 0px;
    width: 100%;
    margin: 0 auto;
}

.data-list-item {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    gap: 15px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 110px;
    max-height: 120px;
}

.data-list-item:hover {
    transform: translateX(5px);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* FIKS FOR MEGA-BILDE: */
.list-image {
    flex: 0 0 60px; /* Låser bredden på bilde-containeren */
    width: 60px;
    height: 60px;
}

.list-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Sikrer at bildet fyller kvadratet uten å bli strukket */
    border-radius: 4px;
}

.list-content {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-main-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.list-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.list-header .badge{
    font-size: 0.6rem;
}

.list-year {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--primary); /* Gir litt farge til detaljene */
}

/* Artistnavnet skal være tydeligst */
.list-artist {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 2px;
}

/* Utgivelsestittel skal være litt nedtonet */
.list-title {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 400;
}

.list-footer {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
}

/* Responsiv fiks for mobil */
@media (max-width: 600px) {
    .list-footer svg {
        display: none; /* Skjul pilen på små skjermer for å spare plass */
    }
}

/* --- 5. TABLES --- */
.table-responsive {
    width: 100%; overflow-x: auto;
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px;
}
.modern-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
.modern-table th { background: var(--bg-secondary); text-align: left; padding: 12px 15px; color: var(--text-muted); font-weight: 700; border-bottom: 1px solid var(--border); }
.modern-table td { padding: 10px 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.modern-table tbody tr:hover { background-color: rgba(25, 118, 210, 0.05); }


/* --- 6. MODALS & TOASTS (Uendret fra før, men beholdes her) --- */

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(27, 29, 31, 0.7);
    z-index: 5000 !important;
    backdrop-filter: blur(4px);
    padding: 20px;
    display: none; 
    justify-content: center; 
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    display: flex; 
    opacity: 1;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-card { background: var(--card-bg); width: 100%; max-width: 600px; max-height: 90vh; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden; }
.modal-header { position: relative; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); background: var(--bg); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 15px 20px; background: var(--bg-secondary); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.toast-container { position: fixed; bottom: 25px; right: 25px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast { background: var(--card-bg); padding: 12px 20px; border-radius: var(--radius); box-shadow: var(--shadow-md); border-left: 4px solid var(--primary); display: flex; align-items: center; justify-content: space-between; min-width: 250px; animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* --- 7. TAGS & BADGES --- */
.card-tags {
    position: absolute;
    bottom: 5px;
    left: 5px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.tag-badge {
    background: var(--primary-light);
    color: white;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    backdrop-filter: blur(2px);
}

.tag-item {
    background: #e9ecef;
    padding: 4px 8px;
    border-radius: 15px;
    margin-right: 5px;
    font-size: 12px;
}

.btn-tag-suggest {
    background: #f0f7ff;
    border: 1px dashed var(--primary-dark);
    color: var(--primary-dark);
    font-size: 11px;
    border-radius: 4px;
    margin-left: 5px;
    cursor: pointer;
    padding: 4px 6px;
}

/* --- NY TAG POPUP (Fiks for layout og visning) --- */
/* --- NY TAG POPUP (Fiks for layout og visning) --- */
/* --- NY TAG POPUP (Fiks for layout og visning) --- */
#tagCategoryModal {
    /* Sørg for at den flyter over alt annet */
    position: fixed; 
    z-index: 6000; /* Må være høyere enn media-modalen (z-index 1000-ish) */
    
    /* Standard utseende */
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 260px; /* Litt bredere for å se pen ut */

    /* VIKTIG: Dette gjør at den plasserer seg "oppå" koordinatet vi gir den */
    transform: translateY(-100%); 
    margin-top: -10px; /* Lager 10px luft mellom felt og popup */
    
    /* Skjul som standard */
    display: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#tagCategoryModal.active {
    display: block;
    opacity: 1;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Kortet inni popupen */
#tagCategoryModal .tag-selector-card {
    padding: 12px;
}

/* Pilen på toppen av popupen */
#tagCategoryModal .tag-selector-card::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 20px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* Overskrift/Tekst inni popup */
#tagCategoryModal p {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #64748b;
    padding-right: 15px; /* Plass til krysset */
}

#tagCategoryModal strong {
    color: #1e293b;
}

/* Mini-grid for knappene */
#tagCategoryModal .tag-type-grid-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

#tagCategoryModal .type-btn-mini {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 6px;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #475569;
}

#tagCategoryModal .type-btn-mini:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #2563eb;
    transform: translateY(-1px);
}


/* --- TAG AUTOCOMPLETE DROPDOWN --- */
/* --- TAG AUTOCOMPLETE DROPDOWN --- */
/* --- TAG AUTOCOMPLETE DROPDOWN --- */
.tag-input-wrapper {
    position: relative; /* Viktig for at dropdown skal henge fast her */
}

.tag-suggestions-dropdown {
    position: absolute;
    top: 100%; /* Rett under feltet */
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100; /* Økt z-index for å ligge over andre ting i modalen */
    display: none; /* Skjult som standard */
}

.tag-suggestions-dropdown.active {
    display: block;
}

/* Endret fra .suggestion-item til .dropdown-item for å matche ui-tags.js */
.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background-color: #f0f9ff; /* Lys blå ved hover */
    color: #000;
}

.suggestion-type {
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Styling for "Legg til ny" knappen nederst */
.dropdown-item.create-item {
    border-top: 1px solid #e5e7eb;
    font-weight: 600;
    color: #2563eb; /* Blå tekst */
    background: #f8fafc;
}
.dropdown-item.create-item:hover {
    background: #eff6ff;
}

/* --- TAG MANAGER V2 STYLING (Lagt til for TagUI) --- */
.tag-manager-v2 {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.tag-chips-area {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px; /* Hindrer hopping hvis tom */
    align-items: center;
    margin-bottom: 5px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px; /* Pille-form */
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

/* Stil for eksisterende/lagrede tags (Verified) */
.tag-chip.is-verified {
    background-color: #e0f2fe; /* Lys blå */
    color: #0369a1;
    border: 1px solid #bae6fd;
}

/* Stil for nye/lokale tags (New) */
.tag-chip.is-new {
    background-color: #f1f5f9; /* Lys grå */
    color: #475569;
    border: 1px dashed #cbd5e1;
}

.tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: inherit;
    padding: 0;
    transition: background 0.2s;
}

.tag-remove:hover {
    background: rgba(0,0,0,0.15);
    color: #ef4444; /* Rød ved hover */
}

.tag-main-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tag-main-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* Soft glow */
}