/**
 * Link Groups Add-on Specific Styling
 * Version: 2.0.0
 * 
 * NOTE: Basis styling (buttons, forms, modals, toast) kommer fra Core!
 * Dette stylesheet indeholder KUN Link Groups-specifikke styles.
 */

/* =================================================================
   LINK GROUPS CONTAINER
   ================================================================= */

.link-groups-container {
    margin-top: 20px;
}

/* =================================================================
   LINK GROUP STYLING
   ================================================================= */

.link-group {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.link-group:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #ccc;
    transform: translateY(-1px);
}

.group-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: background-color 0.2s ease;
}

.group-header:hover {
    background: #f0f2f4;
}

.group-info {
    flex: 1;
    margin-right: 15px;
}

.group-title {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 10px;
}

.links-count {
    font-size: 14px;
    font-weight: normal;
    color: #646970;
    background: #e8e8e8;
    padding: 2px 8px;
    border-radius: 12px;
}

.group-description {
    margin: 0;
    color: #646970;
    font-size: 14px;
    line-height: 1.4;
}

.group-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.group-actions .button {
    padding: 4px 8px;
    font-size: 12px;
    height: auto;
    line-height: 1.4;
}

.group-actions .button .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.group-content {
    padding: 0;
    transition: all 0.3s ease;
    overflow: hidden;
}

.link-group.collapsed .group-content {
    max-height: 0;
    padding: 0;
}

.link-group:not(.collapsed) .group-content {
    max-height: none;
}

/* =================================================================
   DRAG & DROP HANDLES
   ================================================================= */

.group-drag-handle,
.link-drag-handle {
    cursor: move;
    color: #999;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
    position: relative;
}

.group-drag-handle:hover,
.link-drag-handle:hover {
    color: #0073aa;
    transform: scale(1.1);
}

.group-drag-handle:active,
.link-drag-handle:active {
    transform: scale(0.95);
}

/* Sortable helper states */
.link-group.ui-sortable-helper {
    background: #fff;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: rotate(2deg);
    z-index: 1000;
    border: 2px solid #0073aa;
}

.link-item.ui-sortable-helper {
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: rotate(1deg);
    z-index: 1000;
    border: 2px solid #0073aa;
}

.ui-sortable-placeholder {
    background: #f0f0f0;
    border: 2px dashed #0073aa;
    opacity: 0.5;
    visibility: visible !important;
}

/* Drag active states */
.ui-sortable-dragging {
    cursor: grabbing !important;
}

.ui-sortable-dragging .group-drag-handle,
.ui-sortable-dragging .link-drag-handle {
    color: #0073aa;
    transform: scale(1.2);
}

/* =================================================================
   LINKS LIST
   ================================================================= */

.links-list {
    padding: 15px 20px 20px;
}

.link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    margin-bottom: 10px;
    background: #f9f9f9;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.link-item:hover {
    background: #f0f2f4;
    border-color: #ddd;
    transform: translateX(2px);
}

.link-item:last-child {
    margin-bottom: 0;
}

.link-info {
    flex: 1;
    margin-right: 10px;
    min-width: 0;
}

.link-name {
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 4px;
    font-size: 14px;
}

.link-description {
    color: #646970;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 4px;
}

.link-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.link-actions .button {
    padding: 3px 6px;
    font-size: 11px;
    height: auto;
    line-height: 1.3;
}

.link-actions .button .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

.no-links-message {
    text-align: center;
    color: #646970;
    font-style: italic;
    padding: 20px;
    background: #f9f9f9;
    border: 1px dashed #ddd;
    border-radius: 4px;
}

/* =================================================================
   CROSS-GROUP DRAG STATES
   ================================================================= */

.link-item.moved-success {
    animation: linkMovedSuccess 2s ease-out;
    border-color: #46b450;
    background: #f7fcf0;
}

@keyframes linkMovedSuccess {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(70, 180, 80, 0.7);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(70, 180, 80, 0);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(70, 180, 80, 0);
    }
}

.link-item.reverting-move {
    animation: revertMove 0.5s ease-out;
    border-color: #dc3232;
    background: #fef7f7;
}

@keyframes revertMove {
    0% { 
        transform: scale(1.05);
        box-shadow: 0 0 0 0 rgba(220, 50, 50, 0.7);
    }
    50% { 
        transform: scale(0.98);
        box-shadow: 0 0 0 10px rgba(220, 50, 50, 0);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 50, 50, 0);
    }
}

.link-item.moving-link {
    opacity: 0.7;
    pointer-events: none;
}

/* Empty group styling */
.links-list.empty-group {
    background: #fafafa;
    border: 2px dashed #e0e0e0;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.links-list.empty-group::after {
    content: 'Træk links her for at tilføje dem til denne gruppe';
    color: #999;
    font-style: italic;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* =================================================================
   HEADER ACTIONS (Specific to Link Groups)
   ================================================================= */

.admin-header .header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#open-all-links-btn {
    background: #00a32a;
    border-color: #00a32a;
    color: #fff;
}

#open-all-links-btn:hover {
    background: #008a25;
    border-color: #008a25;
}

/* =================================================================
   UPDATING STATES
   ================================================================= */

.updating-order {
    opacity: 0.7;
    pointer-events: none;
}

.updating-order .group-drag-handle,
.updating-order .link-drag-handle {
    opacity: 0.5;
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */

@media (max-width: 768px) {
    .group-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .group-info {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .group-actions {
        justify-content: flex-end;
    }
    
    .link-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .link-info {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .link-actions {
        justify-content: flex-end;
    }
    
    .admin-header .header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    
    .group-drag-handle,
    .link-drag-handle {
        min-height: 44px;
        min-width: 44px;
    }
}

@media (max-width: 480px) {
    .group-title {
        font-size: 16px;
    }
    
    .links-count {
        font-size: 12px;
    }
}

/* =================================================================
   ACCESSIBILITY
   ================================================================= */

.group-drag-handle:focus,
.link-drag-handle:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .link-group,
    .link-item,
    .group-drag-handle,
    .link-drag-handle {
        transition: none;
        animation: none;
    }
}

/* =================================================================
   UTILITY
   ================================================================= */

.spin {
    animation: spin 1s linear infinite;
}

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

.button-link-delete:hover {
    color: #d63638;
    border-color: #d63638;
}
